0
我在我的家目录(/ home/name)下使用pyinotify放置脚本并运行它。虽然我无法使脚本看我的家目录(/ home/name)或包含我的主目录的目录,例如root(/)和/ home /。所有其他目录都可以,例如/ var,/ boot,/ home/name/Documents。pyinotify无法观看当前目录
让我描述它在一个干净的方式:
dirs that are NOT OK:
/
/home
/home/name (script is here)
All other dirs are OK, e.g.
/bin
/var
/home/name/Documents
脚本:
import pyinotify
class MyEventHandler(pyinotify.ProcessEvent):
def process_IN_ACCESS(self, event):
print "ACCESS event:", event.pathname
def process_IN_ATTRIB(self, event):
print "ATTRIB event:", event.pathname
def process_IN_CLOSE_NOWRITE(self, event):
print "CLOSE_NOWRITE event:", event.pathname
def process_IN_CLOSE_WRITE(self, event):
print "CLOSE_WRITE event:", event.pathname
def process_IN_CREATE(self, event):
print "CREATE event:", event.pathname
def process_IN_DELETE(self, event):
print "DELETE event:", event.pathname
def process_IN_MODIFY(self, event):
print "MODIFY event:", event.pathname
def process_IN_OPEN(self, event):
print "OPEN event:", event.pathname
def main():
# watch manager
wm = pyinotify.WatchManager()
wm.add_watch('/var/log', pyinotify.ALL_EVENTS, rec=True)
# event handler
eh = MyEventHandler()
# notifier
notifier = pyinotify.Notifier(wm, eh)
notifier.loop()
if __name__ == '__main__':
main()
你得到了什么错误(例如“Errno = Permission denied(EACCES)”)?什么是目录权限? – Demyn
没有输出,这是我的家庭目录。我拥有所有权限。我粘贴上面的脚本。 –
您需要将手表添加到家中。 –