|
@@ -83,7 +83,11 @@ def handle_old_vpn_files(directory, old_tstamp):
|
|
|
|
|
|
class VPNAcctHandler(pyinotify.ProcessEvent):
|
|
|
|
|
|
+ def process_IN_MOVED_TO(self, event):
|
|
|
+ self.handle_file(event)
|
|
|
def process_IN_CLOSE_WRITE(self, event):
|
|
|
+ self.handle_file(event)
|
|
|
+ def handle_file(self, event):
|
|
|
logging("Event detected for file %s..." % (event.pathname, ), syslog.LOG_DEBUG)
|
|
|
|
|
|
if last_timestamp > 0:
|
|
@@ -144,7 +148,7 @@ if __name__ == '__main__':
|
|
|
wm = pyinotify.WatchManager()
|
|
|
handler = VPNAcctHandler()
|
|
|
notifier = pyinotify.Notifier(wm, handler)
|
|
|
- wm.add_watch(options.directory, pyinotify.IN_CLOSE_WRITE)
|
|
|
+ wm.add_watch(options.directory, pyinotify.IN_CLOSE_WRITE|pyinotify.IN_MOVED_TO)
|
|
|
|
|
|
try:
|
|
|
notifier.loop(daemonize=True, callback=on_loop, pid_file='/var/run/pyinotify.pid', stdout='/var/log/pyinotify.log')
|