diff --git a/wo/cli/plugins/info.py b/wo/cli/plugins/info.py index 2d57e31..9e071d7 100644 --- a/wo/cli/plugins/info.py +++ b/wo/cli/plugins/info.py @@ -41,7 +41,8 @@ class WOInfoController(CementBaseController): @expose(hide=True) def info_nginx(self): """Display Nginx information""" - version = os.popen("/usr/sbin/nginx -v 2>&1 | awk -F '/' '{print $2}' | " + version = os.popen("/usr/sbin/nginx -v 2>&1 | " + "awk -F '/' '{print $2}' | " "awk -F ' ' '{print $1}' | tr '\n' ' '").read() allow = os.popen("grep ^allow /etc/nginx/common/acl.conf | " "cut -d' ' -f2 | cut -d';' -f1 | tr '\n' ' '").read() @@ -66,7 +67,8 @@ class WOInfoController(CementBaseController): @expose(hide=True) def info_php(self): """Display PHP information""" - version = os.popen("/usr/bin/php7.2 -v 2>/dev/null | head -n1 | cut -d' ' -f2 |" + version = os.popen("/usr/bin/php7.2 -v 2>/dev/null | " + "head -n1 | cut -d' ' -f2 |" " cut -d'+' -f1 | tr -d '\n'").read config = configparser.ConfigParser() config.read('/etc/{0}/fpm/php.ini'.format("php/7.2")) @@ -140,7 +142,8 @@ class WOInfoController(CementBaseController): @expose(hide=True) def info_php73(self): """Display PHP information""" - version = os.popen("/usr/bin/php7.3 -v 2>/dev/null | head -n1 | cut -d' ' -f2 |" + version = os.popen("/usr/bin/php7.3 -v 2>/dev/null | " + "head -n1 | cut -d' ' -f2 |" " cut -d'+' -f1 | tr -d '\n'").read config = configparser.ConfigParser() config.read('/etc/php/7.3/fpm/php.ini') @@ -214,23 +217,29 @@ class WOInfoController(CementBaseController): @expose(hide=True) def info_mysql(self): """Display MySQL information""" - version = os.popen("/usr/bin/mysql -V | awk '{print($5)}' | cut -d ',' " + version = os.popen("/usr/bin/mysql -V | awk '{print($5)}' | " + "cut -d ',' " "-f1 | tr -d '\n'").read() host = "localhost" - port = os.popen("/usr/bin/mysql -e \"show variables\" | grep ^port | awk " + port = os.popen("/usr/bin/mysql -e \"show variables\" | " + "grep ^port | awk " "'{print($2)}' | tr -d '\n'").read() wait_timeout = os.popen("/usr/bin/mysql -e \"show variables\" | grep " "^wait_timeout | awk '{print($2)}' | " "tr -d '\n'").read() - interactive_timeout = os.popen("/usr/bin/mysql -e \"show variables\" | grep " + interactive_timeout = os.popen("/usr/bin/mysql -e " + "\"show variables\" | grep " "^interactive_timeout | awk " "'{print($2)}' | tr -d '\n'").read() - max_used_connections = os.popen("/usr/bin/mysql -e \"show global status\" | " + max_used_connections = os.popen("/usr/bin/mysql -e " + "\"show global status\" | " "grep Max_used_connections | awk " "'{print($2)}' | tr -d '\n'").read() - datadir = os.popen("/usr/bin/mysql -e \"show variables\" | grep datadir | awk" + datadir = os.popen("/usr/bin/mysql -e \"show variables\" | " + "grep datadir | awk" " '{print($2)}' | tr -d '\n'").read() - socket = os.popen("/usr/bin/mysql -e \"show variables\" | grep \"^socket\" | " + socket = os.popen("/usr/bin/mysql -e \"show variables\" | " + "grep \"^socket\" | " "awk '{print($2)}' | tr -d '\n'").read() data = dict(version=version, host=host, port=port, wait_timeout=wait_timeout, diff --git a/wo/core/apt_repo.py b/wo/core/apt_repo.py index 4c89dae..cfd1f22 100644 --- a/wo/core/apt_repo.py +++ b/wo/core/apt_repo.py @@ -23,8 +23,8 @@ class WORepo(): """ if repo_url is not None: - repo_file_path = ("/etc/apt/sources.list.d/" - + WOVariables().wo_repo_file) + repo_file_path = ("/etc/apt/sources.list.d/" + + WOVariables().wo_repo_file) try: if not os.path.isfile(repo_file_path): with open(repo_file_path, @@ -62,8 +62,8 @@ class WORepo(): "--remove '{ppa_name}'" .format(ppa_name=ppa)) elif repo_url: - repo_file_path = ("/etc/apt/sources.list.d/" - + WOVariables().wo_repo_file) + repo_file_path = ("/etc/apt/sources.list.d/" + + WOVariables().wo_repo_file) try: repofile = open(repo_file_path, "w+") @@ -84,8 +84,8 @@ class WORepo(): """ WOShellExec.cmd_exec(self, "gpg --keyserver {serv}" .format(serv=(keyserver or - "hkp://keyserver.ubuntu.com")) - + " --recv-keys {key}".format(key=keyids)) + "hkp://keyserver.ubuntu.com")) + + " --recv-keys {key}".format(key=keyids)) WOShellExec.cmd_exec(self, "gpg -a --export --armor {0}" - .format(keyids) - + " | apt-key add - ") + .format(keyids) + + " | apt-key add - ") diff --git a/wo/core/aptget.py b/wo/core/aptget.py index bacaef4..a480202 100644 --- a/wo/core/aptget.py +++ b/wo/core/aptget.py @@ -51,7 +51,8 @@ class WOAptGet(): Log.info(self, Log.FAIL + "Whoops, something went wrong...") Log.error(self, "Check the WordOps log for more details " - "`tail /var/log/wo/wordops.log` and please try again...") + "`tail /var/log/wo/wordops.log` " + "and please try again...") except Exception as e: Log.error(self, "apt-get update exited with error") @@ -98,7 +99,8 @@ class WOAptGet(): Log.info(self, Log.FAIL + "Oops Something went " "wrong!!") Log.error(self, "Check the WordOps log for more details " - "`tail /var/log/wo/wordops.log` and please try again...") + "`tail /var/log/wo/wordops.log` " + "and please try again...") except Exception as e: Log.error(self, "Error while installing packages, " "apt-get exited with error") @@ -124,13 +126,15 @@ class WOAptGet(): Log.info(self, Log.FAIL + "Oops Something went " "wrong!!") Log.error(self, "Check the WordOps log for more details " - "`tail /var/log/wo/wordops.log` and please try again...") + "`tail /var/log/wo/wordops.log` " + "and please try again...") except Exception as e: Log.info(self, Log.FAIL + "Oops Something went " "wrong!!") Log.error(self, "Check the WordOps log for more details " - "`tail /var/log/wo/wordops.log` and please try again...") + "`tail /var/log/wo/wordops.log` " + "and please try again...") def remove(self, packages, auto=False, purge=False): all_packages = ' '.join(packages) @@ -153,7 +157,8 @@ class WOAptGet(): Log.info(self, Log.FAIL + "Oops Something went " "wrong!!") Log.error(self, "Check the WordOps log for more details " - "`tail /var/log/wo/wordops.log` and please try again...") + "`tail /var/log/wo/wordops.log` " + "and please try again...") except Exception as e: Log.error(self, "Error while installing packages, " @@ -186,7 +191,8 @@ class WOAptGet(): def is_installed(self, package_name): """ - Checks if package is available in cache and is installed or not + Checks if package is available in cache " + "and is installed or not returns True if installed otherwise returns False """ apt_cache = apt.cache.Cache() @@ -209,7 +215,8 @@ class WOAptGet(): WORepo.add(self, repo_url=repo_url) if repo_key is not None: WORepo.add_key(self, repo_key) - proc = subprocess.Popen("apt-get update && DEBIAN_FRONTEND=noninteractive " + proc = subprocess.Popen("apt-get update && " + "DEBIAN_FRONTEND=noninteractive " "apt-get install -o " "Dpkg::Options::=\"--force-confdef\"" " -o " @@ -224,7 +231,8 @@ class WOAptGet(): return True else: Log.error( - self, "Error in fetching dpkg package.\nReverting changes ..", False) + self, "Error in fetching dpkg package.\n" + "Reverting changes ..", False) if repo_url is not None: WORepo.remove(self, repo_url=repo_url) return False diff --git a/wo/core/mysql.py b/wo/core/mysql.py index af2d638..c289405 100644 --- a/wo/core/mysql.py +++ b/wo/core/mysql.py @@ -100,20 +100,22 @@ class WOMysql(): '/var/wo-mysqlbackup') os.makedirs('/var/wo-mysqlbackup') - db = subprocess.check_output(["mysql -Bse \'show databases\'"], + db = subprocess.check_output(["/usr/bin/mysql " + "-Bse \'show databases\'"], universal_newlines=True, shell=True).split('\n') for dbs in db: if dbs == "": continue Log.info(self, "Backing up {0} database".format(dbs)) - p1 = subprocess.Popen("mysqldump {0}" + p1 = subprocess.Popen("/usr/bin/mysqldump {0}" " --max_allowed_packet=1024M" " --single-transaction".format(dbs), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) - p2 = subprocess.Popen("pigz -c > /var/wo-mysqlbackup/{0}{1}.s" - "ql.gz".format(dbs, WOVariables.wo_date), + p2 = subprocess.Popen("/usr/bin/pigz -c > " + "/var/wo-mysqlbackup/{0}{1}.sql.gz" + .format(dbs, WOVariables.wo_date), stdin=p1.stdout, shell=True) diff --git a/wo/core/sslutils.py b/wo/core/sslutils.py index 161a484..98f33d5 100644 --- a/wo/core/sslutils.py +++ b/wo/core/sslutils.py @@ -19,7 +19,8 @@ class SSL: current_date = WOShellExec.cmd_exec_stdout(self, "date -d \"now\" +%s") expiration_date = WOShellExec.cmd_exec_stdout(self, "date -d \"" - "`openssl x509 -in " + "`/usr/bin/openssl " + "x509 -in " "/etc/letsencrypt/live/" "{0}/cert.pem" " -text -noout|grep " @@ -45,7 +46,8 @@ class SSL: "`tail /var/log/wo/wordops.log` and please try again...") expiration_date = WOShellExec.cmd_exec_stdout(self, "date -d " - "\"`openssl x509 -in " + "\"`/usr/bin/openssl " + "x509 -in " "/etc/letsencrypt/live/" "{0}/cert.pem" " -text -noout|grep " diff --git a/wo/core/variables.py b/wo/core/variables.py index 293d79a..c43002f 100644 --- a/wo/core/variables.py +++ b/wo/core/variables.py @@ -69,8 +69,9 @@ class WOVariables(): except Exception as e: wo_user = input("Enter your name: ") wo_email = input("Enter your email: ") - os.system("git config --global user.name {0}".format(wo_user)) - os.system("git config --global user.email {0}".format(wo_email)) + os.system("/usr/bin/git config --global user.name {0}".format(wo_user)) + os.system( + "/usr/bin/git config --global user.email {0}".format(wo_email)) # Get System RAM and SWAP details wo_ram = psutil.virtual_memory().total / (1024 * 1024)