# HG changeset patch # User Goffi # Date 1554655813 -7200 # Node ID 7c8773723200529118184203800c45099a8ae0bc # Parent 82b781c46841ec37ad1cb4610d552db0c71f67ba jp (roster): added resync command to do a full roster resynchronisation diff -r 82b781c46841 -r 7c8773723200 sat_frontends/jp/cmd_roster.py --- a/sat_frontends/jp/cmd_roster.py Sun Apr 07 18:49:41 2019 +0200 +++ b/sat_frontends/jp/cmd_roster.py Sun Apr 07 18:50:13 2019 +0200 @@ -19,11 +19,11 @@ # along with this program. If not, see . import base -from sat_frontends.jp.constants import Const as C +from collections import OrderedDict +from functools import partial from sat.core.i18n import _ - +from sat_frontends.jp.constants import Const as C from twisted.words.protocols.jabber import jid -from collections import OrderedDict __commands__ = ["Roster"] @@ -207,8 +207,32 @@ self.host.quit() +class Resync(base.CommandBase): + + def __init__(self, host): + super(Resync, self).__init__( + host, 'resync', help=_(u'do a full resynchronisation of roster with server')) + self.need_loop = True + + def add_parser_options(self): + pass + + def rosterResyncCb(self): + self.disp(_(u"Roster resynchronized")) + self.host.quit(C.EXIT_OK) + + def start(self): + self.host.bridge.rosterResync(profile_key=self.host.profile, + callback=self.rosterResyncCb, + errback=partial( + self.errback, + msg=_(u"can't resynchronise roster: {}"), + exit_code=C.EXIT_BRIDGE_ERRBACK, + )) + + class Roster(base.CommandBase): - subcommands = (Get, Stats, Purge) + subcommands = (Get, Stats, Purge, Resync) def __init__(self, host): super(Roster, self).__init__(host, 'roster', use_profile=True, help=_("Manage an entity's roster"))