Changeset View
Changeset View
Standalone View
Standalone View
swh/core/cli/__init__.py
# Copyright (C) 2019 The Software Heritage developers | # Copyright (C) 2019 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 | ||||
import logging | import logging | ||||
import logging.config | import logging.config | ||||
import signal | |||||
import click | import click | ||||
import pkg_resources | import pkg_resources | ||||
import yaml | |||||
from ..sentry import init_sentry | |||||
LOG_LEVEL_NAMES = ["NOTSET", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] | LOG_LEVEL_NAMES = ["NOTSET", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] | ||||
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) | CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) | ||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | @click.option( | ||||
default=False, | default=False, | ||||
hidden=True, | hidden=True, | ||||
help="Enable debugging of sentry", | help="Enable debugging of sentry", | ||||
) | ) | ||||
@click.pass_context | @click.pass_context | ||||
def swh(ctx, log_level, log_config, sentry_dsn, sentry_debug): | def swh(ctx, log_level, log_config, sentry_dsn, sentry_debug): | ||||
"""Command line interface for Software Heritage. | """Command line interface for Software Heritage. | ||||
""" | """ | ||||
import signal | |||||
import yaml | |||||
from ..sentry import init_sentry | |||||
signal.signal(signal.SIGTERM, clean_exit_on_signal) | signal.signal(signal.SIGTERM, clean_exit_on_signal) | ||||
signal.signal(signal.SIGINT, clean_exit_on_signal) | signal.signal(signal.SIGINT, clean_exit_on_signal) | ||||
init_sentry(sentry_dsn, debug=sentry_debug) | init_sentry(sentry_dsn, debug=sentry_debug) | ||||
if log_level is None and log_config is None: | if log_level is None and log_config is None: | ||||
log_level = "INFO" | log_level = "INFO" | ||||
Show All 28 Lines |