jp(info): devices command first draft:

this command gather data on known devices of an entity.
This commit is contained in:
Goffi 2020-03-06 18:19:03 +01:00
commit dced27f328
2 changed files with 27 additions and 2 deletions

View file

@ -58,6 +58,7 @@ v 0.8.0 « La Cecília » (NOT RELEASED YET):
- background colour detection
- new debug/theme command
- new file/get command (supports aesgcm scheme)
- new info/devices command
- file/upload handle encryption
- various improvments
- (blog) added --language to common publish arguments

View file

@ -20,7 +20,7 @@
from . import base
from sat.core.i18n import _
from sat.tools.common.ansi import ANSI as A
from sat.tools.common import date_utils
from sat.tools.common import date_utils, data_format
from sat_frontends.jp.constants import Const as C
from sat_frontends.jp import common
@ -225,8 +225,32 @@ class Session(base.CommandBase):
self.host.quit()
class Devices(base.CommandBase):
def __init__(self, host):
super(Devices, self).__init__(
host, 'devices', use_output=C.OUTPUT_LIST_DICT,
help=_('devices of an entity'))
def add_parser_options(self):
self.parser.add_argument(
"jid", type=str, nargs='?', default='', help=_("Entity to request"))
async def start(self):
try:
data = await self.host.bridge.devicesInfosGet(
self.args.jid, self.host.profile)
except Exception as e:
self.disp(_(f'Error getting devices infos: {e}'), error=True)
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
else:
data = data_format.deserialise(data, type_check=list)
await self.output(data)
self.host.quit()
class Info(base.CommandBase):
subcommands = (Disco, Version, Session)
subcommands = (Disco, Version, Session, Devices)
def __init__(self, host):
super(Info, self).__init__(