From 77a7a293228ece930a30765266d4f90c920c7a49 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Sun, 12 Jan 2025 06:55:42 -0800 Subject: [PATCH] Fixed TRY300 (try-consider-else): Consider moving this statement to an `else` block --- management/daemon.py | 3 ++- management/status_checks.py | 2 +- management/utils.py | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/management/daemon.py b/management/daemon.py index 20c9d05a..c54aada4 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -380,11 +380,12 @@ def dns_set_record(qname, rtype="A"): if set_custom_dns_record(qname, rtype, value, action, env): return do_dns_update(env) or "Something isn't right." - return "OK" except ValueError as e: return (str(e), 400) + return "OK" + @app.route('/dns/dump') @authorized_personnel_only def dns_get_dump(): diff --git a/management/status_checks.py b/management/status_checks.py index a2e3a997..29b08dc2 100755 --- a/management/status_checks.py +++ b/management/status_checks.py @@ -105,12 +105,12 @@ def check_service(i, service, env): s.settimeout(1) try: s.connect((ip, service["port"])) - return True except OSError: # timed out or some other odd error return False finally: s.close() + return True if service["public"]: # Service should be publicly accessible. diff --git a/management/utils.py b/management/utils.py index 1a5b2195..879776c3 100644 --- a/management/utils.py +++ b/management/utils.py @@ -39,9 +39,9 @@ def load_settings(env): with open(fn, encoding="utf-8") as f: config = rtyaml.load(f) if not isinstance(config, dict): raise ValueError # caught below - return config except: return { } + return config # UTILITIES @@ -172,10 +172,11 @@ def wait_for_service(port, public, env, timeout): s.settimeout(timeout/3) try: s.connect(("127.0.0.1" if not public else env['PUBLIC_IP'], port)) - return True except OSError: if time.perf_counter() > start+timeout: return False + else: + return True time.sleep(min(timeout/4, 1)) def get_ssh_port():