changeset 2492:fcf0ae8102b8

jp (profile/create): errback handling
author Goffi <goffi@goffi.org>
date Wed, 28 Feb 2018 18:28:39 +0100
parents 5895e4daae8c
children 984792a451bc
files frontends/src/jp/cmd_profile.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/jp/cmd_profile.py	Wed Feb 28 18:28:39 2018 +0100
+++ b/frontends/src/jp/cmd_profile.py	Wed Feb 28 18:28:39 2018 +0100
@@ -20,10 +20,12 @@
 """This module permits to manage profiles. It can list, create, delete
 and retrieve information about a profile."""
 
+from sat_frontends.jp.constants import Const as C
 from sat.core.log import getLogger
 log = getLogger(__name__)
 from sat.core.i18n import _
 from sat_frontends.jp import base
+from functools import partial
 
 __commands__ = ["Profile"]
 
@@ -167,7 +169,11 @@
         if self.args.profile in self.host.bridge.profilesListGet():
             log.error("Profile %s already exists." % self.args.profile)
             self.host.quit(1)
-        self.host.bridge.profileCreate(self.args.profile, self.args.password, self.args.component, callback=self._profile_created, errback=None)
+        self.host.bridge.profileCreate(self.args.profile, self.args.password, self.args.component,
+                                       callback=self._profile_created,
+                                       errback=partial(self.errback,
+                                                       msg=_(u"can't create profile: {}"),
+                                                       exit_code=C.EXIT_BRIDGE_ERRBACK))
 
 
 class ProfileModify(base.CommandBase):