From: Stefan Huber Date: Thu, 9 May 2013 15:34:08 +0000 (+0200) Subject: fix div by zero X-Git-Tag: v1.1~4 X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=728da16cad3611634957697dda87760af8c8aaf5;p=paralleljobs.git fix div by zero --- diff --git a/paralleljobs.py b/paralleljobs.py index 535921c..465efdf 100755 --- a/paralleljobs.py +++ b/paralleljobs.py @@ -36,8 +36,12 @@ def printStatusInfo(conn): 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))