From 4d5b8af45d4756463a314fd438ee1a1128edc32f Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Mon, 8 Apr 2019 12:38:01 +0200 Subject: [PATCH] refactor sslutils --- wo/core/sslutils.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/wo/core/sslutils.py b/wo/core/sslutils.py index 78c2df4..1c00482 100644 --- a/wo/core/sslutils.py +++ b/wo/core/sslutils.py @@ -9,7 +9,8 @@ class SSL: # check if exist if not os.path.isfile('/etc/letsencrypt/live/{0}/cert.pem' .format(domain)): - Log.error(self, 'File Not Found : /etc/letsencrypt/live/{0}/cert.pem' + Log.error(self, 'File Not Found: " + "/etc/letsencrypt/live/{0}/cert.pem'" .format(domain), False) if returnonerror: return -1 @@ -17,8 +18,14 @@ class SSL: "`tail /var/log/wo/wordops.log` and please try again...") current_date = WOShellExec.cmd_exec_stdout(self, "date -d \"now\" +%s") - expiration_date = WOShellExec.cmd_exec_stdout(self, "date -d \"`openssl x509 -in /etc/letsencrypt/live/{0}/cert.pem" - " -text -noout|grep \"Not After\"|cut -c 25-`\" +%s".format(domain)) + expiration_date = WOShellExec.cmd_exec_stdout(self, "date -d \"" + "`openssl x509 -in " + "/etc/letsencrypt/live/" + "{0}/cert.pem" + " -text -noout|grep " + "\"Not After\"|" + "cut -c 25-`\" " + "+%s".format(domain)) days_left = int((int(expiration_date) - int(current_date)) / 86400) if (days_left > 0): @@ -31,11 +38,18 @@ class SSL: # check if exist if not os.path.isfile('/etc/letsencrypt/live/{0}/cert.pem' .format(domain)): - Log.error(self, 'File Not Found : /etc/letsencrypt/live/{0}/cert.pem' + Log.error(self, 'File Not Found: "/etc/letsencrypt/" + "live/{0}/cert.pem'" .format(domain), False) Log.error(self, "Check the WordOps log for more details " "`tail /var/log/wo/wordops.log` and please try again...") - expiration_date = WOShellExec.cmd_exec_stdout(self, "date -d \"`openssl x509 -in /etc/letsencrypt/live/{0}/cert.pem" - " -text -noout|grep \"Not After\"|cut -c 25-`\" ".format(domain)) + expiration_date = WOShellExec.cmd_exec_stdout(self, "date -d " + "\"`openssl x509 -in " + "/etc/letsencrypt/live/" + "{0}/cert.pem" + " -text -noout|grep " + "\"Not After\"|" + "cut -c 25-`\" " + .format(domain)) return expiration_date