comparison frontends/src/jp/cmd_profile.py @ 1687:de9cc4d62a4a

jp (profile): fixed profile/modify command: - profile modify was resetting profile password if the option was not used - str types where used instead of unicode decoder - a new option allow to disable profile password (mutually exclusive with --password) - XMPP password was broken in a similar way as profile password
author Goffi <goffi@goffi.org>
date Thu, 26 Nov 2015 15:49:58 +0100
parents 91a605feed8c
children bc7e3ff3c838
comparison
equal deleted inserted replaced
1686:1ed269c5f295 1687:de9cc4d62a4a
141 class ProfileModify(base.CommandBase): 141 class ProfileModify(base.CommandBase):
142 def __init__(self, host): 142 def __init__(self, host):
143 super(ProfileModify, self).__init__(host, 'modify', need_connect=False, help=_('modify an existing profile')) 143 super(ProfileModify, self).__init__(host, 'modify', need_connect=False, help=_('modify an existing profile'))
144 144
145 def add_parser_options(self): 145 def add_parser_options(self):
146 self.parser.add_argument('-w', '--password', type=str, default='', help=_('the password of the profile')) 146 profile_pwd_group = self.parser.add_mutually_exclusive_group()
147 self.parser.add_argument('-j', '--jid', type=str, help=_('the jid of the profile')) 147 profile_pwd_group.add_argument('-w', '--password', type=base.unicode_decoder, help=_('change the password of the profile'))
148 self.parser.add_argument('-x', '--xmpp-password', type=str, help=_('the password of the XMPP account'), 148 profile_pwd_group.add_argument('--disable-password', action='store_true', help=_('disable profile password (dangerous!)'))
149 self.parser.add_argument('-j', '--jid', type=base.unicode_decoder, help=_('the jid of the profile'))
150 self.parser.add_argument('-x', '--xmpp-password', type=base.unicode_decoder, help=_('change the password of the XMPP account'),
149 metavar='PASSWORD') 151 metavar='PASSWORD')
150 self.parser.add_argument('-D', '--default', action='store_true', help=_(u'set as default profile')) 152 self.parser.add_argument('-D', '--default', action='store_true', help=_(u'set as default profile'))
151 153
152 def _profile_created(self):
153 if self.args.jid:
154 self.host.bridge.setParam("JabberID", self.args.jid, "Connection" ,profile_key=self.args.profile)
155 xmpp_pwd = self.args.password or self.args.xmpp_password
156 if xmpp_pwd:
157 self.host.bridge.setParam("Password", xmpp_pwd, "Connection", profile_key=self.args.profile)
158 self.host.quit()
159
160 def connected(self): 154 def connected(self):
161 super(ProfileModify, self).connected() 155 super(ProfileModify, self).connected()
156 if self.args.disable_password:
157 self.args.password = ''
162 if self.args.password is not None: 158 if self.args.password is not None:
163 self.host.bridge.setParam("Password", self.args.password, "General", profile_key=self.host.profile) 159 self.host.bridge.setParam("Password", self.args.password, "General", profile_key=self.host.profile)
164 if self.args.jid is not None: 160 if self.args.jid is not None:
165 self.host.bridge.setParam("JabberID", self.args.jid, "Connection", profile_key=self.host.profile) 161 self.host.bridge.setParam("JabberID", self.args.jid, "Connection", profile_key=self.host.profile)
166 if self.args.xmpp_password is not None: 162 if self.args.xmpp_password is not None: