X-Git-Url: http://git.sthu.org/?p=paralleljobs.git;a=blobdiff_plain;f=paralleljobs.py;fp=paralleljobs.py;h=463afbed086b007596368e7efbfdb981407f0ec3;hp=5c309cd7e7118f677161ebbbd0e7519b81cb3727;hb=a371c8fdd6a748098c8a701d20db4b3c59176afd;hpb=fbca1279e2e56e71b7aa9a15a285e26375ed400a diff --git a/paralleljobs.py b/paralleljobs.py index 5c309cd..463afbe 100755 --- a/paralleljobs.py +++ b/paralleljobs.py @@ -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, \