Show exit code after jobs was processed
authorStefan Huber <shuber@sthu.org>
Fri, 17 May 2013 14:47:18 +0000 (16:47 +0200)
committerStefan Huber <shuber@sthu.org>
Fri, 17 May 2013 14:47:18 +0000 (16:47 +0200)
paralleljobs.py

index 5c309cd7e7118f677161ebbbd0e7519b81cb3727..463afbed086b007596368e7efbfdb981407f0ec3 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
 """ A simple tool to run jobs from a database in parallel."""
 
 __author__ = "Stefan Huber"
@@ -74,7 +74,7 @@ def runCmd(cmd):
     exitcode = proc.wait()
 
     if verbose:
-        print(out, err)
+        print out, err
 
     return exitcode, out, err
 
@@ -84,9 +84,13 @@ def processJob(conn, jobid):
     c.execute("SELECT cmd FROM jobs WHERE id=?", (jobid,))
     cmd, = c.fetchone()
 
-    print("Process job %d: %s" % (jobid, cmd))
-
+    print "Job %d: '%s'..." % (jobid, cmd),
     ec, out, err = runCmd(cmd)
+    if ec==0:
+        print " [OK]"
+    else:
+        print " [FAILED: %d]" % ec
+
     c.execute("UPDATE jobs SET exitcode=?, done=1 WHERE id=?;", (ec, jobid))
 
     propstr = []
@@ -130,7 +134,7 @@ def createSchema(conn):
     # Create table, if necessary
     c.execute("SELECT count(name) FROM sqlite_master WHERE name='jobs';")
     if c.fetchone() == (0,):
-        print("Creating jobs table.")
+        print "Creating jobs table."
         conn.execute("CREATE TABLE jobs ( \
                         id INTEGER PRIMARY KEY AUTOINCREMENT, \
                         cmd STRING NOT NULL, \