Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/cli/__init__.py
# Copyright (C) 2016-2020 The Software Heritage developers | # Copyright (C) 2016-2021 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
# WARNING: do not import unnecessary things here to keep cli startup time under | # WARNING: do not import unnecessary things here to keep cli startup time under | ||||
# control | # control | ||||
import logging | import logging | ||||
import click | import click | ||||
from swh.core.cli import CONTEXT_SETTINGS, AliasedGroup | from swh.core.cli import CONTEXT_SETTINGS, AliasedGroup | ||||
from swh.core.cli import swh as swh_cli_group | from swh.core.cli import swh as swh_cli_group | ||||
# If you're looking for subcommand imports, they are further down this file to | |||||
# avoid a circular import! | |||||
@swh_cli_group.group( | @swh_cli_group.group( | ||||
name="scheduler", context_settings=CONTEXT_SETTINGS, cls=AliasedGroup | name="scheduler", context_settings=CONTEXT_SETTINGS, cls=AliasedGroup | ||||
) | ) | ||||
@click.option( | @click.option( | ||||
"--config-file", | "--config-file", | ||||
"-C", | "-C", | ||||
default=None, | default=None, | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | except (ValueError, OperationalError): | ||||
# 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. | ||||
pass | pass | ||||
ctx.obj["scheduler"] = scheduler | ctx.obj["scheduler"] = scheduler | ||||
ctx.obj["config"] = conf | ctx.obj["config"] = conf | ||||
from . import admin, celery_monitor, task, task_type # noqa | from . import admin, celery_monitor, origin, task, task_type # noqa | ||||
def main(): | def main(): | ||||
import click.core | import click.core | ||||
click.core.DEPRECATED_HELP_NOTICE = """ | click.core.DEPRECATED_HELP_NOTICE = """ | ||||
DEPRECATED! Please use the command 'swh scheduler'.""" | DEPRECATED! Please use the command 'swh scheduler'.""" | ||||
cli.deprecated = True | cli.deprecated = True | ||||
return cli(auto_envvar_prefix="SWH_SCHEDULER") | return cli(auto_envvar_prefix="SWH_SCHEDULER") | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
main() | main() |