Mercurial > libervia-backend
comparison frontends/src/jp/cmd_profile.py @ 1597:91a605feed8c
jp: added profile/connect command
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 14 Nov 2015 19:19:04 +0100 |
parents | b7ee113183fc |
children | de9cc4d62a4a |
comparison
equal
deleted
inserted
replaced
1596:b7ee113183fc | 1597:91a605feed8c |
---|---|
25 from sat_frontends.jp import base | 25 from sat_frontends.jp import base |
26 | 26 |
27 __commands__ = ["Profile"] | 27 __commands__ = ["Profile"] |
28 | 28 |
29 PROFILE_HELP = _('The name of the profile') | 29 PROFILE_HELP = _('The name of the profile') |
30 | |
31 | |
32 class ProfileConnect(base.CommandBase): | |
33 """Dummy command to use profile_session parent, i.e. to be able to connect without doing anything else""" | |
34 | |
35 def __init__(self, host): | |
36 # it's weird to have a command named "connect" with need_connect=False, but it can be handy to be able | |
37 # to launch just the session, so some paradox don't hurt | |
38 super(ProfileConnect, self).__init__(host, 'connect', need_connect=False, help=_('connect a profile')) | |
39 | |
40 def add_parser_options(self): | |
41 pass | |
30 | 42 |
31 | 43 |
32 class ProfileDefault(base.CommandBase): | 44 class ProfileDefault(base.CommandBase): |
33 def __init__(self, host): | 45 def __init__(self, host): |
34 super(ProfileDefault, self).__init__(host, 'default', use_profile=False, help=_('print default profile')) | 46 super(ProfileDefault, self).__init__(host, 'default', use_profile=False, help=_('print default profile')) |
98 print profile | 110 print profile |
99 | 111 |
100 | 112 |
101 class ProfileCreate(base.CommandBase): | 113 class ProfileCreate(base.CommandBase): |
102 def __init__(self, host): | 114 def __init__(self, host): |
103 super(ProfileCreate, self).__init__(host, 'create', use_profile=False, help=_('Create a new profile')) | 115 super(ProfileCreate, self).__init__(host, 'create', use_profile=False, help=_('create a new profile')) |
104 | 116 |
105 def add_parser_options(self): | 117 def add_parser_options(self): |
106 self.parser.add_argument('profile', type=str, help=_('the name of the profile')) | 118 self.parser.add_argument('profile', type=str, help=_('the name of the profile')) |
107 self.parser.add_argument('-p', '--password', type=str, default='', help=_('the password of the profile')) | 119 self.parser.add_argument('-p', '--password', type=str, default='', help=_('the password of the profile')) |
108 self.parser.add_argument('-j', '--jid', type=str, help=_('the jid of the profile')) | 120 self.parser.add_argument('-j', '--jid', type=str, help=_('the jid of the profile')) |
126 self.host.bridge.asyncCreateProfile(self.args.profile, self.args.password, callback=self._profile_created, errback=None) | 138 self.host.bridge.asyncCreateProfile(self.args.profile, self.args.password, callback=self._profile_created, errback=None) |
127 | 139 |
128 | 140 |
129 class ProfileModify(base.CommandBase): | 141 class ProfileModify(base.CommandBase): |
130 def __init__(self, host): | 142 def __init__(self, host): |
131 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')) |
132 | 144 |
133 def add_parser_options(self): | 145 def add_parser_options(self): |
134 self.parser.add_argument('-w', '--password', type=str, default='', help=_('the password of the profile')) | 146 self.parser.add_argument('-w', '--password', type=str, default='', help=_('the password of the profile')) |
135 self.parser.add_argument('-j', '--jid', type=str, help=_('the jid of the profile')) | 147 self.parser.add_argument('-j', '--jid', type=str, help=_('the jid of the profile')) |
136 self.parser.add_argument('-x', '--xmpp-password', type=str, help=_('the password of the XMPP account'), | 148 self.parser.add_argument('-x', '--xmpp-password', type=str, help=_('the password of the XMPP account'), |
156 if self.args.default: | 168 if self.args.default: |
157 self.host.bridge.profileSetDefault(self.host.profile) | 169 self.host.bridge.profileSetDefault(self.host.profile) |
158 | 170 |
159 | 171 |
160 class Profile(base.CommandBase): | 172 class Profile(base.CommandBase): |
161 subcommands = (ProfileCreate, ProfileDefault, ProfileDelete, ProfileInfo, ProfileList, ProfileModify) | 173 subcommands = (ProfileConnect, ProfileCreate, ProfileDefault, ProfileDelete, ProfileInfo, ProfileList, ProfileModify) |
162 | 174 |
163 def __init__(self, host): | 175 def __init__(self, host): |
164 super(Profile, self).__init__(host, 'profile', use_profile=False, help=_('Profile commands')) | 176 super(Profile, self).__init__(host, 'profile', use_profile=False, help=_('Profile commands')) |