Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/cli.py
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | def cli(ctx, config_file, database, url, log_level): | ||||
conf = config.read(config_file, DEFAULT_CONFIG) | conf = config.read(config_file, DEFAULT_CONFIG) | ||||
if 'scheduler' not in conf: | if 'scheduler' not in conf: | ||||
raise ValueError("missing 'scheduler' configuration") | raise ValueError("missing 'scheduler' configuration") | ||||
if database: | if database: | ||||
conf['scheduler']['cls'] = 'local' | conf['scheduler']['cls'] = 'local' | ||||
conf['scheduler']['args']['db'] = database | conf['scheduler']['args']['db'] = database | ||||
elif url: | elif url: | ||||
conf['scheduler']['cls'] = 'local' | conf['scheduler']['cls'] = 'remote' | ||||
conf['scheduler']['args']['url'] = url | conf['scheduler']['args'] = {'url': url} | ||||
sched_conf = conf['scheduler'] | sched_conf = conf['scheduler'] | ||||
try: | try: | ||||
logger.debug('Instanciating scheduler with %s' % ( | logger.debug('Instanciating scheduler with %s' % ( | ||||
sched_conf)) | sched_conf)) | ||||
scheduler = get_scheduler(**sched_conf) | scheduler = get_scheduler(**sched_conf) | ||||
except ValueError: | except ValueError: | ||||
# it's the subcommand to decide whether not having a proper | # it's the subcommand to decide whether not having a proper | ||||
# scheduler instance is a problem. | # scheduler instance is a problem. | ||||
▲ Show 20 Lines • Show All 536 Lines • Show Last 20 Lines |