2
我正在研究一個簡單的看門狗腳本,該腳本會在上傳到我們的FTP的一些非常大的圖像上運行md5sum。看門狗似乎沒有在pyinotify中存在的IN_CLOSE_WRITE事件。我試着檢查該文件是否仍然作爲解決方法打開,但這不起作用。有沒有人知道從看門狗獲取close_write事件的解決方法?來自python看門狗的In_close_write事件
import sys
import time
from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer
path = sys.argv[1]
class MyEventHandler(FileSystemEventHandler):
def on_modified(self, event):
print "File uploaded"
# Is file still uploading?
f = open(event.src_path)
if f.closed:
print "....run md5 & email admin"
event_handler = MyEventHandler()
observer = Observer()
observer.schedule(event_handler, path, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()