comparison frontends/src/jp/cmd_profile.py @ 1404:e4e960d285b0

jp (profile): added "profile modify" command
author Goffi <goffi@goffi.org>
date Mon, 06 Apr 2015 17:36:53 +0200
parents f913b09cd9cc
children b7ee113183fc
comparison
equal deleted inserted replaced
1403:f913b09cd9cc 1404:e4e960d285b0
113 error("Profile %s already exists." % self.args.profile) 113 error("Profile %s already exists." % self.args.profile)
114 self.host.quit(1) 114 self.host.quit(1)
115 self.host.bridge.asyncCreateProfile(self.args.profile, self.args.password, callback=self._profile_created, errback=None) 115 self.host.bridge.asyncCreateProfile(self.args.profile, self.args.password, callback=self._profile_created, errback=None)
116 116
117 117
118 class ProfileModify(base.CommandBase):
119 def __init__(self, host):
120 super(ProfileModify, self).__init__(host, 'modify', help=_('Modify an existing profile'))
121
122 def add_parser_options(self):
123 self.parser.add_argument('-w', '--password', type=str, default='', help=_('the password of the profile'))
124 self.parser.add_argument('-j', '--jid', type=str, help=_('the jid of the profile'))
125 self.parser.add_argument('-x', '--xmpp-password', type=str, help=_('the password of the XMPP account'),
126 metavar='PASSWORD')
127
128 def _profile_created(self):
129 if self.args.jid:
130 self.host.bridge.setParam("JabberID", self.args.jid, "Connection" ,profile_key=self.args.profile)
131 xmpp_pwd = self.args.password or self.args.xmpp_password
132 if xmpp_pwd:
133 self.host.bridge.setParam("Password", xmpp_pwd, "Connection", profile_key=self.args.profile)
134 self.host.quit()
135
136 def connected(self):
137 super(ProfileModify, self).connected()
138 if self.args.password is not None:
139 self.host.bridge.setParam("Password", self.args.password, "General", profile_key=self.host.profile)
140 if self.args.jid is not None:
141 self.host.bridge.setParam("JabberID", self.args.jid, "Connection", profile_key=self.host.profile)
142 if self.args.xmpp_password is not None:
143 self.host.bridge.setParam("Password", self.args.xmpp_password, "Connection", profile_key=self.host.profile)
144
145
118 class Profile(base.CommandBase): 146 class Profile(base.CommandBase):
119 subcommands = (ProfileDelete, ProfileInfo, ProfileList, ProfileCreate) 147 subcommands = (ProfileDelete, ProfileInfo, ProfileList, ProfileCreate, ProfileModify)
120 148
121 def __init__(self, host): 149 def __init__(self, host):
122 super(Profile, self).__init__(host, 'profile', use_profile=False, help=_('Profile commands')) 150 super(Profile, self).__init__(host, 'profile', use_profile=False, help=_('Profile commands'))