From 37c937f006a5e324fa98e652c10d5a12c4b56eb1 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 30 Oct 2019 13:05:08 +0100 Subject: [PATCH] Improve return function --- wo/cli/plugins/site.py | 36 ++++++++---------------------------- wo/core/checkfqdn.py | 5 +---- wo/core/shellexec.py | 11 +++-------- 3 files changed, 12 insertions(+), 40 deletions(-) diff --git a/wo/cli/plugins/site.py b/wo/cli/plugins/site.py index 71a6fee..31373ab 100644 --- a/wo/cli/plugins/site.py +++ b/wo/cli/plugins/site.py @@ -637,10 +637,7 @@ class WOSiteCreateController(CementBaseController): # Setup WordPress if Wordpress site if data['wp']: - if pargs.vhostonly: - vhostonly = True - else: - vhostonly = False + vhostonly = bool(pargs.vhostonly) try: wo_wp_creds = setupwordpress(self, data, vhostonly) # Add database information for site into database @@ -1261,10 +1258,7 @@ class WOSiteUpdateController(CementBaseController): if pargs.letsencrypt == 'on': data['letsencrypt'] = True letsencrypt = True - if (wo_domain_type == 'subdomain'): - acme_subdomain = True - else: - acme_subdomain = False + acme_subdomain = bool(wo_domain_type == 'subdomain') acme_wildcard = False elif pargs.letsencrypt == 'subdomain': data['letsencrypt'] = True @@ -1316,19 +1310,11 @@ class WOSiteUpdateController(CementBaseController): return 0 if data and (not pargs.php73): - if old_php73 is True: - data['php73'] = True - php73 = True - else: - data['php73'] = False - php73 = False + data['php73'] = bool(old_php73 is True) + php73 = bool(old_php73 is True) - if pargs.php73 == "on": - data['php73'] = True - php73 = True - else: - data['php73'] = False - php73 = False + data['php73'] = bool(pargs.php73 == "on") + php73 = bool(pargs.php73 == "on") if pargs.wpredis and data['currcachetype'] != 'wpredis': data['wpredis'] = True @@ -1350,16 +1336,10 @@ class WOSiteUpdateController(CementBaseController): return 1 if pargs.hsts: - if pargs.hsts == "on": - data['hsts'] = True - elif pargs.hsts == "off": - data['hsts'] = False + data['hsts'] = bool(pargs.hsts == "on") if pargs.ngxblocker: - if pargs.ngxblocker == 'on': - ngxblocker = True - elif pargs.ngxblocker == 'off': - ngxblocker = False + ngxblocker = bool(pargs.ngxblocker == 'on') if not data: Log.error(self, "Cannot update {0}, Invalid Options" diff --git a/wo/core/checkfqdn.py b/wo/core/checkfqdn.py index 55f93d5..2ce5533 100644 --- a/wo/core/checkfqdn.py +++ b/wo/core/checkfqdn.py @@ -33,7 +33,4 @@ def check_fqdn_ip(self): y = requests.get('http://v4.wordops.eu/dns/{0}/'.format(wo_fqdn)) ip_fqdn = (y.text).strip() - if ip == ip_fqdn: - return True - else: - return False + return bool(ip == ip_fqdn) diff --git a/wo/core/shellexec.py b/wo/core/shellexec.py index 61b12ea..3fb638c 100644 --- a/wo/core/shellexec.py +++ b/wo/core/shellexec.py @@ -27,14 +27,9 @@ class WOShellExec(): cmd_stderr_bytes.decode('utf-8', "replace")) - if proc.returncode == 0: - Log.debug(self, "Command Output: {0}, \nCommand Error: {1}" - .format(cmd_stdout, cmd_stderr)) - return True - else: - Log.debug(self, "Command Output: {0}, \nCommand Error: {1}" - .format(cmd_stdout, cmd_stderr)) - return False + Log.debug(self, "Command Output: {0}, \nCommand Error: {1}" + .format(cmd_stdout, cmd_stderr)) + return bool(proc.returncode == 0) except OSError as e: Log.debug(self, str(e)) raise CommandExecutionError