From e67b4bd9eb0b4aa665f6031db8c8a8247513107c Mon Sep 17 00:00:00 2001 From: Goffi Date: Mon, 30 Mar 2015 10:04:29 +0200 Subject: [PATCH] jp: fixed bad try/except hidding errors + fixed bad management of jids without node --- frontends/src/jp/base.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/frontends/src/jp/base.py b/frontends/src/jp/base.py index 401ae954..20a868e6 100644 --- a/frontends/src/jp/base.py +++ b/frontends/src/jp/base.py @@ -184,10 +184,15 @@ class Jp(object): nodes2jid = {} for contact in self.bridge.getContacts(self.profile): - _jid, attr, groups = contact - if attr.has_key("name"): - names2jid[attr["name"].lower()] = _jid - nodes2jid[JID(_jid).node.lower()] = _jid + jid_s, attr, groups = contact + _jid = JID(jid_s) + try: + names2jid[attr["name"].lower()] = jid_s + except KeyError: + pass + + if _jid.node: + nodes2jid[_jid.node.lower()] = jid_s def expand_jid(jid): _jid = jid.lower() @@ -356,16 +361,21 @@ class CommandBase(object): def run(self): try: if self.args.profile: - self.host.connect_profile(self.connected) + connect_profile = self.host.connect_profile except AttributeError: # the command doesn't need to connect profile pass + else: + connect_profile(self.connected) + try: if self.args.progress: - self.host.watch_progress() + watch_progress = self.host.watch_progress except AttributeError: # the command doesn't use progress bar pass + else: + watch_progress() def connected(self): if not self.need_loop: