summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/jobqueue_helper.py
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2014-02-11 21:31:51 (GMT)
committerBritney Fransen <brfransen@gmail.com>2014-02-11 21:31:51 (GMT)
commitdd0d1371a1ef3b0a5a71b32721b9cef2277d7caa (patch)
treee845fd741365d04983f7c349e5248e8e5799c90a /abs/core/LinHES-system/jobqueue_helper.py
parent73e217800ce2ebd6e64ae54db7f54c386f047cff (diff)
downloadlinhes_pkgbuild-dd0d1371a1ef3b0a5a71b32721b9cef2277d7caa.zip
linhes_pkgbuild-dd0d1371a1ef3b0a5a71b32721b9cef2277d7caa.tar.gz
linhes_pkgbuild-dd0d1371a1ef3b0a5a71b32721b9cef2277d7caa.tar.bz2
LinHES-system: myth2mkv: use jobqueue_helper.py for myth db access. refs #958
jobqueue_helper.py: initial inclusion.
Diffstat (limited to 'abs/core/LinHES-system/jobqueue_helper.py')
-rwxr-xr-xabs/core/LinHES-system/jobqueue_helper.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/abs/core/LinHES-system/jobqueue_helper.py b/abs/core/LinHES-system/jobqueue_helper.py
new file mode 100755
index 0000000..d27e693
--- /dev/null
+++ b/abs/core/LinHES-system/jobqueue_helper.py
@@ -0,0 +1,63 @@
+#!/usr/bin/python2
+
+import argparse, os, re, subprocess, sys, time
+from MythTV import MythDB, Job
+
+mythDB = MythDB()
+cursor = mythDB.cursor()
+
+def set_cmds(cmdargs,job):
+ #print "Setting cmds on job %s to %s" %(cmdargs.jobid,cmdargs.cmd)
+ cursor.execute("update jobqueue set cmds = '%s' where id = '%s'" %(cmdargs.cmd,cmdargs.jobid))
+
+def set_comment(cmdargs,job):
+ #print "Setting comment on job %s to %s" %(cmdargs.jobid,cmdargs.comment)
+ job.setComment("%s" %cmdargs.comment)
+
+def set_status(cmdargs,job):
+ #print "Setting status on job %s to %s" %(cmdargs.jobid,cmdargs.status)
+ job.setStatus("%s" %cmdargs.status)
+
+def run_cursor(cmdargs):
+ cursor.execute("%s" %cmdargs.man_cursor)
+ results=cursor.fetchone()
+ print results[0]
+
+def usage():
+ line = '''
+ jobqueue_helper.py provides MythTV job queue functions
+ using python bindings for bash scripts.
+ Use jobqueue_helper.py -h to see options.
+ '''
+ print line
+ sys.exit(0)
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-cs', '--comment_set', action='store', dest='comment', help='Set the comment of the jobid')
+ parser.add_argument('-cmds', '--cmd_set', type=int, default=77777, action='store', dest='cmd', help='Set the cmd of the jobid')
+ parser.add_argument('-ss', '--status_set', type=int, action='store', dest='status', help='Set the status of the jobid')
+ action = parser.add_mutually_exclusive_group(required=True)
+ action.add_argument('-j', '--jobid', type=int, help='jobid of the job to control')
+ action.add_argument('-m', '--man_cursor', action='store', dest='man_cursor', help='Manual mysql cursor command')
+ action.add_argument('-u', '--usage', action='store_true', help='Print usage instructions.')
+
+ cmdargs = parser.parse_args()
+
+ if cmdargs.usage:
+ usage()
+
+ if cmdargs.jobid:
+ job = Job(cmdargs.jobid)
+
+ if cmdargs.comment:
+ set_comment(cmdargs, job)
+
+ if cmdargs.status:
+ set_status(cmdargs, job)
+
+ if cmdargs.cmd != 77777:
+ set_cmds(cmdargs, job)
+
+ if cmdargs.man_cursor:
+ run_cursor(cmdargs)