Mercurial > libervia-backend
comparison frontends/src/jp/cmd_roster.py @ 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 | 96ba685162f6 |
children | 3e168cde7a7d |
comparison
equal
deleted
inserted
replaced
1931:2c55e7e99ef3 | 1932:44342730df66 |
---|---|
147 print "Contacts with no 'from' subscription: %d" % no_from | 147 print "Contacts with no 'from' subscription: %d" % no_from |
148 print "Contacts with no 'to' subscription: %d" % no_to | 148 print "Contacts with no 'to' subscription: %d" % no_to |
149 print "Contacts with no subscription at all: %d" % no_sub | 149 print "Contacts with no subscription at all: %d" % no_sub |
150 print | 150 print |
151 print "Total number of groups: %d" % len(unique_groups) | 151 print "Total number of groups: %d" % len(unique_groups) |
152 print "Average contacts per group: %.1f" % (float(total_group_subscription) / len(unique_groups)) | 152 try: |
153 print "Average groups' subscriptions per contact: %.1f" % (float(total_group_subscription) / len(contacts)) | 153 contacts_per_group = float(total_group_subscription) / len(unique_groups) |
154 except ZeroDivisionError: | |
155 contacts_per_group = 0 | |
156 print "Average contacts per group: {:.1f}".format(contacts_per_group) | |
157 try: | |
158 groups_per_contact = float(total_group_subscription) / len(contacts) | |
159 except ZeroDivisionError: | |
160 groups_per_contact = 0 | |
161 print "Average groups' subscriptions per contact: {:.1f}".format(groups_per_contact) | |
154 print "Contacts not assigned to any group: %d" % no_group | 162 print "Contacts not assigned to any group: %d" % no_group |
155 self.host.quit() | 163 self.host.quit() |
156 | 164 |
157 | 165 |
158 class Get(base.CommandBase): | 166 class Get(base.CommandBase): |