Esempio n. 1
0
def start_watching(path=None):
    path = p('') if path is None else path
    global emitter
    emitter = Emitter(event_queue, ObservedWatch(path, recursive=True))
    if platform.is_darwin():
        # FSEvents will report old evens (like create for mkdtemp in test
        # setup. Waiting for a considerable time seems to 'flush' the events.
        time.sleep(10)
    emitter.start()
Esempio n. 2
0
def start_watching(path=None):
    path = p('') if path is None else path
    global emitter
    emitter = Emitter(event_queue, ObservedWatch(path, recursive=True))
    if platform.is_darwin():
        # FSEvents will report old evens (like create for mkdtemp in test
        # setup. Waiting for a considerable time seems to 'flush' the events.
        time.sleep(10)
    emitter.start()
Esempio n. 3
0
def test_passing_bytes_should_give_bytes(p):
    path = p('').encode()

    event_queue = Queue()
    emitter = Emitter(event_queue, ObservedWatch(path, recursive=True))
    emitter.start()
    touch(p('a'))
    event = event_queue.get(timeout=5)[0]
    assert isinstance(event.src_path, bytes)
Esempio n. 4
0
def _setup_emitter(path):
    event_queue = Queue()

    if platform.is_darwin():
        # FSEvents will report old evens (like create for mkdtemp in test
        # setup. Waiting for a considerable time seems to 'flush' the events.
        time.sleep(10)

    emitter = Emitter(event_queue, ObservedWatch(path, recursive=True))
    emitter.start()
    return event_queue, emitter
Esempio n. 5
0
def test_passing_bytes_should_give_bytes(p):
    from watchdog.utils.unicode_paths import bytes_cls
    path = bytes_cls(p(''), 'ascii')
    assert isinstance(p(''), bytes_cls)

    event_queue = Queue()
    emitter = Emitter(event_queue, ObservedWatch(path, recursive=True))
    emitter.start()
    touch(p('a'))
    event = event_queue.get(timeout=5)[0]
    assert isinstance(event.src_path, bytes_cls)
Esempio n. 6
0
def _setup_emitter(path):
    event_queue = Queue()

    if platform.is_darwin():
        # FSEvents will report old evens (like create for mkdtemp in test
        # setup. Waiting for a considerable time seems to 'flush' the events.
        time.sleep(10)

    emitter = Emitter(event_queue, ObservedWatch(path, recursive=True))
    emitter.start()
    return event_queue, emitter
Esempio n. 7
0
def test_passing_bytes_should_give_bytes(p):
    from watchdog.utils.unicode_paths import bytes_cls
    path = bytes_cls(p(''), 'ascii')
    assert isinstance(p(''), bytes_cls)

    event_queue = Queue()
    emitter = Emitter(event_queue, ObservedWatch(path, recursive=True))
    emitter.start()
    touch(p('a'))
    event = event_queue.get(timeout=5)[0]
    assert isinstance(event.src_path, bytes_cls)
Esempio n. 8
0
 def makeEmitter(self, path=None):
     """
     Return a new emitter monitoring `path`.
     """
     return InotifyEmitter(
         event_queue=self.emitter_queue,
         watch=self.ObservedWatch(path=path),
         timeout=0,
         )
Esempio n. 9
0
def test_close_clean(tmpdir):
    """
    On InotifyBuffer.close() InotifyBuffer.read_event() is un-blocked so that
    Inotify thread waiting for it can be closed.

    This is also a test for Inotify.queue_events handling of STOP_EVENT and
    InotifyBuffer.close() is test as side effect of Inotify.stop()
    """
    watch = ObservedWatch(path=tmpdir, recursive=False)
    emitter = InotifyEmitter([], watch)
    emitter.start()

    emitter.stop()
    emitter.join(1)
    assert not emitter.isAlive()
def test_close_clean(tmpdir):
    """
    On InotifyBuffer.close() InotifyBuffer.read_event() is un-blocked so that
    Inotify thread waiting for it can be closed.

    This is also a test for Inotify.queue_events handling of STOP_EVENT and
    InotifyBuffer.close() is test as side effect of Inotify.stop()
    """
    watch = ObservedWatch(path=tmpdir, recursive=False)
    emitter = InotifyEmitter([], watch)
    emitter.start()

    emitter.stop()
    emitter.join(1)
    assert not emitter.isAlive()