Created
May 4, 2017 10:02
-
-
Save FredrikWendt/7045cdd20d6ec5bafe049250b6a000a2 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
#!/usr/bin/env python | |
# | |
# Watches the dropfolder, and kicks off the dropfolder-scanner when a file is closed | |
# | |
import pyinotify, os, logging | |
logging.basicConfig(filename='/tmp/dropfolder.log') | |
logger = logging.getLogger('watcher') | |
logger.setLevel(logging.INFO) | |
class EventHandler(pyinotify.ProcessEvent): | |
def process_IN_CLOSE_WRITE(self, event): | |
logger.info("close: %s", event.pathname) | |
os.system("do magic stuff %s" % event.pathname) | |
wm = pyinotify.WatchManager() | |
mask = pyinotify.IN_CLOSE_WRITE | |
handler = EventHandler() | |
notifier = pyinotify.Notifier(wm, handler) | |
wdd = wm.add_watch('/dump/samba/dropfolder', mask) | |
notifier.loop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment