Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_roster.py @ 3414:ffe7a6d6018a
jp (roster): `delete` implementation
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 12 Nov 2020 14:53:16 +0100 |
parents | f30b238d9c45 |
children | be6d91572633 |
comparison
equal
deleted
inserted
replaced
3413:f4d417593e77 | 3414:ffe7a6d6018a |
---|---|
119 try: | 119 try: |
120 await self.host.bridge.updateContact( | 120 await self.host.bridge.updateContact( |
121 self.args.jid, name, groups, self.host.profile) | 121 self.args.jid, name, groups, self.host.profile) |
122 except Exception as e: | 122 except Exception as e: |
123 self.disp(f"error while updating the contact: {e}", error=True) | 123 self.disp(f"error while updating the contact: {e}", error=True) |
124 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
125 self.host.quit() | |
126 | |
127 | |
128 class Delete(base.CommandBase): | |
129 | |
130 def __init__(self, host): | |
131 super().__init__(host, 'delete', help=_('remove an entity from roster')) | |
132 | |
133 def add_parser_options(self): | |
134 self.parser.add_argument( | |
135 "-f", "--force", action="store_true", help=_("delete without confirmation") | |
136 ) | |
137 self.parser.add_argument( | |
138 "jid", help=_("jid of the roster entity")) | |
139 | |
140 async def start(self): | |
141 if not self.args.force: | |
142 message = _("Are you sure to delete {entity} fril your roster?").format( | |
143 entity=self.args.jid | |
144 ) | |
145 await self.host.confirmOrQuit(message, _("entity deletion cancelled")) | |
146 try: | |
147 await self.host.bridge.delContact( | |
148 self.args.jid, self.host.profile) | |
149 except Exception as e: | |
150 self.disp(f"error while deleting the entity: {e}", error=True) | |
124 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 151 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
125 self.host.quit() | 152 self.host.quit() |
126 | 153 |
127 | 154 |
128 class Stats(base.CommandBase): | 155 class Stats(base.CommandBase): |
291 self.disp(_("Roster resynchronized")) | 318 self.disp(_("Roster resynchronized")) |
292 self.host.quit(C.EXIT_OK) | 319 self.host.quit(C.EXIT_OK) |
293 | 320 |
294 | 321 |
295 class Roster(base.CommandBase): | 322 class Roster(base.CommandBase): |
296 subcommands = (Get, Set, Stats, Purge, Resync) | 323 subcommands = (Get, Set, Delete, Stats, Purge, Resync) |
297 | 324 |
298 def __init__(self, host): | 325 def __init__(self, host): |
299 super(Roster, self).__init__( | 326 super(Roster, self).__init__( |
300 host, 'roster', use_profile=True, help=_("Manage an entity's roster")) | 327 host, 'roster', use_profile=True, help=_("Manage an entity's roster")) |