Guest User

Untitled

a guest
Jul 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. # usage: python mirrordir.py ./directory myuser@host:/path
  2. import sys, pyinotify, subprocess
  3.  
  4. class Handler(pyinotify.ProcessEvent):
  5. def process_IN_CLOSE_WRITE(self, event):
  6. subprocess.call(("scp", event.pathname, sys.argv[2]))
  7.  
  8. if __name__ == '__main__':
  9. wm = pyinotify.WatchManager()
  10. notifier = pyinotify.Notifier(wm, default_proc_fun=Handler())
  11. wm.add_watch(sys.argv[1], pyinotify.IN_CLOSE_WRITE, rec=True, auto_add=True)
  12. notifier.loop()
Add Comment
Please, Sign In to add comment