Commit 758281ef authored by Romain Bignon's avatar Romain Bignon

--backends is used on every frontends

parent e79e4bd6
......@@ -43,7 +43,7 @@ class Monboob(ConsoleApplication):
def main(self, argv):
self.load_config()
self.weboob.load_backends(ICapMessages, storage=self.create_storage())
self.load_backends(ICapMessages, storage=self.create_storage())
return self.process_command(*argv[1:])
......
......@@ -36,7 +36,7 @@ class Boobank(ConsoleApplication):
APPNAME = 'boobank'
def main(self, argv):
self.weboob.load_backends(ICapBank, names=self.enabled_backends)
self.load_backends(ICapBank, names=self.enabled_backends)
return self.process_command(*argv[1:])
@ConsoleApplication.command('List every available accounts')
......
......@@ -29,7 +29,7 @@ class Dummy(BaseApplication):
APPNAME = 'dummy'
def main(self, argv):
self.weboob.load_backends()
self.load_backends()
for backend in self.weboob.iter_backends():
print 'Backend [%s]' % backend.name
......
......@@ -27,7 +27,7 @@ class HaveSex(PromptApplication):
def main(self, argv):
self.load_config()
self.weboob.load_backends(ICapDating, storage=self.create_storage(self.STORAGE_FILENAME))
self.load_backends(ICapDating, storage=self.create_storage(self.STORAGE_FILENAME))
return self.loop()
......
......@@ -31,7 +31,7 @@ class QVideoob(QtApplication):
}
}
def main(self, argv):
self.weboob.load_modules(ICapVideoProvider, names=self.enabled_backends)
self.load_modules(ICapVideoProvider)
self.load_config()
self.main_window = MainWindow(self.config, self.weboob)
......
......@@ -25,7 +25,7 @@ class Travel(ConsoleApplication):
APPNAME = 'travel'
def main(self, argv):
self.weboob.load_modules(ICapTravel)
self.load_modules(ICapTravel)
return self.process_command(*argv[1:])
......
......@@ -146,10 +146,10 @@ class TransilienUI():
backend.iter_station_search(self.combo_dest.get_current_text()):
for departure in \
backend.iter_station_departures(station.id, arrival.id):
self.treestore.append(None,
[departure.type,
departure.time,
departure.arrival_station,
self.treestore.append(None,
[departure.type,
departure.time,
departure.arrival_station,
departure.information])
......@@ -159,6 +159,6 @@ class Travel(BaseApplication):
def main(self, argv):
"main fonction"
self.weboob.load_modules(ICapTravel)
self.load_modules(ICapTravel)
TransilienUI(self.weboob)
gtk.main()
......@@ -26,7 +26,7 @@ class Videoob(ConsoleApplication):
CONFIG = {}
def main(self, argv):
self.weboob.load_modules(ICapVideoProvider, names=self.enabled_backends)
self.load_modules(ICapVideoProvider)
return self.process_command(*argv[1:])
@ConsoleApplication.command('Get video information')
......
......@@ -25,7 +25,7 @@ class WetBoobs(ConsoleApplication):
APPNAME = 'wetboobs'
def main(self, argv):
self.weboob.load_modules(ICapWeather)
self.load_modules(ICapWeather)
return self.process_command(*argv[1:])
......
......@@ -106,14 +106,24 @@ class BaseApplication(object):
def _configure_parser(self, parser):
pass
def load_backends(self, caps=None, names=None, *args, **kwargs):
if names is None:
names = self._enabled_backends
self.weboob.load_backends(caps, names, *args, **kwargs)
def load_modules(self, caps=None, names=None, *args, **kwargs):
if names is None:
names = self._enabled_backends
self.weboob.load_backends(caps, names, *args, **kwargs)
@classmethod
def run(klass):
app = klass()
parser = OptionParser('Usage: %prog [options (-h for help)] URL...')
parser = OptionParser('Usage: %prog [options (-h for help)] URL...')
parser.add_option('-b', '--backends', help='what backend(s) to enable (comma separated)')
parser.add_option('-d', '--debug', action='store_true', help='display debug messages')
parser.add_option('-q', '--quiet', action='store_true', help='display only error messages')
parser.add_option('-v', '--verbose', action='store_true', help='display info messages')
parser.add_option('-d', '--debug', action='store_true', help='display debug messages')
parser.add_option('-q', '--quiet', action='store_true', help='display only error messages')
parser.add_option('-v', '--verbose', action='store_true', help='display info messages')
app._configure_parser(parser)
app.configure_parser(parser)
app.options, args = parser.parse_args(sys.argv)
......@@ -127,7 +137,7 @@ class BaseApplication(object):
level = logging.WARNING
log_format = '%(asctime)s:%(levelname)s:%(filename)s:%(lineno)d:%(funcName)s %(message)s'
logging.basicConfig(stream=sys.stdout, level=level, format=log_format)
app.enabled_backends = app.options.backends.split(',') if app.options.backends else None
app._enabled_backends = app.options.backends.split(',') if app.options.backends else None
try:
sys.exit(app.main(args))
except KeyboardInterrupt:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment