Mercurial > libervia-backend
comparison frontends/src/jp/cmd_profile.py @ 2492:fcf0ae8102b8
jp (profile/create): errback handling
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 28 Feb 2018 18:28:39 +0100 |
parents | 0046283a285d |
children |
comparison
equal
deleted
inserted
replaced
2491:5895e4daae8c | 2492:fcf0ae8102b8 |
---|---|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 """This module permits to manage profiles. It can list, create, delete | 20 """This module permits to manage profiles. It can list, create, delete |
21 and retrieve information about a profile.""" | 21 and retrieve information about a profile.""" |
22 | 22 |
23 from sat_frontends.jp.constants import Const as C | |
23 from sat.core.log import getLogger | 24 from sat.core.log import getLogger |
24 log = getLogger(__name__) | 25 log = getLogger(__name__) |
25 from sat.core.i18n import _ | 26 from sat.core.i18n import _ |
26 from sat_frontends.jp import base | 27 from sat_frontends.jp import base |
28 from functools import partial | |
27 | 29 |
28 __commands__ = ["Profile"] | 30 __commands__ = ["Profile"] |
29 | 31 |
30 PROFILE_HELP = _('The name of the profile') | 32 PROFILE_HELP = _('The name of the profile') |
31 | 33 |
165 def start(self): | 167 def start(self): |
166 """Create a new profile""" | 168 """Create a new profile""" |
167 if self.args.profile in self.host.bridge.profilesListGet(): | 169 if self.args.profile in self.host.bridge.profilesListGet(): |
168 log.error("Profile %s already exists." % self.args.profile) | 170 log.error("Profile %s already exists." % self.args.profile) |
169 self.host.quit(1) | 171 self.host.quit(1) |
170 self.host.bridge.profileCreate(self.args.profile, self.args.password, self.args.component, callback=self._profile_created, errback=None) | 172 self.host.bridge.profileCreate(self.args.profile, self.args.password, self.args.component, |
173 callback=self._profile_created, | |
174 errback=partial(self.errback, | |
175 msg=_(u"can't create profile: {}"), | |
176 exit_code=C.EXIT_BRIDGE_ERRBACK)) | |
171 | 177 |
172 | 178 |
173 class ProfileModify(base.CommandBase): | 179 class ProfileModify(base.CommandBase): |
174 def __init__(self, host): | 180 def __init__(self, host): |
175 super(ProfileModify, self).__init__(host, 'modify', need_connect=False, help=_(u'modify an existing profile')) | 181 super(ProfileModify, self).__init__(host, 'modify', need_connect=False, help=_(u'modify an existing profile')) |