summaryrefslogtreecommitdiffstats
path: root/pykolab/cli/cmd_list_quota.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-09-14 08:37:10 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-09-14 08:37:10 +0100
commit319095b31f77403f2ac114b0c00887e4f19c256a (patch)
treebe83059af9ae056f67e248d38acd8d9f49bb32b3 /pykolab/cli/cmd_list_quota.py
parentb66c633e71ab5ce106f885565eb1d7f798f1b4e8 (diff)
downloadpykolab-319095b31f77403f2ac114b0c00887e4f19c256a.tar.gz
Make sure no division by zero occurs in listing quota. (#1005)
Diffstat (limited to 'pykolab/cli/cmd_list_quota.py')
-rw-r--r--pykolab/cli/cmd_list_quota.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/pykolab/cli/cmd_list_quota.py b/pykolab/cli/cmd_list_quota.py
index dfd8b75..c60f48e 100644
--- a/pykolab/cli/cmd_list_quota.py
+++ b/pykolab/cli/cmd_list_quota.py
@@ -55,15 +55,23 @@ def execute(*args, **kw):
try:
(used, quota) = imap.get_quota(quota_folder)
if not used == None and not quota == None:
- percentage = round((used/quota)*100, 1)
- print "%d (Used: %d, Percentage: %d)" % (quota, used, percentage)
+ if quota == 0:
+ print >> sys.stderr, _("The quota for folder %s is set to literally allow 0KB of storage.") % (quota_folder)
+ print "%d (Used: %d, Percentage: %s)" % (quota, used, u'\u221E')
+ else:
+ percentage = round((used/quota)*100, 1)
+ print "%d (Used: %d, Percentage: %d)" % (quota, used, percentage)
else:
print "No quota"
except:
(quota_root, used, quota) = imap.get_quota_root(quota_folder)
if not quota_root == None and not used == None and not quota == None:
- percentage = round((used/quota)*100, 1)
- print "%d (Root: %s, Used: %d, Percentage: %d)" % (quota, quota_root, used, percentage)
+ if quota == 0:
+ print >> sys.stderr, _("The quota for folder %s is set to literally allow 0KB of storage.") % (quota_folder)
+ print "%d (Used: %d, Percentage: %s)" % (quota, used, u'\u221E')
+ else:
+ percentage = round((used/quota)*100, 1)
+ print "%d (Root: %s, Used: %d, Percentage: %d)" % (quota, quota_root, used, percentage)
else:
print "No quota"