by walking the directory instead of just watching via pyinotify.
mostly this was move where the report formatting code was stored to
someplace a little more shared, and by moving the thread that watches
the directory tree.
from benderjab import rpc
from gaworkflow.pipeline.configure_run import *
-from gaworkflow.pipeline.monitors import _percentCompleted
#s_fc = re.compile('FC[0-9]+')
s_fc = re.compile('_[0-9a-zA-Z]*$')
return "No status information for %s yet." \
" Probably still in configure step. Try again later." % (fc_num)
- fc,ft = status.statusFirecrest()
- bc,bt = status.statusBustard()
- gc,gt = status.statusGerald()
-
- tc,tt = status.statusTotal()
-
- fp = _percentCompleted(fc, ft)
- bp = _percentCompleted(bc, bt)
- gp = _percentCompleted(gc, gt)
- tp = _percentCompleted(tc, tt)
-
- output = []
-
- output.append(u'Firecrest: %s%% (%s/%s)' % (fp, fc, ft))
- output.append(u' Bustard: %s%% (%s/%s)' % (bp, bc, bt))
- output.append(u' Gerald: %s%% (%s/%s)' % (gp, gc, gt))
- output.append(u'-----------------------')
- output.append(u' Total: %s%% (%s/%s)' % (tp, tc, tt))
+ output = status.statusReport()
return '\n'.join(output)
+++ /dev/null
-import time
-import threading
-
-######################
-# Utility functions
-def _percentCompleted(completed, total):
- """
- Returns precent completed as float
- """
- return (completed / float(total)) * 100
-
-
-##################################################
-# Functions to be called by Thread(target=<func>)
-def _cmdLineStatusMonitorFunc(conf_info):
- """
- Given a ConfigInfo object, provides status to stdout.
-
- You should probably use startCmdLineStatusMonitor()
- instead of ths function.
-
- Use with:
- t = threading.Thread(target=_cmdLineStatusMonitorFunc,
- args=[conf_info])
- t.setDaemon(True)
- t.start()
- """
- SLEEP_AMOUNT = 30
-
- while 1:
- if conf_info.status is None:
- print "No status object yet."
- time.sleep(SLEEP_AMOUNT)
- continue
-
- fc, ft = conf_info.status.statusFirecrest()
- bc, bt = conf_info.status.statusBustard()
- gc, gt = conf_info.status.statusGerald()
- tc, tt = conf_info.status.statusTotal()
-
- fp = _percentCompleted(fc, ft)
- bp = _percentCompleted(bc, bt)
- gp = _percentCompleted(gc, gt)
- tp = _percentCompleted(tc, tt)
-
- print 'Firecrest: %s%% (%s/%s)' % (fp, fc, ft)
- print ' Bustard: %s%% (%s/%s)' % (bp, bc, bt)
- print ' Gerald: %s%% (%s/%s)' % (gp, gc, gt)
- print '-----------------------'
- print ' Total: %s%% (%s/%s)' % (tp, tc, tt)
- print ''
-
- time.sleep(SLEEP_AMOUNT)
-
-
-#############################################
-# Start monitor thread convenience functions
-def startCmdLineStatusMonitor(conf_info):
- """
- Starts a command line status monitor given a conf_info object.
- """
- t = threading.Thread(target=_cmdLineStatusMonitorFunc, args=[conf_info])
- t.setDaemon(True)
- t.start()
import glob
import re
import os
+import sys
+import time
+import threading
s_comment = re.compile('^#')
s_general_read_len = re.compile('^READ_LENGTH ')
return pattern % (lane)
-
class GARunStatus(object):
def __init__(self, conf_filepath):
#gerald['Tile.htm.tmp'] = False
gerald['finished.txt'] = False
-
-
-
def statusFirecrest(self):
"""
returns (<completed>, <total>)
return (fc+bc+gc, ft+bt+gt)
+ def statusReport(self):
+ """
+ Generate the basic percent complete report
+ """
+ def _percentCompleted(completed, total):
+ """
+ Returns precent completed as float
+ """
+ return (completed / float(total)) * 100
+
+ fc, ft = self.statusFirecrest()
+ bc, bt = self.statusBustard()
+ gc, gt = self.statusGerald()
+ tc, tt = self.statusTotal()
+
+ fp = _percentCompleted(fc, ft)
+ bp = _percentCompleted(bc, bt)
+ gp = _percentCompleted(gc, gt)
+ tp = _percentCompleted(tc, tt)
+
+ report = ['Firecrest: %s%% (%s/%s)' % (fp, fc, ft),
+ ' Bustard: %s%% (%s/%s)' % (bp, bc, bt),
+ ' Gerald: %s%% (%s/%s)' % (gp, gc, gt),
+ '-----------------------',
+ ' Total: %s%% (%s/%s)' % (tp, tc, tt),
+ ]
+ return report
+
def updateFirecrest(self, filename):
"""
Marks firecrest filename as being completed.
Marks gerald filename as being completed.
"""
self.status['gerald'][filename] = True
+
+
+
+##################################################
+# Functions to be called by Thread(target=<func>)
+def _cmdLineStatusMonitorFunc(conf_info):
+ """
+ Given a ConfigInfo object, provides status to stdout.
+
+ You should probably use startCmdLineStatusMonitor()
+ instead of ths function.
+
+ Use with:
+ t = threading.Thread(target=_cmdLineStatusMonitorFunc,
+ args=[conf_info])
+ t.setDaemon(True)
+ t.start()
+ """
+ SLEEP_AMOUNT = 30
+
+ while 1:
+ if conf_info.status is None:
+ print "No status object yet."
+ time.sleep(SLEEP_AMOUNT)
+ continue
+
+ report = conf_info.status.statusReport()
+ print os.linesep.join(report)
+ print
+
+ time.sleep(SLEEP_AMOUNT)
+
+
+#############################################
+# Start monitor thread convenience functions
+def startCmdLineStatusMonitor(conf_info):
+ """
+ Starts a command line status monitor given a conf_info object.
+ """
+ t = threading.Thread(target=_cmdLineStatusMonitorFunc, args=[conf_info])
+ t.setDaemon(True)
+ t.start()
+
+from optparse import OptionParser
+def make_parser():
+ usage = "%prog: config file"
+
+ parser = OptionParser()
+ return parser
+
+def main(cmdline=None):
+ parser = make_parser()
+ opt, args = parser.parse_args(cmdline)
+
+ if len(args) != 1:
+ parser.error("need name of configuration file")
+
+ status = GARunStatus(args[0])
+ print os.linesep.join(status.statusReport())
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv[1:]))
+
import re
from gaworkflow.pipeline.configure_run import *
from gaworkflow.pipeline import retrieve_config as _rc
-from gaworkflow.pipeline.monitors import startCmdLineStatusMonitor
+from gaworkflow.pipeline.run_status import startCmdLineStatusMonitor
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)-8s %(message)s',