Mercurial > libervia-backend
diff frontends/src/jp/cmd_info.py @ 2114:dc5d214f0a3b
jp (info/session): added a command to get data on current session
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 05 Jan 2017 22:22:26 +0100 |
parents | 3e168cde7a7d |
children | fff88c33442f |
line wrap: on
line diff
--- a/frontends/src/jp/cmd_info.py Thu Jan 05 22:22:13 2017 +0100 +++ b/frontends/src/jp/cmd_info.py Thu Jan 05 22:22:26 2017 +0100 @@ -19,6 +19,7 @@ import base from sat.core.i18n import _ +from sat_frontends.jp.constants import Const as C __commands__ = ["Info"] @@ -26,11 +27,11 @@ class Disco(base.CommandBase): def __init__(self, host): - super(Disco, self).__init__(host, 'disco', help=_('Service discovery')) + super(Disco, self).__init__(host, 'disco', help=_('service discovery')) self.need_loop=True def add_parser_options(self): - self.parser.add_argument("jid", type=str, help=_("Entity to discover")) + self.parser.add_argument("jid", type=str, help=_("entity to discover")) def start(self): jids = self.host.check_jids([self.args.jid]) @@ -104,7 +105,7 @@ class Version(base.CommandBase): def __init__(self, host): - super(Version, self).__init__(host, 'version', help=_('Client version')) + super(Version, self).__init__(host, 'version', help=_('running session')) self.need_loop=True def add_parser_options(self): @@ -133,8 +134,29 @@ self.host.quit() +class Session(base.CommandBase): + + def __init__(self, host): + super(Session, self).__init__(host, 'session', use_output='dict', help=_('client version')) + self.need_loop=True + + def add_parser_options(self): + pass + + def start(self): + self.host.bridge.sessionInfosGet(self.host.profile, callback=self._sessionInfoGetCb, errback=self._sessionInfoGetEb) + + def _sessionInfoGetCb(self, data): + self.output(data) + self.host.quit() + + def _sessionInfoGetEb(self, error_data): + self.disp(_(u'Error getting session infos: {}').format(error_data), error=True) + self.host.quit(C.EXIT_BRIDGE_ERRBACK) + + class Info(base.CommandBase): - subcommands = (Disco, Version) + subcommands = (Disco, Version, Session) def __init__(self, host): super(Info, self).__init__(host, 'info', use_profile=False, help=_('Get various pieces of information on entities'))