Mercurial > libervia-backend
diff sat_frontends/jp/cmd_debug.py @ 3573:813595f88612
merge changes from main branch
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 17 Jun 2021 13:05:58 +0200 |
parents | 04283582966f |
children | 691dbd78981c |
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_debug.py Thu Jun 03 15:21:43 2021 +0200 +++ b/sat_frontends/jp/cmd_debug.py Thu Jun 17 13:05:58 2021 +0200 @@ -53,20 +53,19 @@ self.parser.add_argument( "method", type=str, help=_("name of the method to execute") ) - self.parser.add_argument( - "arg", nargs="*", help=_("argument of the method") - ) + self.parser.add_argument("arg", nargs="*", help=_("argument of the method")) async def start(self): method = getattr(self.host.bridge, self.args.method) import inspect + argspec = inspect.getargspec(method) kwargs = {} - if 'profile_key' in argspec.args: - kwargs['profile_key'] = self.profile - elif 'profile' in argspec.args: - kwargs['profile'] = self.profile + if "profile_key" in argspec.args: + kwargs["profile_key"] = self.profile + elif "profile" in argspec.args: + kwargs["profile"] = self.profile args = self.evalArgs() @@ -76,7 +75,12 @@ **kwargs, ) except Exception as e: - self.disp(_(f"Error while executing {self.args.method}: {e}"), error=True) + self.disp( + _("Error while executing {method}: {e}").format( + method=self.args.method, e=e + ), + error=True, + ) self.host.quit(C.EXIT_ERROR) else: if ret is not None: @@ -92,12 +96,8 @@ BridgeCommon.__init__(self) def add_parser_options(self): - self.parser.add_argument( - "signal", type=str, help=_("name of the signal to send") - ) - self.parser.add_argument( - "arg", nargs="*", help=_("argument of the signal") - ) + self.parser.add_argument("signal", type=str, help=_("name of the signal to send")) + self.parser.add_argument("arg", nargs="*", help=_("argument of the signal")) async def start(self): args = self.evalArgs() @@ -105,9 +105,11 @@ # XXX: we use self.args.profile and not self.profile # because we want the raw profile_key (so plugin handle C.PROF_KEY_NONE) try: - await self.host.bridge.debugFakeSignal(self.args.signal, json_args, self.args.profile) + await self.host.bridge.debugFakeSignal( + self.args.signal, json_args, self.args.profile + ) except Exception as e: - self.disp(_(f"Can't send fake signal: {e}"), error=True) + self.disp(_("Can't send fake signal: {e}").format(e=e), error=True) self.host.quit(C.EXIT_ERROR) else: self.host.quit() @@ -198,18 +200,17 @@ async def start(self): for attr in dir(C): - if not attr.startswith('A_'): + if not attr.startswith("A_"): continue color = getattr(C, attr) - if attr == 'A_LEVEL_COLORS': + if attr == "A_LEVEL_COLORS": # This constant contains multiple colors - self.disp('LEVEL COLORS: ', end=' ') + self.disp("LEVEL COLORS: ", end=" ") for idx, c in enumerate(color): - last = idx == len(color)-1 - end = '\n' if last else ' ' + last = idx == len(color) - 1 + end = "\n" if last else " " self.disp( - c + f'LEVEL_{idx}' + A.RESET + (', ' if not last else ''), - end=end + c + f"LEVEL_{idx}" + A.RESET + (", " if not last else ""), end=end ) else: text = attr[2:]