Mercurial > libervia-backend
comparison frontends/src/jp/base.py @ 2178:b9bfc45cea22
jp (base): added generic errback to CommandBase + show error message on plugin ImportError
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 09 Mar 2017 23:09:18 +0100 |
parents | 255830fdb80b |
children | 4ec72927a222 |
comparison
equal
deleted
inserted
replaced
2177:09cfec4d8d19 | 2178:b9bfc45cea22 |
---|---|
330 for module_name in modules: | 330 for module_name in modules: |
331 module_path = "sat_frontends.jp." + module_name | 331 module_path = "sat_frontends.jp." + module_name |
332 try: | 332 try: |
333 module = import_module(module_path) | 333 module = import_module(module_path) |
334 self.import_plugin_module(module, type_) | 334 self.import_plugin_module(module, type_) |
335 except ImportError: | 335 except ImportError as e: |
336 log.warning(_(u"Can't import {} plugin, ignoring it".format(module_path))) | 336 log.warning(_(u"Can't import {module_path} plugin, ignoring it: {msg}".format( |
337 module_path = module_path, | |
338 msg = e))) | |
337 except exceptions.CancelError: | 339 except exceptions.CancelError: |
338 continue | 340 continue |
339 except exceptions.MissingModule as e: | 341 except exceptions.MissingModule as e: |
340 log.warning(_(u"Missing module for plugin {name}: {missing}".format( | 342 log.warning(_(u"Missing module for plugin {name}: {missing}".format( |
341 name = module_path, | 343 name = module_path, |
722 return self.host.disp(msg, verbosity, error) | 724 return self.host.disp(msg, verbosity, error) |
723 | 725 |
724 def output(self, data): | 726 def output(self, data): |
725 return self.host.output(self._output_type, self.args.output, self.extra_outputs, data) | 727 return self.host.output(self._output_type, self.args.output, self.extra_outputs, data) |
726 | 728 |
729 def errback(self, failure_): | |
730 """generic callback for errbacks | |
731 | |
732 display failure_ then quit with generic error | |
733 @param failure_: arguments returned by errback | |
734 """ | |
735 self.disp(u"error: {}".format(failure_), error=True) | |
736 self.host.quit(C.EXIT_ERROR) | |
737 | |
727 def add_parser_options(self): | 738 def add_parser_options(self): |
728 try: | 739 try: |
729 subcommands = self.subcommands | 740 subcommands = self.subcommands |
730 except AttributeError: | 741 except AttributeError: |
731 # We don't have subcommands, the class need to implements add_parser_options | 742 # We don't have subcommands, the class need to implements add_parser_options |