本文整理汇总了Python中watchdog.observers.api.EventEmitter类的典型用法代码示例。如果您正苦于以下问题:Python EventEmitter类的具体用法?Python EventEmitter怎么用?Python EventEmitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventEmitter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
EventEmitter.__init__(self, event_queue, watch, timeout)
self._lock = threading.Lock()
self._directory_handle = get_directory_handle(watch.path,
WATCHDOG_FILE_FLAGS)
self._buffer = ctypes.create_string_buffer(BUFFER_SIZE)
示例2: __init__
def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
EventEmitter.__init__(self, event_queue, watch, timeout)
self.wm = pyinotify.WatchManager()
self.notifier = pyinotify.Notifier(self.wm, InotifyEventHandler(emitter=self))
self.wm.add_watch(watch.path, mask, rec=watch.is_recursive)
self.stopped = threading.Event()
self.path = watch.path
示例3: __init__
def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT,
stat=default_stat, listdir=os.listdir):
EventEmitter.__init__(self, event_queue, watch, timeout)
self._snapshot = None
self._lock = threading.Lock()
self._take_snapshot = lambda: DirectorySnapshot(
self.watch.path, self.watch.is_recursive, stat=stat, listdir=listdir)
示例4: queue_event
def queue_event(self, event):
EventEmitter.queue_event(self, event)
if event.event_type == EVENT_TYPE_CREATED:
self._register_kevent(event.src_path, event.is_directory)
elif event.event_type == EVENT_TYPE_MOVED:
self._unregister_kevent(event.src_path)
self._register_kevent(event.dest_path, event.is_directory)
elif event.event_type == EVENT_TYPE_DELETED:
self._unregister_kevent(event.src_path)
示例5: __init__
def __init__(self, event_queue, watch, timeout = DEFAULT_EMITTER_TIMEOUT):
EventEmitter.__init__(self, event_queue, watch, timeout)
self._kq = select.kqueue()
self._lock = threading.RLock()
self._descriptors = KeventDescriptorSet()
def walker_callback(path, stat_info, self = self):
self._register_kevent(path, stat.S_ISDIR(stat_info.st_mode))
self._snapshot = DirectorySnapshot(watch.path, watch.is_recursive, walker_callback)
示例6: queue_event
def queue_event(self, event):
"""
Handles queueing a single event object.
:param event:
An instance of :class:`watchdog.events.FileSystemEvent`
or a subclass.
"""
# Handles all the book keeping for queued events.
# We do not need to fire moved/deleted events for all subitems in
# a directory tree here, because this function is called by kqueue
# for all those events anyway.
EventEmitter.queue_event(self, event)
if event.event_type == EVENT_TYPE_CREATED:
self._register_kevent(event.src_path, event.is_directory)
elif event.event_type == EVENT_TYPE_MOVED:
self._unregister_kevent(event.src_path)
self._register_kevent(event.dest_path, event.is_directory)
elif event.event_type == EVENT_TYPE_DELETED:
self._unregister_kevent(event.src_path)
示例7: __init__
def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
EventEmitter.__init__(self, event_queue, watch, timeout)
self._lock = threading.Lock()
self._inotify = Inotify(watch.path, watch.is_recursive)
示例8: __init__
def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
EventEmitter.__init__(self, event_queue, watch, timeout)
self._snapshot = DirectorySnapshot(watch.path, watch.is_recursive)
self._lock = threading.Lock()
示例9: test___init__
def test___init__(self):
event_queue = EventQueue()
watch = ObservedWatch('/foobar', True)
event_emitter = EventEmitter(event_queue, watch, timeout=1)
event_emitter.queue_event(FileModifiedEvent('/foobar/blah'))
示例10: __init__
def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
EventEmitter.__init__(self, event_queue, watch, timeout)
self._lock = threading.Lock()
self._inotify = None
示例11: __init__
def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
EventEmitter.__init__(self, event_queue, watch, timeout)
self._fsevents = FSEventsQueue(watch.path)
self._fsevents.start()
示例12: __init__
def __init__(self, event_queue, watch, make_snapshot, timeout):
EventEmitter.__init__(self, event_queue, watch, timeout)
self._make_snapshot = make_snapshot
self._snapshot = make_snapshot(self.watch.path)
示例13: on_created
return
logging.debug(event)
def on_created(self, event):
logging.debug(event)
def on_deleted(self, event):
logging.debug(event)
def on_modified(self, event):
logging.debug(event)
#path = sys.argv[1]
qu = EventQueue()
ob_w = ObservedWatch(path,True)
em = EventEmitter(qu,ob_w,1)
em.start()
t = True
try:
while 1:
if qu.task_done():
time.sleep(3)
else:
logging.info("{0:s}".format(qu.get()))
except KeyboardInterrupt:
em.stop()
em.stop()
em.join()
示例14: __init__
def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
EventEmitter.__init__(self, event_queue, watch, timeout)
self._lock = threading.Lock()
self._handle = get_directory_handle(watch.path)
示例15: __init__
def __init__(self, event_queue, watch, timeout=1):
EventEmitter.__init__(self, event_queue, watch, timeout)
self._snapshot = None