Mercurial > libervia-backend
comparison frontends/src/jp/cmd_info.py @ 2151:fff88c33442f
jp (info/disco): added --node argument
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 12 Feb 2017 21:17:56 +0100 |
parents | dc5d214f0a3b |
children | 4fd499d14b27 |
comparison
equal
deleted
inserted
replaced
2150:91347fe95384 | 2151:fff88c33442f |
---|---|
29 def __init__(self, host): | 29 def __init__(self, host): |
30 super(Disco, self).__init__(host, 'disco', help=_('service discovery')) | 30 super(Disco, self).__init__(host, 'disco', help=_('service discovery')) |
31 self.need_loop=True | 31 self.need_loop=True |
32 | 32 |
33 def add_parser_options(self): | 33 def add_parser_options(self): |
34 self.parser.add_argument("jid", type=str, help=_("entity to discover")) | 34 self.parser.add_argument(u"jid", type=base.unicode_decoder, help=_(u"entity to discover")) |
35 self.parser.add_argument(u"-n", u"--node", type=base.unicode_decoder, default=u'', help=_(u"node to use")) | |
35 | 36 |
36 def start(self): | 37 def start(self): |
37 jids = self.host.check_jids([self.args.jid]) | 38 jids = self.host.check_jids([self.args.jid]) |
38 jid = jids[0] | 39 jid = jids[0] |
39 self.host.bridge.discoInfos(jid, profile_key=self.host.profile, callback=lambda infos: self.gotInfos(infos, jid), errback=self.error) | 40 self.host.bridge.discoInfos(jid, node=self.args.node, profile_key=self.host.profile, callback=lambda infos: self.gotInfos(infos, jid), errback=self.error) |
40 | 41 |
41 def error(self, failure): | 42 def error(self, failure): |
42 print (_("Error while doing discovery [%s]") % failure) | 43 print (_("Error while doing discovery [%s]") % failure) |
43 self.host.quit(1) | 44 self.host.quit(1) |
44 | 45 |
45 def gotInfos(self, infos, jid): | 46 def gotInfos(self, infos, jid): |
46 self.host.bridge.discoItems(jid, profile_key=self.host.profile, callback=lambda items: self.gotItems(infos, items), errback=self.error) | 47 self.host.bridge.discoItems(jid, node=self.args.node, profile_key=self.host.profile, callback=lambda items: self.gotItems(infos, items), errback=self.error) |
47 | 48 |
48 def gotItems(self, infos, items): | 49 def gotItems(self, infos, items): |
49 features, identities, extensions = infos | 50 features, identities, extensions = infos |
50 features.sort() | 51 features.sort() |
51 identities.sort(key=lambda identity: identity[2]) | 52 identities.sort(key=lambda identity: identity[2]) |