factorize code to check loaded backends
This commit is contained in:
parent
99750e8bc7
commit
3aa286fb94
1 changed files with 47 additions and 38 deletions
|
|
@ -82,11 +82,22 @@ class ConsoleApplication(BaseApplication):
|
|||
|
||||
for name, backend in ret.iteritems():
|
||||
self.enabled_backends.add(backend)
|
||||
|
||||
self.check_loaded_backends()
|
||||
|
||||
return ret
|
||||
|
||||
def check_loaded_backends(self, default_config=None):
|
||||
while len(self.enabled_backends) == 0:
|
||||
print 'Warning: there is currently no configured backend for %s' % self.APPNAME
|
||||
if not self.ask('Do you want to configure backends?', default=True):
|
||||
break
|
||||
return False
|
||||
|
||||
self.prompt_create_backends(default_config)
|
||||
|
||||
return True
|
||||
|
||||
def prompt_create_backends(self, default_config=None):
|
||||
self.weboob.modules_loader.load_all()
|
||||
r = ''
|
||||
while r != 'q':
|
||||
|
|
@ -117,7 +128,7 @@ class ConsoleApplication(BaseApplication):
|
|||
continue
|
||||
name = backends[i]
|
||||
try:
|
||||
inst = self.add_backend(name)
|
||||
inst = self.add_backend(name, default_config)
|
||||
if inst:
|
||||
self.load_backends(names=[inst])
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
|
|
@ -125,8 +136,6 @@ class ConsoleApplication(BaseApplication):
|
|||
|
||||
print 'Right right!'
|
||||
|
||||
return ret
|
||||
|
||||
def _handle_options(self):
|
||||
self.load_default_backends()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue