all loaded backends are now configured (refs #368)
This commit is contained in:
parent
8afff42465
commit
9581fa0b19
15 changed files with 17 additions and 45 deletions
|
|
@ -39,7 +39,7 @@ class Boobank(ConsoleApplication):
|
|||
|
||||
@ConsoleApplication.command('List every available accounts')
|
||||
def command_list(self):
|
||||
self.load_configured_backends(ICapBank)
|
||||
self.load_backends(ICapBank)
|
||||
tot_balance = 0.0
|
||||
tot_coming = 0.0
|
||||
try:
|
||||
|
|
@ -63,7 +63,7 @@ class Boobank(ConsoleApplication):
|
|||
def command_history(self, id):
|
||||
id, backend_name = self.parse_id(id)
|
||||
names = (backend_name,) if backend_name is not None else None
|
||||
self.load_configured_backends(ICapBank, names=names)
|
||||
self.load_backends(ICapBank, names=names)
|
||||
|
||||
def do(backend):
|
||||
account = backend.get_account(id)
|
||||
|
|
@ -76,7 +76,7 @@ class Boobank(ConsoleApplication):
|
|||
def command_coming(self, id):
|
||||
id, backend_name = self.parse_id(id)
|
||||
names = (backend_name,) if backend_name is not None else None
|
||||
self.load_configured_backends(ICapBank, names=names)
|
||||
self.load_backends(ICapBank, names=names)
|
||||
|
||||
def do(backend):
|
||||
account = backend.get_account(id)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Chatoob(ConsoleApplication):
|
|||
COPYRIGHT = 'Copyright(C) 2010 Christophe Benz'
|
||||
|
||||
def main(self, argv):
|
||||
self.load_configured_backends(ICapChat)
|
||||
self.load_backends(ICapChat)
|
||||
#for backend, result in self.do('start_chat_polling', self.on_new_chat_message):
|
||||
#logging.info(u'Polling chat messages for backend %s' % backend)
|
||||
return self.process_command(*argv[1:])
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Geolooc(ConsoleApplication):
|
|||
print >>sys.stderr, 'Syntax: %s ipaddr' % argv[0]
|
||||
return 1
|
||||
|
||||
self.load_configured_backends(ICapGeolocIp)
|
||||
self.load_backends(ICapGeolocIp)
|
||||
for backend, location in self.do('get_location', argv[1]):
|
||||
self.format(location)
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class HaveSex(PromptApplication):
|
|||
|
||||
def main(self, argv):
|
||||
self.load_config()
|
||||
self.load_configured_backends(ICapDating, storage=self.create_storage(self.STORAGE_FILENAME))
|
||||
self.load_backends(ICapDating, storage=self.create_storage(self.STORAGE_FILENAME))
|
||||
|
||||
self.do('init_optimizations').wait()
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class Monboob(ConsoleApplication):
|
|||
|
||||
def main(self, argv):
|
||||
self.load_config()
|
||||
self.load_configured_backends(ICapMessages, storage=self.create_storage())
|
||||
self.load_backends(ICapMessages, storage=self.create_storage())
|
||||
|
||||
return self.process_command(*argv[1:])
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class QBoobMsg(QtApplication):
|
|||
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon'
|
||||
|
||||
def main(self, argv):
|
||||
self.load_configured_backends(ICapMessages, storage=self.create_storage())
|
||||
self.load_backends(ICapMessages, storage=self.create_storage())
|
||||
|
||||
self.main_window = MainWindow(self.config, self.weboob)
|
||||
self.main_window.show()
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class QHaveSex(QtApplication):
|
|||
|
||||
def main(self, argv):
|
||||
self.create_storage(self.STORAGE_FILENAME)
|
||||
self.load_configured_backends(ICapDating)
|
||||
self.load_backends(ICapDating)
|
||||
|
||||
self.main_window = MainWindow(self.config, self.weboob)
|
||||
self.main_window.show()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class QWeboobCfg(QtApplication):
|
|||
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon'
|
||||
|
||||
def main(self, argv):
|
||||
self.load_configured_backends()
|
||||
self.load_backends()
|
||||
|
||||
self.dlg = BackendCfg(self.weboob)
|
||||
self.dlg.show()
|
||||
|
|
|
|||
|
|
@ -29,9 +29,6 @@ class WeboobCli(ConsoleApplication):
|
|||
VERSION = '0.1'
|
||||
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon'
|
||||
|
||||
def add_application_options(self, group):
|
||||
group.add_option('-C', '--configured', action='store_true', help='load configured backends')
|
||||
|
||||
def main(self, argv):
|
||||
if len(argv) < 3:
|
||||
print >>sys.stderr, "Syntax: %s capability command [args ..]" % argv[0]
|
||||
|
|
@ -41,10 +38,7 @@ class WeboobCli(ConsoleApplication):
|
|||
cmd = argv[2]
|
||||
args = argv[3:]
|
||||
|
||||
if self.options.configured:
|
||||
self.load_configured_backends(cap_s)
|
||||
else:
|
||||
self.load_backends(cap_s)
|
||||
self.load_backends(cap_s)
|
||||
|
||||
for backend, obj in self.do(cmd, *args):
|
||||
self.format(obj)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Weboorrents(ConsoleApplication):
|
|||
COPYRIGHT = 'Copyright(C) 2010 Romain Bignon'
|
||||
|
||||
def main(self, argv):
|
||||
self.load_configured_backends(ICapTorrent)
|
||||
self.load_backends(ICapTorrent)
|
||||
return self.process_command(*argv[1:])
|
||||
|
||||
@ConsoleApplication.command('Get information about a torrent')
|
||||
|
|
|
|||
|
|
@ -68,21 +68,7 @@ class Weboob(object):
|
|||
def deinit(self):
|
||||
self.unload_backends()
|
||||
|
||||
def load_backends(self, caps=None, names=None, storage=None):
|
||||
loaded = {}
|
||||
if storage is None:
|
||||
storage = self.storage
|
||||
|
||||
self.backends_loader.load_all()
|
||||
for backend_name, backend in self.backends_loader.loaded.iteritems():
|
||||
if caps is not None and not backend.has_caps(caps) or \
|
||||
names is not None and backend_name not in names:
|
||||
continue
|
||||
backend_instance = backend.create_instance(self, backend_name, {}, storage)
|
||||
self.backend_instances[backend_name] = loaded[backend_name] = backend_instance
|
||||
return loaded
|
||||
|
||||
def load_configured_backends(self, caps=None, names=None, modules=None, storage=None):
|
||||
def load_backends(self, caps=None, names=None, modules=None, storage=None):
|
||||
loaded = {}
|
||||
if storage is None:
|
||||
storage = self.storage
|
||||
|
|
|
|||
|
|
@ -179,14 +179,6 @@ class BaseApplication(object):
|
|||
logging.warning(u'No backend loaded')
|
||||
return loaded
|
||||
|
||||
def load_configured_backends(self, caps=None, names=None, *args, **kwargs):
|
||||
if names is None:
|
||||
names = self.requested_backends
|
||||
loaded = self.weboob.load_configured_backends(caps, names, *args, **kwargs)
|
||||
if not loaded:
|
||||
logging.warning(u'No configured backend loaded')
|
||||
return loaded
|
||||
|
||||
def _get_optparse_version(self):
|
||||
version = None
|
||||
if self.VERSION:
|
||||
|
|
|
|||
|
|
@ -273,8 +273,8 @@ class ConsoleApplication(BaseApplication):
|
|||
register_command = staticmethod(register_command)
|
||||
command = staticmethod(command)
|
||||
|
||||
def load_configured_backends(self, caps=None, names=None, *args, **kwargs):
|
||||
loaded_backends = BaseApplication.load_configured_backends(self, caps, names, *args, **kwargs)
|
||||
def load_backends(self, caps=None, names=None, *args, **kwargs):
|
||||
loaded_backends = BaseApplication.load_backends(self, caps, names, *args, **kwargs)
|
||||
if not loaded_backends:
|
||||
logging.error(u'Cannot start application: no configured backend was found.\nHere is a list of all available backends:')
|
||||
from weboob.applications.weboobcfg import WeboobCfg
|
||||
|
|
|
|||
|
|
@ -310,6 +310,6 @@ class BackendCfg(QDialog):
|
|||
ret = (len(self.to_load) > 0 or len(self.to_unload) > 0)
|
||||
|
||||
self.weboob.unload_backends(self.to_unload)
|
||||
self.weboob.load_configured_backends(names=self.to_load)
|
||||
self.weboob.load_backends(names=self.to_load)
|
||||
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class BackendTest(TestCase):
|
|||
self.backend = None
|
||||
self.weboob = Weboob()
|
||||
|
||||
if self.weboob.load_configured_backends(modules=[self.BACKEND]):
|
||||
if self.weboob.load_backends(modules=[self.BACKEND]):
|
||||
self.backend = choice(self.weboob.backend_instances.values())
|
||||
|
||||
def run(self, result):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue