Skip to content

Instantly share code, notes, and snippets.

@seungjin
Created March 14, 2011 23:17
Show Gist options
  • Save seungjin/870060 to your computer and use it in GitHub Desktop.
Save seungjin/870060 to your computer and use it in GitHub Desktop.
import sys
import os
import asyncore
import pyinotify
class EventHandler(pyinotify.ProcessEvent):
def process_IN_CREATE(self, event):
#print "Creating:", event.pathname
#I will use boto to connect amazon / euca2ool or irod??
os.system('scp "%s" "%s:%s"' % (event.pathname, 'seungjin@localhost', '/home/seungjin/mydropbox') )
def process_IN_DELETE(self, event):
#print "Removing:" , event.pathname
pass
def main():
path = sys.argv[1]
wm = pyinotify.WatchManager()
mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE
notifier = pyinotify.AsyncNotifier(wm, EventHandler())
wdd = wm.add_watch(path,mask,rec=True)
asyncore.loop()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment