black formatting on uptimekuma hook
Some checks are pending
build / test (push) Waiting to run
build / docs (push) Blocked by required conditions

This commit is contained in:
Paul Wilde 2024-06-24 10:46:04 +01:00
parent 14ce88e04b
commit 8f423c7293

View file

@ -27,22 +27,21 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev
status = 'down' if state.name.lower() == 'fail' else 'up' status = 'down' if state.name.lower() == 'fail' else 'up'
push_url = hook_config.get('push_url', 'https://example.uptime.kuma/api/push/abcd1234') push_url = hook_config.get('push_url', 'https://example.uptime.kuma/api/push/abcd1234')
query = f'status={status}&msg={state.name.lower()}' query = f'status={status}&msg={state.name.lower()}'
logger.info(f'{config_filename}: Pinging Uptime Kuma push_url {push_url}?{query} {dry_run_label}') logger.info(
logger.debug( f'{config_filename}: Pinging Uptime Kuma push_url {push_url}?{query} {dry_run_label}'
f'{config_filename}: Full Uptime Kuma state URL {push_url}?{query}'
) )
logger.debug(f'{config_filename}: Full Uptime Kuma state URL {push_url}?{query}')
if dry_run: if dry_run:
return return
logging.getLogger('urllib3').setLevel(logging.ERROR) logging.getLogger('urllib3').setLevel(logging.ERROR)
try: try:
response = requests.get( response = requests.get(f'{push_url}?{query}')
f'{push_url}?{query}'
)
if not response.ok: if not response.ok:
response.raise_for_status() response.raise_for_status()
except requests.exceptions.RequestException as error: except requests.exceptions.RequestException as error:
logger.warning(f'{config_filename}: Uptime Kuma error: {error}') logger.warning(f'{config_filename}: Uptime Kuma error: {error}')
def destroy_monitor( def destroy_monitor(
ping_url_or_uuid, config, config_filename, monitoring_log_level, dry_run ping_url_or_uuid, config, config_filename, monitoring_log_level, dry_run
): # pragma: no cover ): # pragma: no cover