From 147aab1e4ecd9445135799e48829488c65b21e8e Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Sat, 30 Jul 2022 01:06:41 +0530 Subject: [PATCH 1/2] chore: Remove dead MANIFEST.in --- MANIFEST.in | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index f9ed1524..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,9 +0,0 @@ -include *.md -include *.py -recursive-include bench *.conf -recursive-include bench *.sh -recursive-include bench *.py -recursive-include bench *.txt -recursive-include bench *.json -recursive-include bench/config/templates * -recursive-include bench/playbooks * From a5b7a101d21024852ba10413a24b20a820fbe6f9 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Sat, 30 Jul 2022 01:12:27 +0530 Subject: [PATCH 2/2] refactor: Use Suppress instead of try-pass --- bench/config/production_setup.py | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/bench/config/production_setup.py b/bench/config/production_setup.py index 4d5a4bec..719f90d2 100755 --- a/bench/config/production_setup.py +++ b/bench/config/production_setup.py @@ -1,4 +1,5 @@ # imports - standard imports +import contextlib import os import logging import sys @@ -181,40 +182,25 @@ def is_running_systemd(): def reload_supervisor(): supervisorctl = which("supervisorctl") - try: + with contextlib.suppress(CommandFailedError): # first try reread/update exec_cmd(f"{supervisorctl} reread") exec_cmd(f"{supervisorctl} update") return - except CommandFailedError: - pass - - try: + with contextlib.suppress(CommandFailedError): # something is wrong, so try reloading exec_cmd(f"{supervisorctl} reload") return - except CommandFailedError: - pass - - try: + with contextlib.suppress(CommandFailedError): # then try restart for centos service("supervisord", "restart") return - except CommandFailedError: - pass - - try: + with contextlib.suppress(CommandFailedError): # else try restart for ubuntu / debian service("supervisor", "restart") return - except CommandFailedError: - pass def reload_nginx(): - try: - exec_cmd(f"sudo {which('nginx')} -t") - except Exception: - raise - + exec_cmd(f"sudo {which('nginx')} -t") service("nginx", "reload")