From 905ef0660a0bda05c60e60f94aae9ea47578a53a Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Mon, 30 Sep 2019 12:38:28 +0200 Subject: [PATCH] Fix some errors with pylint --- setup.py | 2 +- wo/cli/plugins/site.py | 15 ++++++++++----- wo/cli/plugins/site_functions.py | 5 +++-- wo/core/acme.py | 8 +++----- wo/core/mysql.py | 6 +++--- wo/core/variables.py | 2 ++ 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/setup.py b/setup.py index 1fa7f3b..de2f75b 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ if not os.path.exists('/var/lib/wo/tmp/'): os.makedirs('/var/lib/wo/tmp/') setup(name='wo', - version='3.9.9.1', + version='3.9.9.2', description=long_description, long_description=long_description, classifiers=[], diff --git a/wo/cli/plugins/site.py b/wo/cli/plugins/site.py index 869f296..4221d50 100644 --- a/wo/cli/plugins/site.py +++ b/wo/cli/plugins/site.py @@ -1051,6 +1051,7 @@ class WOSiteUpdateController(CementBaseController): if not WOService.reload_service(self, 'nginx'): Log.error(self, "service nginx reload failed. " "check issues with `nginx -t` command") + return 0 if (pargs.ngxblocker and not (pargs.html or pargs.php or pargs.php73 or @@ -1060,11 +1061,14 @@ class WOSiteUpdateController(CementBaseController): pargs.wpsubdir or pargs.wpsubdomain or pargs.hsts)): if pargs.ngxblocker == "on": - try: - setupngxblocker(self, wo_domain) - except SiteError as e: - Log.debug(self, str(e)) - Log.info(self, "\nngxblocker not enabled.") + if os.path.isdir('/etc/nginx/bots.d'): + try: + setupngxblocker(self, wo_domain) + except SiteError as e: + Log.debug(self, str(e)) + Log.info(self, "\nngxblocker not enabled.") + else: + Log.error(self, 'ngxblocker stack is not installed') elif pargs.ngxblocker == "off": if os.path.isfile( '/var/www/{0}/conf/nginx/ngxblocker.conf' @@ -1082,6 +1086,7 @@ class WOSiteUpdateController(CementBaseController): if not WOService.reload_service(self, 'nginx'): Log.error(self, "service nginx reload failed. " "check issues with `nginx -t` command") + return 0 if ((stype == 'php' and oldsitetype not in ['html', 'proxy', 'php73']) or diff --git a/wo/cli/plugins/site_functions.py b/wo/cli/plugins/site_functions.py index 7ebf2e9..77ce9dc 100644 --- a/wo/cli/plugins/site_functions.py +++ b/wo/cli/plugins/site_functions.py @@ -17,7 +17,8 @@ from wo.core.aptget import WOAptGet from wo.core.fileutils import WOFileUtils from wo.core.git import WOGit from wo.core.logging import Log -from wo.core.mysql import WOMysql +from wo.core.mysql import (MySQLConnectionError, StatementExcecutionError, + WOMysql) from wo.core.services import WOService from wo.core.shellexec import CommandExecutionError, WOShellExec from wo.core.sslutils import SSL @@ -1622,4 +1623,4 @@ def setupngxblocker(self, domain, block=True): self, '/var/www/{0}/conf/nginx/ngxblocker.disabled' .format(domain), '/var/www/{0}/conf/nginx/ngxblocker' .format(domain)) - return 0 \ No newline at end of file + return 0 diff --git a/wo/core/acme.py b/wo/core/acme.py index d640eed..e6cafd3 100644 --- a/wo/core/acme.py +++ b/wo/core/acme.py @@ -13,11 +13,10 @@ class WOAcme: """Acme.sh utilities for WordOps""" def setupletsencrypt(self, acme_domains, acmedata): - """issue SSL certificates with acme.sh""" + """Issue SSL certificates with acme.sh""" all_domains = '\' -d \''.join(acme_domains) wo_acme_dns = acmedata['acme_dns'] - keylenght = "{0}".format(self.app.config.get('letsencrypt', - 'keylength')) + keylenght = "{0}".format(WOVariables.wo_keylength) wo_acme_exec = ("/etc/letsencrypt/acme.sh --config-home " "'/etc/letsencrypt/config'") if acmedata['dns'] is True: @@ -96,8 +95,7 @@ class WOAcme: if not WOFileUtils.grep(self, '/var/www/22222/conf/nginx/ssl.conf', '/etc/letsencrypt'): - Log.info(self, "Securing WordOps backend with current cert" - .format(wo_domain_name)) + Log.info(self, "Securing WordOps backend with current cert") sslconf = open("/var/www/22222/conf/nginx/ssl.conf", encoding='utf-8', mode='w') sslconf.write("ssl_certificate {0}/{1}/fullchain.pem;\n" diff --git a/wo/core/mysql.py b/wo/core/mysql.py index 2e962b6..92339b5 100644 --- a/wo/core/mysql.py +++ b/wo/core/mysql.py @@ -54,14 +54,14 @@ class WOMysql(): db=db_name, read_default_file='~/.my.cnf') return connection + except pymysql.err.InternalError as e: + Log.debug(self, str(e)) + raise MySQLConnectionError except DatabaseError as e: if e.args[1] == '#42000Unknown database \'{0}\''.format(db_name): raise DatabaseNotExistsError else: raise MySQLConnectionError - except pymysql.err.InternalError as e: - Log.debug(self, str(e)) - raise MySQLConnectionError except Exception as e: Log.debug(self, "[Error]Setting up database: \'" + str(e) + "\'") raise MySQLConnectionError diff --git a/wo/core/variables.py b/wo/core/variables.py index d5ce887..7049136 100644 --- a/wo/core/variables.py +++ b/wo/core/variables.py @@ -111,6 +111,8 @@ class WOVariables(): wo_nginx = ["nginx-custom", "nginx-wo"] wo_nginx_key = '188C9FB063F0247A' + wo_keylength = self.app.config.get('letsencrypt', 'keylength') + wo_php = ["php7.2-fpm", "php7.2-curl", "php7.2-gd", "php7.2-imap", "php7.2-readline", "php7.2-common", "php7.2-recode", "php7.2-cli", "php7.2-mbstring", "php7.2-intl",