From 210d9f08dc0ab4108b66dba6d9fa59bd900d31a4 Mon Sep 17 00:00:00 2001 From: KiekerJan Date: Sat, 5 Nov 2022 21:04:05 +0100 Subject: [PATCH] simplify utils.py#shell method used by unbound-control call --- management/dns_update.py | 2 +- management/status_checks.py | 2 +- management/utils.py | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/management/dns_update.py b/management/dns_update.py index 12dab498..d53d5777 100755 --- a/management/dns_update.py +++ b/management/dns_update.py @@ -127,7 +127,7 @@ def do_dns_update(env, force=False): # Clear unbound's DNS cache so our own DNS resolver is up to date. # (ignore errors with trap=True) - shell('check_call', ["/usr/sbin/unbound-control", "flush_zone", "."], trap=True, capture_stdout=False) + shell('check_call', ["/usr/sbin/unbound-control", "flush_zone", ".", "-q"], trap=True) if len(updated_domains) == 0: # if nothing was updated (except maybe DKIM's files), don't show any output diff --git a/management/status_checks.py b/management/status_checks.py index cc375380..9a763e3d 100755 --- a/management/status_checks.py +++ b/management/status_checks.py @@ -58,7 +58,7 @@ def run_checks(rounded_values, env, output, pool, domains_to_check=None): # clear unbound's DNS cache so our DNS checks are up to date # (ignore errors; if unbound isn't running we'd already report # that in run_services checks.) - shell('check_call', ["/usr/sbin/unbound-control", "flush_zone", "."], trap=True, capture_stdout=False) + shell('check_call', ["/usr/sbin/unbound-control", "flush_zone", ".", "-q"], trap=True) run_system_checks(rounded_values, env, output) diff --git a/management/utils.py b/management/utils.py index 8b910da4..3aaece2e 100644 --- a/management/utils.py +++ b/management/utils.py @@ -106,7 +106,7 @@ def sort_email_addresses(email_addresses, env): ret.extend(sorted(email_addresses)) # whatever is left return ret -def shell(method, cmd_args, env={}, capture_stdout=True, capture_stderr=False, return_bytes=False, trap=False, input=None): +def shell(method, cmd_args, env={}, capture_stderr=False, return_bytes=False, trap=False, input=None): # A safe way to execute processes. # Some processes like apt-get require being given a sane PATH. import subprocess @@ -116,8 +116,6 @@ def shell(method, cmd_args, env={}, capture_stdout=True, capture_stderr=False, r 'env': env, 'stderr': None if not capture_stderr else subprocess.STDOUT, } - if not capture_stdout: - kwargs['stdout'] = subprocess.DEVNULL if method == "check_output" and input is not None: kwargs['input'] = input