jp (base): added exitCb generic callback to display a message and quit

This commit is contained in:
Goffi 2017-12-12 00:11:27 +01:00
commit d95aeb2bd3

View file

@ -779,6 +779,16 @@ class CommandBase(object):
raise exceptions.InternalError(_(u'trying to use output when use_output has not been set'))
return self.host.output(output_type, self.args.output, self.extra_outputs, data)
def exitCb(self, msg=None):
"""generic callback for success
optionally print a message, and quit
msg(None, unicode): if not None, print this message
"""
if msg is not None:
self.disp(msg)
self.host.quit(C.EXIT_OK)
def errback(self, failure_, msg=None, exit_code=C.EXIT_ERROR):
"""generic callback for errbacks