Created
March 14, 2011 23:17
-
-
Save seungjin/870060 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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