Mercurial > libervia-backend
changeset 1932:44342730df66
jp (cmd/roster): fixes division by zero exceptions
fix bug 135
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 17 Apr 2016 13:00:44 +0200 |
parents | 2c55e7e99ef3 |
children | 16e65f15f31f |
files | frontends/src/jp/cmd_roster.py |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/src/jp/cmd_roster.py Sat Mar 26 18:43:54 2016 +0100 +++ b/frontends/src/jp/cmd_roster.py Sun Apr 17 13:00:44 2016 +0200 @@ -149,8 +149,16 @@ print "Contacts with no subscription at all: %d" % no_sub print print "Total number of groups: %d" % len(unique_groups) - print "Average contacts per group: %.1f" % (float(total_group_subscription) / len(unique_groups)) - print "Average groups' subscriptions per contact: %.1f" % (float(total_group_subscription) / len(contacts)) + try: + contacts_per_group = float(total_group_subscription) / len(unique_groups) + except ZeroDivisionError: + contacts_per_group = 0 + print "Average contacts per group: {:.1f}".format(contacts_per_group) + try: + groups_per_contact = float(total_group_subscription) / len(contacts) + except ZeroDivisionError: + groups_per_contact = 0 + print "Average groups' subscriptions per contact: {:.1f}".format(groups_per_contact) print "Contacts not assigned to any group: %d" % no_group self.host.quit()