Mercurial > libervia-backend
annotate sat_frontends/jp/cmd_roster.py @ 3195:29d72336a40d
changelog: update
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 28 Feb 2020 18:10:58 +0100 |
parents | 559a625a236b |
children | 012e89fb2dd1 |
rev | line source |
---|---|
3137 | 1 #!/usr/bin/env python3 |
2 | |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
3 |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
4 # jp: a SAT command line tool |
3136 | 5 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org) |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
6 # Copyright (C) 2003-2016 Adrien Cossa (souliane@mailoo.org) |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
7 |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
8 # This program is free software: you can redistribute it and/or modify |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
9 # it under the terms of the GNU Affero General Public License as published by |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
10 # the Free Software Foundation, either version 3 of the License, or |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
11 # (at your option) any later version. |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
12 |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
13 # This program is distributed in the hope that it will be useful, |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
16 # GNU Affero General Public License for more details. |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
17 |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
18 # You should have received a copy of the GNU Affero General Public License |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
20 |
3028 | 21 from . import base |
2893
7c8773723200
jp (roster): added resync command to do a full roster resynchronisation
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
22 from collections import OrderedDict |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
23 from sat.core.i18n import _ |
2893
7c8773723200
jp (roster): added resync command to do a full roster resynchronisation
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
24 from sat_frontends.jp.constants import Const as C |
3040 | 25 from sat_frontends.tools import jid |
26 from sat.tools.common.ansi import ANSI as A | |
1796
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
27 |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
28 __commands__ = ["Roster"] |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
29 |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
30 |
3040 | 31 class Get(base.CommandBase): |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
32 |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
33 def __init__(self, host): |
3040 | 34 super().__init__( |
35 host, 'get', use_output=C.OUTPUT_DICT, use_verbose=True, | |
36 extra_outputs = {"default": self.default_output}, | |
37 help=_('retrieve the roster entities')) | |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
38 |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
39 def add_parser_options(self): |
3040 | 40 pass |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
41 |
3040 | 42 def default_output(self, data): |
43 for contact_jid, contact_data in data.items(): | |
44 all_keys = list(contact_data.keys()) | |
45 keys_to_show = [] | |
46 name = contact_data.get('name', contact_jid.node) | |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
47 |
3040 | 48 if self.verbosity >= 1: |
49 keys_to_show.append('groups') | |
50 all_keys.remove('groups') | |
51 if self.verbosity >= 2: | |
52 keys_to_show.extend(all_keys) | |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
53 |
3040 | 54 if name is None: |
55 self.disp(A.color(C.A_HEADER, contact_jid)) | |
56 else: | |
57 self.disp(A.color(C.A_HEADER, name, A.RESET, f" ({contact_jid})")) | |
58 for k in keys_to_show: | |
59 value = contact_data[k] | |
60 if value: | |
61 if isinstance(value, list): | |
62 value = ', '.join(value) | |
63 self.disp(A.color( | |
64 " ", C.A_SUBHEADER, f"{k}: ", A.RESET, str(value))) | |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
65 |
3040 | 66 async def start(self): |
67 try: | |
68 contacts = await self.host.bridge.getContacts(profile_key=self.host.profile) | |
69 except Exception as e: | |
70 self.disp(f"error while retrieving the contacts: {e}", error=True) | |
71 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
72 |
3040 | 73 contacts_dict = {} |
74 for contact_jid_s, data, groups in contacts: | |
75 # FIXME: we have to convert string to bool here for historical reason | |
76 # getContacts format should be changed and serialised properly | |
77 for key in ('from', 'to', 'ask'): | |
78 if key in data: | |
79 data[key] = C.bool(data[key]) | |
80 data['groups'] = list(groups) | |
81 contacts_dict[jid.JID(contact_jid_s)] = data | |
82 | |
83 await self.output(contacts_dict) | |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
84 self.host.quit() |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
85 |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
86 |
1796
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
87 class Stats(base.CommandBase): |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
88 |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
89 def __init__(self, host): |
1798
c5d58387d031
jp (roster stats): add some extra information
souliane <souliane@mailoo.org>
parents:
1797
diff
changeset
|
90 super(Stats, self).__init__(host, 'stats', help=_('Show statistics about a roster')) |
1796
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
91 |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
92 def add_parser_options(self): |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
93 pass |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
94 |
3040 | 95 async def start(self): |
96 try: | |
97 contacts = await self.host.bridge.getContacts(profile_key=self.host.profile) | |
98 except Exception as e: | |
99 self.disp(f"error while retrieving the contacts: {e}", error=True) | |
100 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
1796
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
101 |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
102 hosts = {} |
1798
c5d58387d031
jp (roster stats): add some extra information
souliane <souliane@mailoo.org>
parents:
1797
diff
changeset
|
103 unique_groups = set() |
c5d58387d031
jp (roster stats): add some extra information
souliane <souliane@mailoo.org>
parents:
1797
diff
changeset
|
104 no_sub, no_from, no_to, no_group, total_group_subscription = 0, 0, 0, 0, 0 |
1796
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
105 for contact, attrs, groups in contacts: |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
106 from_, to = C.bool(attrs["from"]), C.bool(attrs["to"]) |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
107 if not from_: |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
108 if not to: |
1798
c5d58387d031
jp (roster stats): add some extra information
souliane <souliane@mailoo.org>
parents:
1797
diff
changeset
|
109 no_sub += 1 |
1796
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
110 else: |
1798
c5d58387d031
jp (roster stats): add some extra information
souliane <souliane@mailoo.org>
parents:
1797
diff
changeset
|
111 no_from += 1 |
1796
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
112 elif not to: |
1798
c5d58387d031
jp (roster stats): add some extra information
souliane <souliane@mailoo.org>
parents:
1797
diff
changeset
|
113 no_to += 1 |
3040 | 114 |
115 host = jid.JID(contact).domain | |
116 | |
1796
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
117 hosts.setdefault(host, 0) |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
118 hosts[host] += 1 |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
119 if groups: |
1798
c5d58387d031
jp (roster stats): add some extra information
souliane <souliane@mailoo.org>
parents:
1797
diff
changeset
|
120 unique_groups.update(groups) |
1796
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
121 total_group_subscription += len(groups) |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
122 if not groups: |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
123 no_group += 1 |
3028 | 124 hosts = OrderedDict(sorted(list(hosts.items()), key=lambda item:-item[1])) |
1796
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
125 |
3028 | 126 print() |
127 print("Total number of contacts: %d" % len(contacts)) | |
128 print("Number of different hosts: %d" % len(hosts)) | |
129 print() | |
130 for host, count in hosts.items(): | |
3040 | 131 print("Contacts on {host}: {count} ({rate:.1f}%)".format( |
132 host=host, count=count, rate=100 * float(count) / len(contacts))) | |
3028 | 133 print() |
134 print("Contacts with no 'from' subscription: %d" % no_from) | |
135 print("Contacts with no 'to' subscription: %d" % no_to) | |
136 print("Contacts with no subscription at all: %d" % no_sub) | |
137 print() | |
138 print("Total number of groups: %d" % len(unique_groups)) | |
1932
44342730df66
jp (cmd/roster): fixes division by zero exceptions
souliane <souliane@mailoo.org>
parents:
1864
diff
changeset
|
139 try: |
44342730df66
jp (cmd/roster): fixes division by zero exceptions
souliane <souliane@mailoo.org>
parents:
1864
diff
changeset
|
140 contacts_per_group = float(total_group_subscription) / len(unique_groups) |
44342730df66
jp (cmd/roster): fixes division by zero exceptions
souliane <souliane@mailoo.org>
parents:
1864
diff
changeset
|
141 except ZeroDivisionError: |
44342730df66
jp (cmd/roster): fixes division by zero exceptions
souliane <souliane@mailoo.org>
parents:
1864
diff
changeset
|
142 contacts_per_group = 0 |
3028 | 143 print("Average contacts per group: {:.1f}".format(contacts_per_group)) |
1932
44342730df66
jp (cmd/roster): fixes division by zero exceptions
souliane <souliane@mailoo.org>
parents:
1864
diff
changeset
|
144 try: |
44342730df66
jp (cmd/roster): fixes division by zero exceptions
souliane <souliane@mailoo.org>
parents:
1864
diff
changeset
|
145 groups_per_contact = float(total_group_subscription) / len(contacts) |
44342730df66
jp (cmd/roster): fixes division by zero exceptions
souliane <souliane@mailoo.org>
parents:
1864
diff
changeset
|
146 except ZeroDivisionError: |
44342730df66
jp (cmd/roster): fixes division by zero exceptions
souliane <souliane@mailoo.org>
parents:
1864
diff
changeset
|
147 groups_per_contact = 0 |
3040 | 148 print(f"Average groups' subscriptions per contact: {groups_per_contact:.1f}") |
3028 | 149 print("Contacts not assigned to any group: %d" % no_group) |
1796
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
150 self.host.quit() |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
151 |
314d2eb7fbaa
jp: add command "roster stats"
souliane <souliane@mailoo.org>
parents:
1793
diff
changeset
|
152 |
3040 | 153 class Purge(base.CommandBase): |
1799
f1f4775f8cc0
jp (roster): add command "roster get" with parameters "--subscriptions", "--name" and "--groups"
souliane <souliane@mailoo.org>
parents:
1798
diff
changeset
|
154 |
f1f4775f8cc0
jp (roster): add command "roster get" with parameters "--subscriptions", "--name" and "--groups"
souliane <souliane@mailoo.org>
parents:
1798
diff
changeset
|
155 def __init__(self, host): |
3040 | 156 super(Purge, self).__init__( |
157 host, 'purge', | |
158 help=_('purge the roster from its contacts with no subscription')) | |
1799
f1f4775f8cc0
jp (roster): add command "roster get" with parameters "--subscriptions", "--name" and "--groups"
souliane <souliane@mailoo.org>
parents:
1798
diff
changeset
|
159 |
f1f4775f8cc0
jp (roster): add command "roster get" with parameters "--subscriptions", "--name" and "--groups"
souliane <souliane@mailoo.org>
parents:
1798
diff
changeset
|
160 def add_parser_options(self): |
3040 | 161 self.parser.add_argument( |
162 "--no_from", action="store_true", | |
163 help=_("also purge contacts with no 'from' subscription")) | |
164 self.parser.add_argument( | |
165 "--no_to", action="store_true", | |
166 help=_("also purge contacts with no 'to' subscription")) | |
1799
f1f4775f8cc0
jp (roster): add command "roster get" with parameters "--subscriptions", "--name" and "--groups"
souliane <souliane@mailoo.org>
parents:
1798
diff
changeset
|
167 |
3040 | 168 async def start(self): |
169 try: | |
170 contacts = await self.host.bridge.getContacts(self.host.profile) | |
171 except Exception as e: | |
172 self.disp(f"error while retrieving the contacts: {e}", error=True) | |
173 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
1799
f1f4775f8cc0
jp (roster): add command "roster get" with parameters "--subscriptions", "--name" and "--groups"
souliane <souliane@mailoo.org>
parents:
1798
diff
changeset
|
174 |
3040 | 175 no_sub, no_from, no_to = [], [], [] |
176 for contact, attrs, groups in contacts: | |
177 from_, to = C.bool(attrs["from"]), C.bool(attrs["to"]) | |
178 if not from_: | |
179 if not to: | |
180 no_sub.append(contact) | |
181 elif self.args.no_from: | |
182 no_from.append(contact) | |
183 elif not to and self.args.no_to: | |
184 no_to.append(contact) | |
185 if not no_sub and not no_from and not no_to: | |
186 self.disp( | |
187 f"Nothing to do - there's a from and/or to subscription(s) between " | |
188 f"profile {self.host.profile!r} and each of its contacts" | |
189 ) | |
190 elif await self.ask_confirmation(no_sub, no_from, no_to): | |
191 for contact in no_sub + no_from + no_to: | |
192 try: | |
193 await self.host.bridge.delContact( | |
194 contact, profile_key=self.host.profile) | |
195 except Exception as e: | |
196 self.disp(f"can't delete contact {contact!r}: {e}", error=True) | |
197 else: | |
198 self.disp(f"contact {contact!r} has been removed") | |
1799
f1f4775f8cc0
jp (roster): add command "roster get" with parameters "--subscriptions", "--name" and "--groups"
souliane <souliane@mailoo.org>
parents:
1798
diff
changeset
|
199 |
3040 | 200 self.host.quit() |
201 | |
202 async def ask_confirmation(self, no_sub, no_from, no_to): | |
203 """Ask the confirmation before removing contacts. | |
1799
f1f4775f8cc0
jp (roster): add command "roster get" with parameters "--subscriptions", "--name" and "--groups"
souliane <souliane@mailoo.org>
parents:
1798
diff
changeset
|
204 |
3040 | 205 @param no_sub (list[unicode]): list of contacts with no subscription |
206 @param no_from (list[unicode]): list of contacts with no 'from' subscription | |
207 @param no_to (list[unicode]): list of contacts with no 'to' subscription | |
208 @return bool | |
1799
f1f4775f8cc0
jp (roster): add command "roster get" with parameters "--subscriptions", "--name" and "--groups"
souliane <souliane@mailoo.org>
parents:
1798
diff
changeset
|
209 """ |
3040 | 210 if no_sub: |
211 self.disp( | |
212 f"There's no subscription between profile {self.host.profile!r} and the " | |
213 f"following contacts:") | |
214 self.disp(" " + "\n ".join(no_sub)) | |
215 if no_from: | |
216 self.disp( | |
217 f"There's no 'from' subscription between profile {self.host.profile!r} " | |
218 f"and the following contacts:") | |
219 self.disp(" " + "\n ".join(no_from)) | |
220 if no_to: | |
221 self.disp( | |
222 f"There's no 'to' subscription between profile {self.host.profile!r} and " | |
223 f"the following contacts:") | |
224 self.disp(" " + "\n ".join(no_to)) | |
225 message = f"REMOVE them from profile {self.host.profile}'s roster" | |
226 while True: | |
227 res = await self.host.ainput(f"{message} (y/N)? ") | |
228 if not res or res.lower() == 'n': | |
229 return False | |
230 if res.lower() == 'y': | |
231 return True | |
1799
f1f4775f8cc0
jp (roster): add command "roster get" with parameters "--subscriptions", "--name" and "--groups"
souliane <souliane@mailoo.org>
parents:
1798
diff
changeset
|
232 |
f1f4775f8cc0
jp (roster): add command "roster get" with parameters "--subscriptions", "--name" and "--groups"
souliane <souliane@mailoo.org>
parents:
1798
diff
changeset
|
233 |
2893
7c8773723200
jp (roster): added resync command to do a full roster resynchronisation
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
234 class Resync(base.CommandBase): |
7c8773723200
jp (roster): added resync command to do a full roster resynchronisation
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
235 |
7c8773723200
jp (roster): added resync command to do a full roster resynchronisation
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
236 def __init__(self, host): |
7c8773723200
jp (roster): added resync command to do a full roster resynchronisation
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
237 super(Resync, self).__init__( |
3028 | 238 host, 'resync', help=_('do a full resynchronisation of roster with server')) |
2893
7c8773723200
jp (roster): added resync command to do a full roster resynchronisation
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
239 |
7c8773723200
jp (roster): added resync command to do a full roster resynchronisation
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
240 def add_parser_options(self): |
7c8773723200
jp (roster): added resync command to do a full roster resynchronisation
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
241 pass |
7c8773723200
jp (roster): added resync command to do a full roster resynchronisation
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
242 |
3040 | 243 async def start(self): |
244 try: | |
245 await self.host.bridge.rosterResync(profile_key=self.host.profile) | |
246 except Exception as e: | |
247 self.disp(f"can't resynchronise roster: {e}", error=True) | |
248 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
249 else: | |
250 self.disp(_("Roster resynchronized")) | |
251 self.host.quit(C.EXIT_OK) | |
2893
7c8773723200
jp (roster): added resync command to do a full roster resynchronisation
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
252 |
7c8773723200
jp (roster): added resync command to do a full roster resynchronisation
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
253 |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
254 class Roster(base.CommandBase): |
2893
7c8773723200
jp (roster): added resync command to do a full roster resynchronisation
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
255 subcommands = (Get, Stats, Purge, Resync) |
1793
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
256 |
f39ca2832774
jp: add command "roster purge" to remove the contacts with no from/to subscription
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
257 def __init__(self, host): |
3040 | 258 super(Roster, self).__init__( |
259 host, 'roster', use_profile=True, help=_("Manage an entity's roster")) |