comparison frontends/src/jp/cmd_info.py @ 2343:ca1ab42c7ae9

jp (info/disco): added --no-cache option
author Goffi <goffi@goffi.org>
date Tue, 22 Aug 2017 22:13:22 +0200
parents 4fd499d14b27
children c903c259402a
comparison
equal deleted inserted replaced
2342:f047d5410040 2343:ca1ab42c7ae9
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(u"jid", type=base.unicode_decoder, help=_(u"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 self.parser.add_argument(u"-n", u"--node", type=base.unicode_decoder, default=u'', help=_(u"node to use"))
36 self.parser.add_argument(u"-C", u"--no-cache", dest='use_cache', action="store_false", help=_(u"ignore cache"))
36 37
37 def start(self): 38 def start(self):
38 jids = self.host.check_jids([self.args.jid]) 39 jids = self.host.check_jids([self.args.jid])
39 jid = jids[0] 40 jid = jids[0]
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) 41 self.host.bridge.discoInfos(jid, node=self.args.node, use_cache=self.args.use_cache, profile_key=self.host.profile, callback=lambda infos: self.gotInfos(infos, jid), errback=self.error)
41 42
42 def error(self, failure): 43 def error(self, failure):
43 print (_("Error while doing discovery [%s]") % failure) 44 print (_("Error while doing discovery [%s]") % failure)
44 self.host.quit(1) 45 self.host.quit(1)
45 46
46 def gotInfos(self, infos, jid): 47 def gotInfos(self, infos, jid):
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) 48 self.host.bridge.discoItems(jid, node=self.args.node, use_cache=self.args.use_cache, profile_key=self.host.profile, callback=lambda items: self.gotItems(infos, items), errback=self.error)
48 49
49 def gotItems(self, infos, items): 50 def gotItems(self, infos, items):
50 features, identities, extensions = infos 51 features, identities, extensions = infos
51 features.sort() 52 features.sort()
52 identities.sort(key=lambda identity: identity[2]) 53 identities.sort(key=lambda identity: identity[2])