python看门狗观察者没有在ubuntu上工作16.04

时间:2017-03-30 11:32:15

标签: python-watchdog

我这个脚本不适用于有Ubuntu 16.04

的流浪汉

此代码在mac上工作正常

 import sys
 import time
 import logging
 from watchdog.observers import Observer
 from watchdog.events import LoggingEventHandler

 if __name__ == "__main__":
 logging.basicConfig(level=logging.INFO,
                  format='%(asctime)s - %(message)s',
                  datefmt='%Y-%m-%d %H:%M:%S')
  path = sys.argv[1] if len(sys.argv) > 1 else '.'
  event_handler = LoggingEventHandler()
  observer = Observer()
  observer.schedule(event_handler, path, recursive=True)
  observer.start()
  try:
      while True:
        time.sleep(1)
  except KeyboardInterrupt:
      observer.stop()
      observer.join()

1 个答案:

答案 0 :(得分:0)

它的解决,看门狗事件没有解雇,因为我从流浪者之外添加了新文件:)