# HG changeset patch # User Goffi # Date 1487707300 -3600 # Node ID c9a67eb5bf727ef21c6a34a0fbf3f7be0fd6cf04 # Parent 62dfa6e02f54a0e32aa0348d81aadf64f94963ad jp (base): improved module import: module import now display a warning were suitable on import issue diff -r 62dfa6e02f54 -r c9a67eb5bf72 frontends/src/jp/base.py --- a/frontends/src/jp/base.py Tue Feb 21 21:01:40 2017 +0100 +++ b/frontends/src/jp/base.py Tue Feb 21 21:01:40 2017 +0100 @@ -22,7 +22,7 @@ ### logging ### import logging as log log.basicConfig(level=log.DEBUG, - format='%(message)s') + format='%(message)s') ### import sys @@ -112,8 +112,8 @@ try: import progressbar except ImportError: - log.info (_(u'ProgressBar not available, please download it at http://pypi.python.org/pypi/progressbar')) - log.info (_(u'Progress bar deactivated\n--\n')) + log.warning(_(u'ProgressBar not available, please download it at http://pypi.python.org/pypi/progressbar')) + log.warning(_(u'Progress bar deactivated\n--\n')) progressbar=None #consts @@ -328,11 +328,19 @@ for type_, pattern in ((C.PLUGIN_OUTPUT, 'output_*.py'), (C.PLUGIN_CMD, 'cmd_*.py')): modules = (os.path.splitext(module)[0] for module in map(os.path.basename, iglob(os.path.join(path, pattern)))) for module_name in modules: - module = import_module("sat_frontends.jp."+module_name) + module_path = "sat_frontends.jp." + module_name try: + module = import_module(module_path) self.import_plugin_module(module, type_) except ImportError: + log.warning(_(u"Can't import {} plugin, ignoring it".format(module_path))) + except exceptions.CancelError: continue + except exceptions.MissingModule as e: + log.warning(_(u"Missing module for plugin {name}: {missing}".format( + name = module_path, + missing = e))) + def import_plugin_module(self, module, type_): """add commands or outpus from a module to jp