and put most of the configuration information in the script
(i really should load it from a config file at some point)
Also teach setup.py about said script
--- /dev/null
+#!/usr/bin/env python
+
+from uashelper.spoolwatcher import TreeWriteDoneNotifier
+
+if __name__ == "__main__":
+ copy_jid = "cellthumper@chaos.caltech.edu"
+ runner_jid = "diane@ghic.org"
+
+ watcher = TreeWriteDoneNotifier("/gec/jumpgate/ext0", copy_jid, runner_jid)
+ watcher.event_loop()
description="some bots and other utilities to help deal with data from an illumina sequencer",
author="Diane Trout",
author_email="diane@caltech.edu",
description="some bots and other utilities to help deal with data from an illumina sequencer",
author="Diane Trout",
author_email="diane@caltech.edu",
- packages="uashelper",
- scripts=[],
+ packages=["uashelper"],
+ scripts=['scripts/spoolwatcher'],
from benderjab.xsend import send
from benderjab.xsend import send
-copy_jid = "cellthumper@chaos.caltech.edu"
-runner_jid = "diane@ghic.org"
-copy_jid = runner_jid
class Handler(pyinotify.ProcessEvent):
class Handler(pyinotify.ProcessEvent):
- def __init__(self, watchmanager):
+ def __init__(self, watchmanager, runner_jid):
self.last_event_time = None
self.watchmanager = watchmanager
self.last_event_time = None
self.watchmanager = watchmanager
+ self.runner_jid = runner_jid
def process_IN_CREATE(self, event):
self.last_event_time = time.time()
msg = "Create: %s" % os.path.join(event.path, event.name)
def process_IN_CREATE(self, event):
self.last_event_time = time.time()
msg = "Create: %s" % os.path.join(event.path, event.name)
- if event.name == "Run.completed":
+ if event.name.lower() == "run.completed":
- send(runner_jid, "a run finished, launch it, and swap the drive")
+ send(self.runner_jid, "a run finished, launch it, and swap the drive")
print msg
def process_IN_DELETE(self, event):
print msg
def process_IN_DELETE(self, event):
this'll hopefully send out a message saying hey look theres data available
"""
this'll hopefully send out a message saying hey look theres data available
"""
- def __init__(self, watchdir, write_timeout=10, notify_timeout=5):
- self.watchdirs = []
+ def __init__(self, watchdir,
+ copy_jid, runner_jid,
+ write_timeout=10, notify_timeout=5):
+ self.watchdir = watchdir
+ self.copy_jid = copy_jid
+ self.runner_jid = runner_jid
self.write_timeout = write_timeout
self.notify_timeout = int(notify_timeout * 1000)
self.wm = pyinotify.WatchManager()
self.write_timeout = write_timeout
self.notify_timeout = int(notify_timeout * 1000)
self.wm = pyinotify.WatchManager()
- self.handler = Handler(self.wm)
+ self.handler = Handler(self.wm, self.runner_jid)
self.notifier = pyinotify.Notifier(self.wm, self.handler)
self.notifier = pyinotify.Notifier(self.wm, self.handler)
- self.add_watch(watchdir)
+ self.add_watch(self.watchdir)
def add_watch(self, watchdir):
def add_watch(self, watchdir):
- self.watchdirs.append(watchdir)
print "Watching:", watchdir
mask = EventsCodes.IN_CREATE | EventsCodes.IN_UNMOUNT
# rec traverses the tree and adds all the directories that are there
print "Watching:", watchdir
mask = EventsCodes.IN_CREATE | EventsCodes.IN_UNMOUNT
# rec traverses the tree and adds all the directories that are there
def copying_paused(self):
print "more than 10 seconds have elapsed"
def copying_paused(self):
print "more than 10 seconds have elapsed"
- send(copy_jid, "start copy")
-
-
-if __name__ == "__main__":
- #watcher = TreeWriteDoneNotifier("/tmp")
- watcher = TreeWriteDoneNotifier("/gec/jumpgate/ext0")
- watcher.event_loop()
+ send(self.copy_jid, "start copy")