下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
#!/usr/bin/env python
#coding=utf-8
import os
from pyinotify import WatchManager,Notifier,ProcessEvent,IN_DELETE,IN_CREATE,IN_MODIFY
wm = WatchManager()
mask = IN_DELETE | IN_CREATE |IN_MODIFY # watched events
class PFilePath(ProcessEvent):
def process_IN_CREATE(self,event):
print "Create file: %s " % os.path.join(event.path,event.name)
def process_IN_DELETE(self,event):
print "Delete file: %s " % os.path.join(event.path,event.name)
def process_IN_MODIFY(self,event):
print "Modify file: %s " % os.path.join(event.path,event.name)
if __name__ == "__main__":
notifier = Notifier(wm,PFilePath())
wdd = wm.add_watch('.',mask,rec=True)
while True:
try :
notifier.process_events()
if notifier.check_events():
notifier.read_events()
except KeyboardInterrupt:
notifier.stop()
break
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
总结
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。