comparison frontends/src/jp/base.py @ 1544:3d5193b4c582

jp: separate password and connection of profile in --connect and --pwd arguments
author Goffi <goffi@goffi.org>
date Mon, 02 Nov 2015 22:02:41 +0100
parents 265ff2bd8d67
children 823a385235ef
comparison
equal deleted inserted replaced
1543:62596ec69bbd 1544:3d5193b4c582
109 def _make_parents(self): 109 def _make_parents(self):
110 self.parents = {} 110 self.parents = {}
111 111
112 profile_parent = self.parents['profile'] = argparse.ArgumentParser(add_help=False) 112 profile_parent = self.parents['profile'] = argparse.ArgumentParser(add_help=False)
113 profile_parent.add_argument("-p", "--profile", action="store", type=str, default='@DEFAULT@', help=_("Use PROFILE profile key (default: %(default)s)")) 113 profile_parent.add_argument("-p", "--profile", action="store", type=str, default='@DEFAULT@', help=_("Use PROFILE profile key (default: %(default)s)"))
114 profile_parent.add_argument("-c", "--connect", action="store", type=str, nargs='?', const='', default=None, metavar='PASSWORD', help=_("Connect the profile before doing anything else")) 114 profile_parent.add_argument("--pwd", action="store", type=unicode, default='', metavar='PASSWORD', help=_("Password used to connect profile, if necessary"))
115 profile_parent.add_argument("-c", "--connect", action="store_true", help=_("Connect the profile before doing anything else"))
115 116
116 progress_parent = self.parents['progress'] = argparse.ArgumentParser(add_help=False) 117 progress_parent = self.parents['progress'] = argparse.ArgumentParser(add_help=False)
117 if progressbar: 118 if progressbar:
118 progress_parent.add_argument("-P", "--progress", action="store_true", help=_("Show progress bar")) 119 progress_parent.add_argument("-P", "--progress", action="store_true", help=_("Show progress bar"))
119 120
241 242
242 if not hasattr(self.args, 'connect'): 243 if not hasattr(self.args, 'connect'):
243 # a profile can be presente without connect option (e.g. on profile creation/deletion) 244 # a profile can be presente without connect option (e.g. on profile creation/deletion)
244 return 245 return
245 elif self.args.connect is not None: # if connection is asked, we connect the profile 246 elif self.args.connect is not None: # if connection is asked, we connect the profile
246 self.bridge.asyncConnect(self.profile, self.args.connect, lambda dummy: callback(), cant_connect) 247 self.bridge.asyncConnect(self.profile, self.args.pwd, lambda dummy: callback(), cant_connect)
247 self._auto_loop = True 248 self._auto_loop = True
248 return 249 return
249 elif not self.bridge.isConnected(self.profile): 250 elif not self.bridge.isConnected(self.profile):
250 error(_(u"Profile [%(profile)s] is not connected, please connect it before using jp, or use --connect option") % { "profile": self.profile }) 251 error(_(u"Profile [%(profile)s] is not connected, please connect it before using jp, or use --connect option") % { "profile": self.profile })
251 self.quit(1) 252 self.quit(1)