comparison frontends/src/jp/base.py @ 1401:265ff2bd8d67

jp: fixed crash on commands using profile without "connect" option
author Goffi <goffi@goffi.org>
date Mon, 06 Apr 2015 12:11:23 +0200
parents 069ad98b360d
children 3d5193b4c582
comparison
equal deleted inserted replaced
1400:c8459b53bb81 1401:265ff2bd8d67
219 219
220 return dest_jids 220 return dest_jids
221 221
222 def connect_profile(self, callback): 222 def connect_profile(self, callback):
223 """ Check if the profile is connected 223 """ Check if the profile is connected
224
224 @param callback: method to call when profile is connected 225 @param callback: method to call when profile is connected
225 @exit: - 1 when profile is not connected and --connect is not set 226 @exit: - 1 when profile is not connected and --connect is not set
226 - 1 when the profile doesn't exists 227 - 1 when the profile doesn't exists
227 - 1 when there is a connection error 228 - 1 when there is a connection error
228 """ 229 """
236 237
237 if not self.profile: 238 if not self.profile:
238 error(_("The profile [%s] doesn't exist") % self.args.profile) 239 error(_("The profile [%s] doesn't exist") % self.args.profile)
239 self.quit(1) 240 self.quit(1)
240 241
241 if self.args.connect is not None: # if connection is asked, we connect the profile 242 if not hasattr(self.args, 'connect'):
243 # a profile can be presente without connect option (e.g. on profile creation/deletion)
244 return
245 elif self.args.connect is not None: # if connection is asked, we connect the profile
242 self.bridge.asyncConnect(self.profile, self.args.connect, lambda dummy: callback(), cant_connect) 246 self.bridge.asyncConnect(self.profile, self.args.connect, lambda dummy: callback(), cant_connect)
243 self._auto_loop = True 247 self._auto_loop = True
244 return 248 return
245
246 elif not self.bridge.isConnected(self.profile): 249 elif not self.bridge.isConnected(self.profile):
247 error(_(u"Profile [%(profile)s] is not connected, please connect it before using jp, or use --connect option") % { "profile": self.profile }) 250 error(_(u"Profile [%(profile)s] is not connected, please connect it before using jp, or use --connect option") % { "profile": self.profile })
248 self.quit(1) 251 self.quit(1)
249 252
250 callback() 253 callback()