Mercurial > libervia-backend
comparison frontends/src/jp/cmd_roster.py @ 1864:96ba685162f6
jp: all commands now use the new start method and set need_loop in __init__ when needed
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 29 Feb 2016 16:52:51 +0100 |
parents | 5f4d688d8b6e |
children | 44342730df66 |
comparison
equal
deleted
inserted
replaced
1863:b2ddd7f5dcdf | 1864:96ba685162f6 |
---|---|
31 | 31 |
32 class Purge(base.CommandBase): | 32 class Purge(base.CommandBase): |
33 | 33 |
34 def __init__(self, host): | 34 def __init__(self, host): |
35 super(Purge, self).__init__(host, 'purge', help=_('Purge the roster from its contacts with no subscription')) | 35 super(Purge, self).__init__(host, 'purge', help=_('Purge the roster from its contacts with no subscription')) |
36 self.need_loop = True | |
36 | 37 |
37 def add_parser_options(self): | 38 def add_parser_options(self): |
38 self.parser.add_argument("--no_from", action="store_true", help=_("Also purge contacts with no 'from' subscription")) | 39 self.parser.add_argument("--no_from", action="store_true", help=_("Also purge contacts with no 'from' subscription")) |
39 self.parser.add_argument("--no_to", action="store_true", help=_("Also purge contacts with no 'to' subscription")) | 40 self.parser.add_argument("--no_to", action="store_true", help=_("Also purge contacts with no 'to' subscription")) |
40 | 41 |
41 def connected(self): | 42 def start(self): |
42 self.need_loop = True | |
43 super(Purge, self).connected() | |
44 self.host.bridge.getContacts(profile_key=self.host.profile, callback=self.gotContacts, errback=self.error) | 43 self.host.bridge.getContacts(profile_key=self.host.profile, callback=self.gotContacts, errback=self.error) |
45 | 44 |
46 def error(self, failure): | 45 def error(self, failure): |
47 print (_("Error while retrieving the contacts [%s]") % failure) | 46 print (_("Error while retrieving the contacts [%s]") % failure) |
48 self.host.quit(1) | 47 self.host.quit(1) |
97 | 96 |
98 class Stats(base.CommandBase): | 97 class Stats(base.CommandBase): |
99 | 98 |
100 def __init__(self, host): | 99 def __init__(self, host): |
101 super(Stats, self).__init__(host, 'stats', help=_('Show statistics about a roster')) | 100 super(Stats, self).__init__(host, 'stats', help=_('Show statistics about a roster')) |
101 self.need_loop = True | |
102 | 102 |
103 def add_parser_options(self): | 103 def add_parser_options(self): |
104 pass | 104 pass |
105 | 105 |
106 def connected(self): | 106 def start(self): |
107 self.need_loop = True | |
108 super(Stats, self).connected() | |
109 self.host.bridge.getContacts(profile_key=self.host.profile, callback=self.gotContacts, errback=self.error) | 107 self.host.bridge.getContacts(profile_key=self.host.profile, callback=self.gotContacts, errback=self.error) |
110 | 108 |
111 def error(self, failure): | 109 def error(self, failure): |
112 print (_("Error while retrieving the contacts [%s]") % failure) | 110 print (_("Error while retrieving the contacts [%s]") % failure) |
113 self.host.quit(1) | 111 self.host.quit(1) |
159 | 157 |
160 class Get(base.CommandBase): | 158 class Get(base.CommandBase): |
161 | 159 |
162 def __init__(self, host): | 160 def __init__(self, host): |
163 super(Get, self).__init__(host, 'get', help=_('Retrieve the roster contacts')) | 161 super(Get, self).__init__(host, 'get', help=_('Retrieve the roster contacts')) |
162 self.need_loop = True | |
164 | 163 |
165 def add_parser_options(self): | 164 def add_parser_options(self): |
166 self.parser.add_argument("--subscriptions", action="store_true", help=_("Show the contacts' subscriptions")) | 165 self.parser.add_argument("--subscriptions", action="store_true", help=_("Show the contacts' subscriptions")) |
167 self.parser.add_argument("--groups", action="store_true", help=_("Show the contacts' groups")) | 166 self.parser.add_argument("--groups", action="store_true", help=_("Show the contacts' groups")) |
168 self.parser.add_argument("--name", action="store_true", help=_("Show the contacts' names")) | 167 self.parser.add_argument("--name", action="store_true", help=_("Show the contacts' names")) |
169 | 168 |
170 def connected(self): | 169 def start(self): |
171 self.need_loop = True | |
172 super(Get, self).connected() | |
173 self.host.bridge.getContacts(profile_key=self.host.profile, callback=self.gotContacts, errback=self.error) | 170 self.host.bridge.getContacts(profile_key=self.host.profile, callback=self.gotContacts, errback=self.error) |
174 | 171 |
175 def error(self, failure): | 172 def error(self, failure): |
176 print (_("Error while retrieving the contacts [%s]") % failure) | 173 print (_("Error while retrieving the contacts [%s]") % failure) |
177 self.host.quit(1) | 174 self.host.quit(1) |