comparison frontends/src/jp/base.py @ 2188:052d560d0dce

jp (base): replaced log.warning by stderr prints
author Goffi <goffi@goffi.org>
date Sun, 12 Mar 2017 23:32:43 +0100
parents 4ec72927a222
children a25a256688e2
comparison
equal deleted inserted replaced
2187:4ec72927a222 2188:052d560d0dce
110 shlex.split = new_split 110 shlex.split = new_split
111 111
112 try: 112 try:
113 import progressbar 113 import progressbar
114 except ImportError: 114 except ImportError:
115 log.warning(_(u'ProgressBar not available, please download it at http://pypi.python.org/pypi/progressbar')) 115 msg = (_(u'ProgressBar not available, please download it at http://pypi.python.org/pypi/progressbar\n') +
116 log.warning(_(u'Progress bar deactivated\n--\n')) 116 _(u'Progress bar deactivated\n--\n'))
117 print >>sys.stderr,msg.encode('utf-8')
117 progressbar=None 118 progressbar=None
118 119
119 #consts 120 #consts
120 PROG_NAME = u"jp" 121 PROG_NAME = u"jp"
121 DESCRIPTION = """This software is a command line tool for XMPP. 122 DESCRIPTION = """This software is a command line tool for XMPP.
349 module_path = "sat_frontends.jp." + module_name 350 module_path = "sat_frontends.jp." + module_name
350 try: 351 try:
351 module = import_module(module_path) 352 module = import_module(module_path)
352 self.import_plugin_module(module, type_) 353 self.import_plugin_module(module, type_)
353 except ImportError as e: 354 except ImportError as e:
354 log.warning(_(u"Can't import {module_path} plugin, ignoring it: {msg}".format( 355 self.disp(_(u"Can't import {module_path} plugin, ignoring it: {msg}".format(
355 module_path = module_path, 356 module_path = module_path,
356 msg = e))) 357 msg = e)), error=True)
357 except exceptions.CancelError: 358 except exceptions.CancelError:
358 continue 359 continue
359 except exceptions.MissingModule as e: 360 except exceptions.MissingModule as e:
360 log.warning(_(u"Missing module for plugin {name}: {missing}".format( 361 self.disp(_(u"Missing module for plugin {name}: {missing}".format(
361 name = module_path, 362 name = module_path,
362 missing = e))) 363 missing = e)), error=True)
363 364
364 365
365 def import_plugin_module(self, module, type_): 366 def import_plugin_module(self, module, type_):
366 """add commands or outpus from a module to jp 367 """add commands or outpus from a module to jp
367 368
369 @param type_(str): one of C_PLUGIN_* 370 @param type_(str): one of C_PLUGIN_*
370 """ 371 """
371 try: 372 try:
372 class_names = getattr(module, '__{}__'.format(type_)) 373 class_names = getattr(module, '__{}__'.format(type_))
373 except AttributeError: 374 except AttributeError:
374 log.warning(_("Invalid plugin module [{type}] {module}").format(type=type_, module=module)) 375 log.disp(_(u"Invalid plugin module [{type}] {module}").format(type=type_, module=module), error=True)
375 raise ImportError 376 raise ImportError
376 else: 377 else:
377 for class_name in class_names: 378 for class_name in class_names:
378 cls = getattr(module, class_name) 379 cls = getattr(module, class_name)
379 cls(self) 380 cls(self)