move enabled backends option to BaseApplication
This commit is contained in:
parent
560a129083
commit
7a86ddfbb6
2 changed files with 4 additions and 8 deletions
|
|
@ -25,15 +25,8 @@ class Videoob(ConsoleApplication):
|
||||||
APPNAME = 'videoob'
|
APPNAME = 'videoob'
|
||||||
CONFIG = {}
|
CONFIG = {}
|
||||||
|
|
||||||
def configure_parser(self, parser):
|
|
||||||
parser.add_option('-b', '--backends', help='what backend(s) to enable (comma separated)')
|
|
||||||
|
|
||||||
def main(self, argv):
|
def main(self, argv):
|
||||||
names = None
|
self.weboob.load_modules(ICapVideoProvider, names=self.enabled_backends)
|
||||||
if self.options.backends:
|
|
||||||
names = self.options.backends.split(',')
|
|
||||||
|
|
||||||
self.weboob.load_modules(ICapVideoProvider, names=names)
|
|
||||||
return self.process_command(*argv[1:])
|
return self.process_command(*argv[1:])
|
||||||
|
|
||||||
@ConsoleApplication.command('Get video information')
|
@ConsoleApplication.command('Get video information')
|
||||||
|
|
|
||||||
|
|
@ -107,9 +107,11 @@ class BaseApplication(object):
|
||||||
def run(klass):
|
def run(klass):
|
||||||
app = 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('-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('-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('-v', '--verbose', action='store_true', help='display info messages')
|
||||||
|
app._configure_parser(parser)
|
||||||
app.configure_parser(parser)
|
app.configure_parser(parser)
|
||||||
app.options, args = parser.parse_args(sys.argv)
|
app.options, args = parser.parse_args(sys.argv)
|
||||||
if app.options.debug:
|
if app.options.debug:
|
||||||
|
|
@ -122,6 +124,7 @@ 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
|
||||||
try:
|
try:
|
||||||
sys.exit(app.main(args))
|
sys.exit(app.main(args))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue