watch.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:qface 作者: Pelagicore 项目源码 文件源码
def monitor(script, src, dst):
    """
    reloads the script given by argv when src files changes
    """
    src = src if isinstance(src, (list, tuple)) else [src]
    dst = Path(dst).expand().abspath()
    src = [Path(entry).expand().abspath() for entry in src]
    script = Path(script).expand().abspath()
    command = '{0} {1} {2}'.format(script, ' '.join(src), dst)
    event_handler = RunScriptChangeHandler(command)
    observer = Observer()
    click.secho('watch recursive: {0}'.format(script.dirname()), fg='blue')
    observer.schedule(event_handler, script.dirname(), recursive=True)
    for entry in src:
        click.secho('watch recursive: {0}'.format(entry), fg='blue')
        observer.schedule(event_handler, entry, recursive=True)
    event_handler.run()  # run always once
    observer.start()

    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号