From dced27f328104bc4ae6c748c3c409098d3081262 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 6 Mar 2020 18:19:03 +0100 Subject: [PATCH] jp(info): `devices` command first draft: this command gather data on known devices of an entity. --- CHANGELOG | 1 + sat_frontends/jp/cmd_info.py | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b2f5c6cb..1ace18d1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/sat_frontends/jp/cmd_info.py b/sat_frontends/jp/cmd_info.py index 32bd3507..81704731 100644 --- a/sat_frontends/jp/cmd_info.py +++ b/sat_frontends/jp/cmd_info.py @@ -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__(