inform user about backend not found
This commit is contained in:
parent
b91093a92c
commit
11475c8325
2 changed files with 29 additions and 7 deletions
|
|
@ -25,7 +25,12 @@ from weboob.core.ouiboube import Weboob
|
||||||
from weboob.tools.config.iconfig import ConfigError
|
from weboob.tools.config.iconfig import ConfigError
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['BaseApplication', 'ConfigError']
|
__all__ = ['BackendNotFound', 'BaseApplication', 'ConfigError']
|
||||||
|
|
||||||
|
|
||||||
|
class BackendNotFound(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class FrontendStorage(object):
|
class FrontendStorage(object):
|
||||||
def __init__(self, name, storage):
|
def __init__(self, name, storage):
|
||||||
|
|
@ -138,13 +143,19 @@ class BaseApplication(object):
|
||||||
|
|
||||||
def load_backends(self, caps=None, names=None, *args, **kwargs):
|
def load_backends(self, caps=None, names=None, *args, **kwargs):
|
||||||
if names is None:
|
if names is None:
|
||||||
names = self._enabled_backends
|
names = self.requested_backends
|
||||||
return self.weboob.load_backends(caps, names, *args, **kwargs)
|
loaded_backends = self.weboob.load_backends(caps, names, *args, **kwargs)
|
||||||
|
if not loaded_backends:
|
||||||
|
logging.warning(u'No backend loaded')
|
||||||
|
return loaded_backends
|
||||||
|
|
||||||
def load_modules(self, caps=None, names=None, *args, **kwargs):
|
def load_modules(self, caps=None, names=None, *args, **kwargs):
|
||||||
if names is None:
|
if names is None:
|
||||||
names = self._enabled_backends
|
names = self.requested_backends
|
||||||
return self.weboob.load_modules(caps, names, *args, **kwargs)
|
loaded_modules = self.weboob.load_modules(caps, names, *args, **kwargs)
|
||||||
|
if not loaded_modules:
|
||||||
|
logging.warning(u'No module loaded')
|
||||||
|
return loaded_modules
|
||||||
|
|
||||||
def _get_completions(self):
|
def _get_completions(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -194,7 +205,11 @@ class BaseApplication(object):
|
||||||
level = logging.WARNING
|
level = logging.WARNING
|
||||||
log_format = '%(asctime)s:%(levelname)s:%(filename)s:%(lineno)d:%(funcName)s %(message)s'
|
log_format = '%(asctime)s:%(levelname)s:%(filename)s:%(lineno)d:%(funcName)s %(message)s'
|
||||||
logging.basicConfig(stream=sys.stdout, level=level, format=log_format)
|
logging.basicConfig(stream=sys.stdout, level=level, format=log_format)
|
||||||
app._enabled_backends = app.options.backends.split(',') if app.options.backends else None
|
app.requested_backends = app.options.backends.split(',') if app.options.backends else None
|
||||||
|
existing_module_names = list(app.weboob.modules_loader.iter_existing_module_names())
|
||||||
|
for requested_backend in app.requested_backends:
|
||||||
|
if requested_backend not in existing_module_names:
|
||||||
|
raise BackendNotFound(u'Unknown backend: "%s"' % requested_backend)
|
||||||
|
|
||||||
app._handle_app_options()
|
app._handle_app_options()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import sys
|
||||||
from weboob.core.bcall import CallErrors
|
from weboob.core.bcall import CallErrors
|
||||||
from weboob.core.modules import BackendsConfig
|
from weboob.core.modules import BackendsConfig
|
||||||
|
|
||||||
from .base import BaseApplication
|
from .base import BackendNotFound, BaseApplication
|
||||||
from .formatters.instances import formatters
|
from .formatters.instances import formatters
|
||||||
from .results import ResultsCondition, ResultsConditionException
|
from .results import ResultsCondition, ResultsConditionException
|
||||||
|
|
||||||
|
|
@ -233,3 +233,10 @@ class ConsoleApplication(BaseApplication):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
backend_name = None
|
backend_name = None
|
||||||
return _id, backend_name
|
return _id, backend_name
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def run(klass, args=None):
|
||||||
|
try:
|
||||||
|
super(ConsoleApplication, klass).run(args)
|
||||||
|
except BackendNotFound, e:
|
||||||
|
logging.error(e)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue