comparison frontends/src/jp/base.py @ 2457:49aa1e3a90b8

jp (base): added exitCb generic callback to display a message and quit
author Goffi <goffi@goffi.org>
date Tue, 12 Dec 2017 00:11:27 +0100
parents 8b37a62336c3
children 0046283a285d
comparison
equal deleted inserted replaced
2456:83f9b9ff1a54 2457:49aa1e3a90b8
777 output_type = self._output_type 777 output_type = self._output_type
778 except AttributeError: 778 except AttributeError:
779 raise exceptions.InternalError(_(u'trying to use output when use_output has not been set')) 779 raise exceptions.InternalError(_(u'trying to use output when use_output has not been set'))
780 return self.host.output(output_type, self.args.output, self.extra_outputs, data) 780 return self.host.output(output_type, self.args.output, self.extra_outputs, data)
781 781
782 def exitCb(self, msg=None):
783 """generic callback for success
784
785 optionally print a message, and quit
786 msg(None, unicode): if not None, print this message
787 """
788 if msg is not None:
789 self.disp(msg)
790 self.host.quit(C.EXIT_OK)
791
782 def errback(self, failure_, msg=None, exit_code=C.EXIT_ERROR): 792 def errback(self, failure_, msg=None, exit_code=C.EXIT_ERROR):
783 """generic callback for errbacks 793 """generic callback for errbacks
784 794
785 display failure_ then quit with generic error 795 display failure_ then quit with generic error
786 @param failure_: arguments returned by errback 796 @param failure_: arguments returned by errback