Exemple #1
0
                  readable=True,
                  resolve_path=True,
                  allow_dash=False),
        envvar='HARVESTR_RECYCLE',
        required=True)
@option('--exclude',
        '-e',
        type=STRING,
        envvar='HARVESTR_EXCLUDE',
        required=False)
@option('--dry-run', '-d', envvar='HARVESTR_DRY_RUN', is_flag=True)
@option('--sleep-time', type=INT, envvar='HARVESTR_SLEEP_TIME', default=5)
@option(
    '--log-level',
    type=CHOICE(
        ['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG', 'SUCCESS', 'TRACE'],
        case_sensitive=False),
    envvar='HARVESTR_LOG_LEVEL',
    default='DEBUG')
@option('--slack-webhook', type=STRING, envvar='SLACK_WEBHOOK', default=None)
@option('--slack-username',
        type=STRING,
        envvar='SLACK_USERNAME',
        default='Harvestr')
@option('--slack-format',
        type=STRING,
        envvar='SLACK_FORMAT',
        default='{message}')
@logger.catch
def main(source, target, recycle, exclude, dry_run, sleep_time, log_level,
         slack_webhook, slack_username, slack_format):
Exemple #2
0
from sys import stderr

from click import Choice as CHOICE, STRING, argument, group, option

from illallangi.k8sapi import API

from loguru import logger

from notifiers.logging import NotificationHandler


@group()
@option(
    "--log-level",
    type=CHOICE(
        ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "SUCCESS", "TRACE"],
        case_sensitive=False,
    ),
    default="DEBUG",
)
@option("--slack-webhook", type=STRING, envvar="SLACK_WEBHOOK", default=None)
@option("--slack-username",
        type=STRING,
        envvar="SLACK_USERNAME",
        default=__name__)
@option("--slack-format",
        type=STRING,
        envvar="SLACK_FORMAT",
        default="{message}")
def cli(log_level, slack_webhook, slack_username, slack_format):
    logger.remove()
    logger.add(stderr, level=log_level)