当前位置: 首页>>代码示例>>Python>>正文


Python api.BaseObserver类代码示例

本文整理汇总了Python中watchdog.observers.api.BaseObserver的典型用法代码示例。如果您正苦于以下问题:Python BaseObserver类的具体用法?Python BaseObserver怎么用?Python BaseObserver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BaseObserver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: schedule

 def schedule(self, event_handler, path, recursive=False):
     # Fix for issue #26: Trace/BPT error when given a unicode path
     # string. https://github.com/gorakhargosh/watchdog/issues#issue/26
     if isinstance(path, unicode):
         #path = unicode(path, 'utf-8')
         path = unicodedata.normalize('NFC', path).encode('utf-8')
     BaseObserver.schedule(self, event_handler, path, recursive)
开发者ID:aswadrangnekar,项目名称:watchdog,代码行数:7,代码来源:fsevents.py

示例2: observer2

def observer2():
    obs = BaseObserver(EventEmitter)
    yield obs
    obs.stop()
    try:
        obs.join()
    except RuntimeError:
        pass
开发者ID:gorakhargosh,项目名称:watchdog,代码行数:8,代码来源:test_observer.py

示例3: __init__

 def __init__(self, stat, listdir, polling_interval=1):
     """
     :param stat: stat function. See ``os.stat`` for details.
     :param listdir: listdir function. See ``os.listdir`` for details.
     :type polling_interval: float
     :param polling_interval: interval in seconds between polling the file system.
     """
     emitter_cls = partial(PollingEmitter, stat=stat, listdir=listdir)
     BaseObserver.__init__(self, emitter_class=emitter_cls, timeout=polling_interval)
开发者ID:skcript,项目名称:watchdog,代码行数:9,代码来源:polling.py

示例4: schedule

    def schedule(self, event_handler, path, recursive = False):
        try:
            str_class = unicode
        except NameError:
            str_class = str

        if isinstance(path, str_class):
            path = unicodedata.normalize('NFC', path)
            if sys.version_info < (3,):
                path = path.encode('utf-8')
        return BaseObserver.schedule(self, event_handler, path, recursive)
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:11,代码来源:fsevents.py

示例5: schedule

    def schedule(self, event_handler, path, recursive=False):
        # Python 2/3 compat
        try:
            str_class = unicode
        except NameError:
            str_class = str

        # Fix for issue #26: Trace/BPT error when given a unicode path
        # string. https://github.com/gorakhargosh/watchdog/issues#issue/26
        if isinstance(path, str_class):
            #path = unicode(path, 'utf-8')
            path = unicodedata.normalize('NFC', path).encode('utf-8')
        return BaseObserver.schedule(self, event_handler, path, recursive)
开发者ID:ubick,项目名称:watchdog,代码行数:13,代码来源:fsevents.py

示例6: schedule

    def schedule(self, event_handler, path, recursive=False):
        # Python 2/3 compat
        try:
            str_class = unicode
        except NameError:
            str_class = str

        # Fix for issue #26: Trace/BPT error when given a unicode path
        # string. https://github.com/gorakhargosh/watchdog/issues#issue/26
        if isinstance(path, str_class):
            #path = unicode(path, 'utf-8')
            path = unicodedata.normalize('NFC', path)
            # We only encode the path in Python 2 for backwards compatibility.
            # On Python 3 we want the path to stay as unicode if possible for
            # the sake of path matching not having to be rewritten to use the
            # bytes API instead of strings. The _watchdog_fsevent.so code for
            # Python 3 can handle both str and bytes paths, which is why we
            # do not HAVE to encode it with Python 3. The Python 2 code in
            # _watchdog_fsevents.so was not changed for the sake of backwards
            # compatibility.
            if sys.version_info < (3,):
                path = path.encode('utf-8')
        return BaseObserver.schedule(self, event_handler, path, recursive)
开发者ID:GuoJing,项目名称:watchdog,代码行数:23,代码来源:fsevents.py

示例7: __init__

 def __init__(self, timeout=DEFAULT_OBSERVER_TIMEOUT):
   BaseObserver.__init__(self, emitter_class=InotifyEmitter,
                         timeout=timeout)
开发者ID:edevil,项目名称:watchdog,代码行数:3,代码来源:inotify.py

示例8: test_basic

  def test_basic(self):
    observer = BaseObserver(EventEmitter)
    handler = LoggingEventHandler()

    watch = observer.schedule(handler, '/foobar', True)
    observer.add_handler_for_watch(handler, watch)
    observer.add_handler_for_watch(handler, watch)
    observer.remove_handler_for_watch(handler, watch)
    self.assertRaises(KeyError,
                      observer.remove_handler_for_watch, handler, watch)
    observer.unschedule(watch)
    self.assertRaises(KeyError, observer.unschedule, watch)

    watch = observer.schedule(handler, '/foobar', True)
    observer.event_queue.put((FileModifiedEvent('/foobar'), watch))
    observer.start()
    time.sleep(1)
    observer.unschedule_all()
    observer.stop()
开发者ID:edevil,项目名称:watchdog,代码行数:19,代码来源:test_watchdog_observers_api.py

示例9: __init__

 def __init__(self, timeout=DEFAULT_OBSERVER_TIMEOUT):
     BaseObserver.__init__(self, emitter_class=PollingEmitterWithState, timeout=timeout)
开发者ID:AltarBeastiful,项目名称:rateItSeven,代码行数:2,代码来源:polling_observer_with_state.py

示例10: __init__

 def __init__(self, timeout=DEFAULT_OBSERVER_TIMEOUT):
     BaseObserver.__init__(self, emitter_class=WindowsApiAsyncEmitter,
                           timeout=timeout)
开发者ID:aswadrangnekar,项目名称:watchdog,代码行数:3,代码来源:read_directory_changes_async.py

示例11: __init__

 def __init__(self, make_snapshot, polling_interval=1):
   constructor = partial(Poller, make_snapshot=make_snapshot)
   BaseObserver.__init__(self, constructor, polling_interval)
开发者ID:Thilas,项目名称:xbmc-addon-watchdog,代码行数:3,代码来源:polling.py

示例12: __init__

 def __init__(self, timeout=DEFAULT_OBSERVER_TIMEOUT, generate_full_events=False):
     if (generate_full_events):
         BaseObserver.__init__(self, emitter_class=InotifyFullEmitter, timeout=timeout)
     else:
         BaseObserver.__init__(self, emitter_class=InotifyEmitter,
                           timeout=timeout)
开发者ID:BetaMatrix,项目名称:watchdog,代码行数:6,代码来源:inotify.py

示例13: __init__

 def __init__(self):
     BaseObserver.__init__(self, None)
开发者ID:lidormalicb,项目名称:xbmc-addon-watchdog,代码行数:2,代码来源:emitters.py

示例14: __init__

 def __init__(self, timeout=DEFAULT_OBSERVER_TIMEOUT):
     BaseObserver.__init__(self, emitter_class=MistWatchdogPollingEmitter, timeout=timeout)
开发者ID:potay,项目名称:mist,代码行数:2,代码来源:mist_watchdog.py

示例15: __init__

 def __init__(self, stat, listdir, polling_interval=1):
    
     emitter_cls = partial(PollingEmitter, stat=stat, listdir=listdir)
     BaseObserver.__init__(self, emitter_class=emitter_cls, timeout=polling_interval)
开发者ID:vjs3,项目名称:Fast-file-transfer,代码行数:4,代码来源:polling.py


注:本文中的watchdog.observers.api.BaseObserver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。