Python看门狗,移动文件会触发移动事件和修改事件

时间:2014-10-15 23:12:07

标签: python directory watchdog

这是我的FileHandler ..当我移动文件时,我得到一个移动事件和一个修改过的事件,但我只想要一个移动事件。我该如何处理?

class FileHandler(FileSystemEventHandler):

    def on_modified(self, event):  
        print "path: " + event.src_path
        print "type: " + event.event_type
        print "is dir: " + str(event.is_directory)
        print "\n"

    def on_created(self, event):
        print "path: " + event.src_path
        print "type: " + event.event_type
        print "is dir: " + str(event.is_directory)
        print "\n"

    def on_deleted(self, event):
        print "path: " + event.src_path
        print "type: " + event.event_type
        print "is dir: " + str(event.is_directory)
        print "\n"

    def on_moved(self, event):
        print "path: " + event.src_path
        print "type: " + event.event_type
        print "is dir: " + str(event.is_directory)
        print "dest_path: " + event.dest_path
        print "\n"

1 个答案:

答案 0 :(得分:0)

你一次只能有一个事件,你必须玩 SOU 目录/文件和 DESTINATION