comparison frontends/src/jp/base.py @ 1395:1ae9aa94c351

jp: fixed bad try/except hidding errors + fixed bad management of jids without node
author Goffi <goffi@goffi.org>
date Mon, 30 Mar 2015 10:04:29 +0200
parents faa1129559b8
children 069ad98b360d
comparison
equal deleted inserted replaced
1394:e3624cb3765d 1395:1ae9aa94c351
182 """ 182 """
183 names2jid = {} 183 names2jid = {}
184 nodes2jid = {} 184 nodes2jid = {}
185 185
186 for contact in self.bridge.getContacts(self.profile): 186 for contact in self.bridge.getContacts(self.profile):
187 _jid, attr, groups = contact 187 jid_s, attr, groups = contact
188 if attr.has_key("name"): 188 _jid = JID(jid_s)
189 names2jid[attr["name"].lower()] = _jid 189 try:
190 nodes2jid[JID(_jid).node.lower()] = _jid 190 names2jid[attr["name"].lower()] = jid_s
191 except KeyError:
192 pass
193
194 if _jid.node:
195 nodes2jid[_jid.node.lower()] = jid_s
191 196
192 def expand_jid(jid): 197 def expand_jid(jid):
193 _jid = jid.lower() 198 _jid = jid.lower()
194 if _jid in names2jid: 199 if _jid in names2jid:
195 expanded = names2jid[_jid] 200 expanded = names2jid[_jid]
354 cls(self) 359 cls(self)
355 360
356 def run(self): 361 def run(self):
357 try: 362 try:
358 if self.args.profile: 363 if self.args.profile:
359 self.host.connect_profile(self.connected) 364 connect_profile = self.host.connect_profile
360 except AttributeError: 365 except AttributeError:
361 # the command doesn't need to connect profile 366 # the command doesn't need to connect profile
362 pass 367 pass
368 else:
369 connect_profile(self.connected)
370
363 try: 371 try:
364 if self.args.progress: 372 if self.args.progress:
365 self.host.watch_progress() 373 watch_progress = self.host.watch_progress
366 except AttributeError: 374 except AttributeError:
367 # the command doesn't use progress bar 375 # the command doesn't use progress bar
368 pass 376 pass
377 else:
378 watch_progress()
369 379
370 def connected(self): 380 def connected(self):
371 if not self.need_loop: 381 if not self.need_loop:
372 self.host.stop_loop() 382 self.host.stop_loop()
373 383