module: | watchdog.events |
---|---|
synopsis: | File system events and event handlers. |
author: | yesudeep@google.com (Yesudeep Mangalapilly) |
Bases: object
Immutable type that represents a file system event that is triggered when a change occurs on the monitored file system.
All FileSystemEvent objects are required to be immutable and hence can be used as keys in dictionaries or be added to sets.
The type of the event as a string.
True if event was emitted for a directory; False otherwise.
Bases: watchdog.events.FileSystemEvent
File system event representing any kind of file system movement.
Bases: watchdog.events.FileSystemMovedEvent
File system event representing file movement on the file system.
Bases: watchdog.events.FileSystemMovedEvent
File system event representing directory movement on the file system.
Bases: watchdog.events.FileSystemEvent
File system event representing file modification on the file system.
Bases: watchdog.events.FileSystemEvent
File system event representing directory modification on the file system.
Bases: watchdog.events.FileSystemEvent
File system event representing file creation on the file system.
Bases: watchdog.events.FileSystemEvent
File system event representing directory creation on the file system.
Bases: watchdog.events.FileSystemEvent
File system event representing file deletion on the file system.
Bases: watchdog.events.FileSystemEvent
File system event representing directory deletion on the file system.
Bases: object
Base file system event handler that you can override methods from.
Dispatches events to the appropriate methods.
Parameters: | event (FileSystemEvent) – The event object representing the file system event. |
---|
Catch-all event handler.
Parameters: | event (FileSystemEvent) – The event object representing the file system event. |
---|
Called when a file or directory is created.
Parameters: | event (DirCreatedEvent or FileCreatedEvent) – Event representing file/directory creation. |
---|
Called when a file or directory is deleted.
Parameters: | event (DirDeletedEvent or FileDeletedEvent) – Event representing file/directory deletion. |
---|
Called when a file or directory is modified.
Parameters: | event (DirModifiedEvent or FileModifiedEvent) – Event representing file/directory modification. |
---|
Called when a file or a directory is moved or renamed.
Parameters: | event (DirMovedEvent or FileMovedEvent) – Event representing file/directory movement. |
---|
Bases: watchdog.events.FileSystemEventHandler
Matches given patterns with file paths associated with occurring events.
(Read-only) True if path names should be matched sensitive to case; False otherwise.
Dispatches events to the appropriate methods.
Parameters: | event (FileSystemEvent) – The event object representing the file system event. |
---|
Bases: watchdog.events.FileSystemEventHandler
Matches given regexes with file paths associated with occurring events.
(Read-only) True if path names should be matched sensitive to case; False otherwise.
Dispatches events to the appropriate methods.
Parameters: | event (FileSystemEvent) – The event object representing the file system event. |
---|
Bases: watchdog.events.FileSystemEventHandler
Logs all the events captured.
Bases: watchdog.utils.bricks.SkipRepeatsQueue
Thread-safe event queue based on a special queue that skips adding the same event (FileSystemEvent) multiple times consecutively. Thus avoiding dispatching multiple event handling calls when multiple identical events are produced quicker than an observer can consume them.
Bases: watchdog.utils.BaseThread
Producer thread base class subclassed by event emitters that generate events and populate a queue with them.
Parameters: |
|
---|
Queues a single event.
Parameters: | event (An instance of watchdog.events.FileSystemEvent or a subclass.) – Event to be queued. |
---|
Bases: watchdog.utils.BaseThread
Consumer thread base class subclassed by event observer threads that dispatch events from an event queue to appropriate event handlers.
Parameters: | timeout (float) – Event queue blocking timeout (in seconds). |
---|
Override this method to consume events from an event queue, blocking on the queue for the specified timeout before raising queue.Empty.
Parameters: |
|
---|---|
Raises: | queue.Empty |
Bases: watchdog.observers.api.EventDispatcher
Base observer.
Adds a handler for the given watch.
Parameters: |
|
---|
Removes a handler for the given watch.
Parameters: |
|
---|
Schedules watching a path and calls appropriate methods specified in the given event handler in response to file system events.
Parameters: |
|
---|---|
Returns: | An ObservedWatch object instance representing a watch. |
Unschedules a watch.
Parameters: | watch (An instance of ObservedWatch or a subclass of ObservedWatch) – The watch to unschedule. |
---|
module: | watchdog.observers |
---|---|
synopsis: | Observer that picks a native implementation if available. |
author: | yesudeep@google.com (Yesudeep Mangalapilly) |
alias of InotifyObserver
Observer thread that schedules watching directories and dispatches calls to event handlers.
You can also import platform specific classes directly and use it instead of Observer. Here is a list of implemented observer classes.:
Class | Platforms | Note |
---|---|---|
inotify.InotifyObserver | Linux 2.6.13+ | inotify(7) based observer |
fsevents.FSEventsObserver | Mac OS X | FSEvents based observer |
kqueue.KqueueObserver | Mac OS X and BSD with kqueue(2) | kqueue(2) based observer |
read_directory_changes.WindowsApiObserver | MS Windows | Windows API-based observer |
polling.PollingObserver | Any | fallback implementation |
module: | watchdog.observers.polling |
---|---|
synopsis: | Polling emitter implementation. |
author: | yesudeep@google.com (Yesudeep Mangalapilly) |
Bases: watchdog.observers.api.BaseObserver
Platform-independent observer that polls a directory to detect file system changes.
Bases: watchdog.observers.api.BaseObserver
File system independent observer that polls a directory to detect changes.
module: | watchdog.utils |
---|---|
synopsis: | Utility classes and functions. |
author: | yesudeep@google.com (Yesudeep Mangalapilly) |
Bases: threading.Thread
Convenience class for creating stoppable threads.
A boolean value indicating whether this thread is a daemon thread (True) or not (False).
This must be set before start() is called, otherwise RuntimeError is raised. Its initial value is inherited from the creating thread; the main thread is not a daemon thread and therefore all threads created in the main thread default to daemon = False.
The entire Python program exits when no alive non-daemon threads are left.
Thread identifier of this thread or None if it has not been started.
This is a nonzero integer. See the thread.get_ident() function. Thread identifiers may be recycled when a thread exits and another thread is created. The identifier is available even after the thread has exited.
Return whether the thread is alive.
This method returns True just before the run() method starts until just after the run() method terminates. The module function enumerate() returns a list of all alive threads.
Return whether the thread is alive.
This method returns True just before the run() method starts until just after the run() method terminates. The module function enumerate() returns a list of all alive threads.
Wait until the thread terminates.
This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.
When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call isAlive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.
When the timeout argument is not present or None, the operation will block until the thread terminates.
A thread can be join()ed many times.
join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.
A string used for identification purposes only.
It has no semantics. Multiple threads may be given the same name. The initial name is set by the constructor.
Override this method instead of start(). start() calls this method.
This method is called right before this thread is started and this object’s run() method is invoked.
Override this method instead of stop(). stop() calls this method.
This method is called immediately after the thread is signaled to stop.
Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
module: | watchdog.utils.dirsnapshot |
---|---|
synopsis: | Directory snapshots and comparison. |
author: | yesudeep@google.com (Yesudeep Mangalapilly) |
Where are the moved events? They “disappeared”
This implementation does not take partition boundaries into consideration. It will only work when the directory tree is entirely on the same file system. More specifically, any part of the code that depends on inode numbers can break if partition boundaries are crossed. In these cases, the snapshot diff will represent file/directory movement as created and deleted events.
Bases: object
A snapshot of stat information of files in a directory.
Parameters: |
|
---|
Returns a stat information object for the specified path from the snapshot.
Attached information is subject to change. Do not use unless you specify stat in constructor. Use inode(), mtime(), isdir() instead.
Parameters: | path – The path for which stat information should be obtained from a snapshot. |
---|
Bases: object
Compares two directory snapshots and creates an object that represents the difference between the two snapshots.
Parameters: |
|
---|