From 4e711d4336ec0f45fc06a9e664d4507c8194ab63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Tue, 13 Jan 2015 18:50:50 +0100 Subject: [PATCH] Fixed zero division error if max_count_value is zero. --- jobmanager/decorators.py | 2 +- jobmanager/progress.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/jobmanager/decorators.py b/jobmanager/decorators.py index 6902eb4..51949dd 100644 --- a/jobmanager/decorators.py +++ b/jobmanager/decorators.py @@ -117,7 +117,7 @@ class ProgressBar(object): kwargs[self.cm[0]] = progress.UnsignedIntValue(0) if not kwargs.has_key(self.cm[1]) or kwargs[self.cm[1]] is None: # max_count - kwargs[self.cm[1]] = progress.UnsignedIntValue(0) + kwargs[self.cm[1]] = progress.UnsignedIntValue(1) with progress.ProgressBar(kwargs[self.cm[0]], kwargs[self.cm[1]], *self.args, **self.kwargs) as pb: pb.start() diff --git a/jobmanager/progress.py b/jobmanager/progress.py index b1b2e46..1ad064e 100644 --- a/jobmanager/progress.py +++ b/jobmanager/progress.py @@ -929,7 +929,11 @@ class ProgressBar(Progress): l = len(s1) + len(s3) l2 = width - l - 1 - a = int(l2 * count_value / max_count_value) + if max_count_value != 0: + a = int(l2 * count_value / max_count_value) + else: + a = 0 + b = l2 - a s2 = "="*a + ">" + " "*b print(s1+s2+s3)