comparison sat_frontends/jp/cmd_roster.py @ 2893:7c8773723200

jp (roster): added resync command to do a full roster resynchronisation
author Goffi <goffi@goffi.org>
date Sun, 07 Apr 2019 18:50:13 +0200
parents 003b8b4b56a7
children ab2696e34d29
comparison
equal deleted inserted replaced
2892:82b781c46841 2893:7c8773723200
17 17
18 # You should have received a copy of the GNU Affero General Public License 18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. 19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 20
21 import base 21 import base
22 from collections import OrderedDict
23 from functools import partial
24 from sat.core.i18n import _
22 from sat_frontends.jp.constants import Const as C 25 from sat_frontends.jp.constants import Const as C
23 from sat.core.i18n import _
24
25 from twisted.words.protocols.jabber import jid 26 from twisted.words.protocols.jabber import jid
26 from collections import OrderedDict
27 27
28 __commands__ = ["Roster"] 28 __commands__ = ["Roster"]
29 29
30 30
31 31
205 args.append(u"\t".join(groups) if groups else "") 205 args.append(u"\t".join(groups) if groups else "")
206 print u";".join(["{}"] * field_count).format(*args).encode("utf-8") 206 print u";".join(["{}"] * field_count).format(*args).encode("utf-8")
207 self.host.quit() 207 self.host.quit()
208 208
209 209
210 class Resync(base.CommandBase):
211
212 def __init__(self, host):
213 super(Resync, self).__init__(
214 host, 'resync', help=_(u'do a full resynchronisation of roster with server'))
215 self.need_loop = True
216
217 def add_parser_options(self):
218 pass
219
220 def rosterResyncCb(self):
221 self.disp(_(u"Roster resynchronized"))
222 self.host.quit(C.EXIT_OK)
223
224 def start(self):
225 self.host.bridge.rosterResync(profile_key=self.host.profile,
226 callback=self.rosterResyncCb,
227 errback=partial(
228 self.errback,
229 msg=_(u"can't resynchronise roster: {}"),
230 exit_code=C.EXIT_BRIDGE_ERRBACK,
231 ))
232
233
210 class Roster(base.CommandBase): 234 class Roster(base.CommandBase):
211 subcommands = (Get, Stats, Purge) 235 subcommands = (Get, Stats, Purge, Resync)
212 236
213 def __init__(self, host): 237 def __init__(self, host):
214 super(Roster, self).__init__(host, 'roster', use_profile=True, help=_("Manage an entity's roster")) 238 super(Roster, self).__init__(host, 'roster', use_profile=True, help=_("Manage an entity's roster"))