• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python polling.PollingObserver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: watch

 def watch(self):
     observer = PollingObserver(0.1)
     observer.schedule(self, self.path)
     observer.start()
     self.file = open(self.path + "\Power.log", "r")
     self.on_modified(None)
     self.watching = True
开发者ID:ykcycer,项目名称:Nagibator,代码行数:7,代码来源:parser.py


示例2: watch

def watch(directory=None, auto_clear=False, beep_on_failure=True,
          onpass=None, onfail=None, poll=False, extensions=[]):
    """
    Starts a server to render the specified file or directory
    containing a README.
    """
    if directory and not os.path.isdir(directory):
        raise ValueError('Directory not found: ' + directory)
    directory = os.path.abspath(directory or '')

    # Initial run
    event_handler = ChangeHandler(directory, auto_clear, beep_on_failure,
                                  onpass, onfail, extensions)
    event_handler.run()

    # Setup watchdog
    if poll:
        observer = PollingObserver()
    else:
        observer = Observer()

    observer.schedule(event_handler, path=directory, recursive=True)
    observer.start()

    # Watch and run tests until interrupted by user
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
开发者ID:aldanor,项目名称:pytest-watch,代码行数:31,代码来源:watcher.py


示例3: get_contracts_code_observer

def get_contracts_code_observer(project_dir):
    observer = PollingObserver()

    build_path = utils.get_build_dir(project_dir)
    event_handler = ContractCodeChangedEventHandler(project_dir=project_dir)
    observer.schedule(event_handler, build_path, recursive=False)

    return observer
开发者ID:arhik,项目名称:populus,代码行数:8,代码来源:observers.py


示例4: watch_server

def watch_server(root_dir):
    # create event handler
    event_handler = OneDirServerEventHandler()
    # create observer
    observer = PollingObserver()

    # observe the given directory recursively
    observer.schedule(event_handler, path=root_dir, recursive=True)
    return observer
开发者ID:pvraj,项目名称:OneDir,代码行数:9,代码来源:FileWatch.py


示例5: get_active_dir_observer

def get_active_dir_observer(project_dir, event_handler):
    """ Setup a polling observer on the project's
        blockchains directory. This directory contains the
        .active-chain symlink which is watched for.
    """
    bchain = get_blockchains_dir(project_dir)
    observer = PollingObserver()
    observer.schedule(event_handler, bchain, recursive=False)
    return observer
开发者ID:arhik,项目名称:populus,代码行数:9,代码来源:observers.py


示例6: __init__

class Watcher:
    def __init__(self):
#       self.observer = Observer()            # Use this if SS_DIR is local
        self.observer = PollingObserver()     # Use this if SS_DIR is remote mount

    def run(self):
        event_handler = file_changed()
        self.observer.schedule(event_handler, SS_DIR, recursive=True)
        self.observer.start()
        loop1()
开发者ID:brucewinter,项目名称:myhouse,代码行数:10,代码来源:ss_monitor.py


示例7: __init__

    def __init__(self, basedir='.', polling=False):
        """Initialize the Monitor."""
        if not polling:
            self.observer = Observer()
        else:
            self.observer = PollingObserver()

        self.handlers = []
        self.basedir = basedir
        self.running = False
开发者ID:CorverDevelopment,项目名称:Pandora,代码行数:10,代码来源:monitor.py


示例8: watch_record

def watch_record(indexer, use_polling=False):
    """
    Start watching `cfstore.record_path`.

    :type indexer: rash.indexer.Indexer

    """
    if use_polling:
        from watchdog.observers.polling import PollingObserver as Observer

        Observer  # fool pyflakes
    else:
        from watchdog.observers import Observer

    event_handler = RecordHandler(indexer)
    observer = Observer()
    observer.schedule(event_handler, path=indexer.record_path, recursive=True)
    indexer.logger.debug("Start observer.")
    observer.start()
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        indexer.logger.debug("Got KeyboardInterrupt. Stopping observer.")
        observer.stop()
    indexer.logger.debug("Joining observer.")
    observer.join()
    indexer.logger.debug("Finish watching record.")
开发者ID:tenken,项目名称:rash,代码行数:28,代码来源:watchrecord.py


示例9: watch

    def watch(self):
        """
        Start watching
        """
        logger.info('Watching directory %s' % self.directory)

        # Set up handler for when we see new files
        callback = self.callback
        class NewFileEventHandler(FileSystemEventHandler):
            def on_created(self, event):
                if not event.is_directory:
                    logger.info('Detected new file: %s' % event.src_path)
                    callback(event.src_path)
        event_handler = NewFileEventHandler()

        # Use polling observer (rather than filesystem-specific observers),
        # because it is more reliable.
        observer = PollingObserver(timeout=self.sleep_time)

        # Start the observer
        observer.schedule(event_handler, self.directory, recursive=False)
        observer.start()

        # Wait while the observer is running
        try:
            while True:
                sleep(self.sleep_time)
        # Exit gracefully
        except KeyboardInterrupt:
            logger.info('Detected interrupt. Stopping observer.')
            observer.stop()
        observer.join()
开发者ID:nmalkin,项目名称:s3-autouploader,代码行数:32,代码来源:watch.py


示例10: SuiteTable

class SuiteTable(object):
    def __init__(self, dbfile=":memory:", poll=False):
        self.db = sqlite3.connect(dbfile, check_same_thread=False)
        self.log = logging.getLogger(__name__)
        self._create_db()

        # set up watchdog observer to monitor changes to
        # keyword files (or more correctly, to directories
        # of keyword files)
        self.observer =  PollingObserver() if poll else Observer()
        self.observer.start()

    def _create_db(self):

        if not self._table_exists("collection_table"):
            self.db.execute("""
                CREATE TABLE collection_table
                (collection_id INTEGER PRIMARY KEY AUTOINCREMENT,
                 name          TEXT COLLATE NOCASE,
                 type          COLLATE NOCASE,
                 version       TEXT,
                 scope         TEXT,
                 namedargs     TEXT,
                 path          TEXT,
                 doc           TEXT,
                 doc_format    TEXT)
            """)
            self.db.execute("""
                CREATE INDEX collection_index
                ON collection_table (name)
            """)

        if not self._table_exists("keyword_table"):
            self.db.execute("""
                CREATE TABLE keyword_table
                (keyword_id    INTEGER PRIMARY KEY AUTOINCREMENT,
                 name          TEXT COLLATE NOCASE,
                 collection_id INTEGER,
                 doc           TEXT,
                 args          TEXT)
            """)
            self.db.execute("""
                CREATE INDEX keyword_index
                ON keyword_table (name)
            """)

    def _table_exists(self, name):
        cursor = self.db.execute("""
            SELECT name FROM sqlite_master
            WHERE type='table' AND name='%s'
        """ % name)
        return len(cursor.fetchall()) > 0
开发者ID:stefanzweig,项目名称:rfbench,代码行数:52,代码来源:zweigdb.py


示例11: get_static_assets_observer

def get_static_assets_observer(project_dir):
    build_path = utils.get_build_dir(project_dir)

    observer = PollingObserver()

    contracts_js_event_handler = ContractsJSChangedEventHandler(project_dir=project_dir)
    observer.schedule(contracts_js_event_handler, build_path, recursive=False)

    if project_has_assets(project_dir):
        assets_watch_path = get_static_assets_dir(project_dir)
        assets_event_handler = AssetsChangedEventHandler(project_dir=project_dir)
        observer.schedule(assets_event_handler, assets_watch_path, recursive=True)

    return observer
开发者ID:arhik,项目名称:populus,代码行数:14,代码来源:observers.py


示例12: get_contracts_observer

def get_contracts_observer(project_dir, contract_filters=None, compiler_kwargs=None):
    if contract_filters is None:
        contract_filters = []
    if compiler_kwargs is None:
        compiler_kwargs = {}
    contracts_dir = utils.get_contracts_dir(project_dir)
    libraries_dir = get_project_libraries_dir(project_dir)

    event_handler = ContractSourceChangedEventHandler(
        project_dir=project_dir, contract_filters=contract_filters, compiler_kwargs=compiler_kwargs
    )
    observer = PollingObserver()
    observer.schedule(event_handler, contracts_dir, recursive=True)
    observer.schedule(event_handler, libraries_dir, recursive=True)
    return observer
开发者ID:atomicjets,项目名称:populus,代码行数:15,代码来源:observers.py


示例13: watch

    def watch(self):
        observer = PollingObserver()
        observer.schedule(self.pickup_event_processor, path=self.pickup_dir)
        observer.start()
        
        try:
            while self.keep_running:
                sleep(3)
        except KeyboardInterrupt:
            observer.stop()

        observer.join()
开发者ID:barowski,项目名称:zato,代码行数:12,代码来源:generic.py


示例14: main

def main():
    """Script entry point."""
    from watchdog.observers.polling import PollingObserver
    from .parser import AAConfigParser
    from .tricks import AutoRunTrick

    parser = _create_main_argparser()
    args = parser.parse_args()
    configm = _apply_main_args(args)

    # The reason to use PollingObserver() is it's os-independent. And it's
    # more reliable.
    observer = PollingObserver()

    parser = AAConfigParser(configm)
    handler_for_watch = parser.schedule_with(observer, AutoRunTrick)
    handlers = set.union(*tuple(handler_for_watch.values()))

    for handler in handlers:
        handler.start()
    observer.start()
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
    for handler in handlers:
        handler.stop()
开发者ID:StephenHesperus,项目名称:arfarf,代码行数:29,代码来源:arf.py


示例15: watch_assets

def watch_assets(options):
    """
    Watch for changes to asset files, and regenerate js/css
    """
    # Don't watch assets when performing a dry run
    if tasks.environment.dry_run:
        return

    observer = PollingObserver()

    CoffeeScriptWatcher().register(observer)
    SassWatcher().register(observer)
    XModuleSassWatcher().register(observer)
    XModuleAssetsWatcher().register(observer)

    print("Starting asset watcher...")
    observer.start()
    if not getattr(options, 'background', False):
        # when running as a separate process, the main thread needs to loop
        # in order to allow for shutdown by contrl-c
        try:
            while True:
                observer.join(2)
        except KeyboardInterrupt:
            observer.stop()
        print("\nStopped asset watcher.")
开发者ID:10clouds,项目名称:edx-platform,代码行数:26,代码来源:assets.py


示例16: __init__

    def __init__(self, dbfile=":memory:", poll=False):
        self.db = sqlite3.connect(dbfile, check_same_thread=False)
        self.log = logging.getLogger(__name__)
        self._create_db()

        # set up watchdog observer to monitor changes to
        # keyword files (or more correctly, to directories
        # of keyword files)
        self.observer =  PollingObserver() if poll else Observer()
        self.observer.start()
开发者ID:stefanzweig,项目名称:rfbench,代码行数:10,代码来源:zweigdb.py


示例17: folderObserver

def folderObserver(pathStructure, dbPath):

    logging = DefaultLogger()

    if pathStructure == None or pathStructure['inBox'] == None:
        message = 'Watch: Unable to run as pathStructure is undefined'
        logging.debug(message)
        return
    
    event_handler = singleFileWatcher(pathStructure, dbPath)
    observer = PollingObserver()
    observer.schedule(event_handler, pathStructure['inBox'], recursive=False)
    observer.start()

    try:
        while True and observer.is_alive():
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
开发者ID:patrickcusack,项目名称:BWF,代码行数:20,代码来源:watchprocess.py


示例18: main

def main():
    handler = ChangeHandler()
    directory = "./"
    observer = PollingObserver(0.35)
    # Poll every 0.35 seconds
    if not os.path.exists(directory):
        os.makedirs(directory)
    observer.schedule(handler, directory, recursive=True)
    # Only search in the LaTeX directory
    observer.start()
    try:
        while True:
            time.sleep(60 * 5)
            # Sleep for 5 minutes (time doesn't really matter)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
开发者ID:stevenengler,项目名称:Real-Time-LaTeX-With-Vagrant,代码行数:17,代码来源:compile_latex.py


示例19: watch

def watch():
    # Users expect an implicit push
    push(watch=True)

    # Start the observer
    observer = PollingObserver()
    observer.event_queue.max_size = 1
    observer.schedule(EventHandler(), os.getcwd(), recursive=True)
    observer.start()
    puts(colored.yellow('Watching for changes... (ctrl-c to stop)'))
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    # Block until the thread terminates
    observer.join()
开发者ID:getsiphon,项目名称:siphon-cli,代码行数:17,代码来源:push.py


示例20: run_watch

    def run_watch(self):
        if self.poll:
            from watchdog.observers.polling import PollingObserver as Observer
        else:
            from watchdog.observers import Observer

        event_handler = RoninEventHandler(self)
        observer = Observer()
        observer.schedule(event_handler, self.source, recursive=True)
        observer.start()

        try:
            logger.info("Watching directory: '{0}' for changes (poll={1})".format(self.source, self.poll))
            while True:
                time.sleep(1)
        except KeyboardInterrupt:
            logger.info("Stopping watcher...")
            observer.stop()
        observer.join()
开发者ID:swquinn,项目名称:ronin,代码行数:19,代码来源:__init__.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.has_attribute函数代码示例发布时间:2022-05-26
下一篇:
Python api.EventEmitter类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap