comparison frontends/src/jp/cmd_profile.py @ 1403:f913b09cd9cc

jp (profile): in "profile create", jid and password arguments are now optional + added a new --xmpp-password option to set XMPP password separately (default to the same password as for profile).
author Goffi <goffi@goffi.org>
date Mon, 06 Apr 2015 17:36:21 +0200
parents 391b0c21f4be
children e4e960d285b0
comparison
equal deleted inserted replaced
1402:391b0c21f4be 1403:f913b09cd9cc
91 def __init__(self, host): 91 def __init__(self, host):
92 super(ProfileCreate, self).__init__(host, 'create', use_profile=False, help=_('Create a new profile')) 92 super(ProfileCreate, self).__init__(host, 'create', use_profile=False, help=_('Create a new profile'))
93 93
94 def add_parser_options(self): 94 def add_parser_options(self):
95 self.parser.add_argument('profile', type=str, help=_('the name of the profile')) 95 self.parser.add_argument('profile', type=str, help=_('the name of the profile'))
96 self.parser.add_argument('jid', type=str, help=_('the jid of the profile')) 96 self.parser.add_argument('-p', '--password', type=str, default='', help=_('the password of the profile'))
97 self.parser.add_argument('password', type=str, help=_('the password of the profile')) 97 self.parser.add_argument('-j', '--jid', type=str, help=_('the jid of the profile'))
98 self.parser.add_argument('-x', '--xmpp-password', type=str, help=_('the password of the XMPP account (use profile password if not specified)'),
99 metavar='PASSWORD')
98 100
99 def _profile_created(self): 101 def _profile_created(self):
100 self.host.bridge.setParam("JabberID", self.args.jid, "Connection" ,profile_key=self.args.profile) 102 if self.args.jid:
101 self.host.bridge.setParam("Password", self.args.password, "Connection", profile_key=self.args.profile) 103 self.host.bridge.setParam("JabberID", self.args.jid, "Connection" ,profile_key=self.args.profile)
104 xmpp_pwd = self.args.password or self.args.xmpp_password
105 if xmpp_pwd:
106 self.host.bridge.setParam("Password", xmpp_pwd, "Connection", profile_key=self.args.profile)
102 self.host.quit() 107 self.host.quit()
103 108
104 def run(self): 109 def run(self):
105 """Create a new profile""" 110 """Create a new profile"""
106 self.need_loop = True 111 self.need_loop = True
107 if self.args.profile in self.host.bridge.getProfilesList(): 112 if self.args.profile in self.host.bridge.getProfilesList():
108 error("Profile %s already exists." % self.args.profile) 113 error("Profile %s already exists." % self.args.profile)
109 self.host.quit(1) 114 self.host.quit(1)
110 self.host.bridge.asyncCreateProfile(self.args.profile, callback=self._profile_created, errback=None) 115 self.host.bridge.asyncCreateProfile(self.args.profile, self.args.password, callback=self._profile_created, errback=None)
111 116
112 117
113 class Profile(base.CommandBase): 118 class Profile(base.CommandBase):
114 subcommands = (ProfileDelete, ProfileInfo, ProfileList, ProfileCreate) 119 subcommands = (ProfileDelete, ProfileInfo, ProfileList, ProfileCreate)
115 120