X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=paralleljobs.py;h=5041d408b3b32f74d05270ee400feab9ad24c9db;hb=refs%2Fheads%2Fmaster;hp=535921c758b70c6bd09707e05a50ff31cdd9281d;hpb=3efeb3047d800403f9db6adb77b47cf06872ed40;p=paralleljobs.git diff --git a/paralleljobs.py b/paralleljobs.py index 535921c..5041d40 100755 --- a/paralleljobs.py +++ b/paralleljobs.py @@ -34,14 +34,24 @@ def printStatusInfo(conn): c.execute("SELECT sum(workloadestm) FROM jobs;") wltotal, = c.fetchone() - c.close() - perdone = 100.0*float(nodone)/float(nototal) - perwl = 100.0*float(wldone)/float(wltotal) + perdone = 0 + perwl = 0 + if nototal > 0: + perdone = 100.0*float(nodone)/float(nototal) + if wltotal > 0: + perwl = 100.0*float(wldone)/float(wltotal) print("%d (%.1f%%) of %d jobs and %.1f%% of the workload done. %d jobs are running." % \ (nodone, perdone, nototal, perwl, nostarted-nodone)) + print("Exit code stats:") + c.execute("SELECT exitcode, count(exitcode) AS cnt FROM jobs WHERE exitcode >= 0 GROUP BY exitcode ORDER BY exitcode ASC;") + for code, cnt in c.fetchall(): + print(" %3s: %6s (%5.1f%%)" % (code, cnt, 100.0*float(cnt)/nodone)) + + c.close() + def createPropertiesTable(conn, propdef): conn.execute("BEGIN EXCLUSIVE") @@ -64,7 +74,7 @@ def runCmd(cmd): exitcode = proc.wait() if verbose: - print(out, err) + print out, err return exitcode, out, err @@ -74,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 = [] @@ -120,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, \ @@ -246,7 +260,7 @@ if __name__ == "__main__": print("No database given.") sys.exit(os.EX_USAGE) - conn = sqlite3.connect(dbfn) + conn = sqlite3.connect(dbfn, timeout=60) createSchema(conn) if status: