improve code quality according to codacy

This commit is contained in:
VirtuBox
2019-04-30 19:00:14 +02:00
parent 8c21974f0e
commit 09e764cba7
2 changed files with 10 additions and 11 deletions

View File

@@ -41,7 +41,7 @@ class WOInfoController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def info_nginx(self): def info_nginx(self):
"""Display Nginx information""" """Display Nginx information"""
version = os.popen("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() "awk -F ' ' '{print $1}' | tr '\n' ' '").read()
allow = os.popen("grep ^allow /etc/nginx/common/acl.conf | " allow = os.popen("grep ^allow /etc/nginx/common/acl.conf | "
"cut -d' ' -f2 | cut -d';' -f1 | tr '\n' ' '").read() "cut -d' ' -f2 | cut -d';' -f1 | tr '\n' ' '").read()
@@ -66,7 +66,7 @@ class WOInfoController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def info_php(self): def info_php(self):
"""Display PHP information""" """Display PHP information"""
version = os.popen("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 " cut -d'+' -f1 | tr -d '\n'").read
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('/etc/{0}/fpm/php.ini'.format("php/7.2")) config.read('/etc/{0}/fpm/php.ini'.format("php/7.2"))
@@ -140,7 +140,7 @@ class WOInfoController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def info_php73(self): def info_php73(self):
"""Display PHP information""" """Display PHP information"""
version = os.popen("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 " cut -d'+' -f1 | tr -d '\n'").read
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('/etc/php/7.3/fpm/php.ini') config.read('/etc/php/7.3/fpm/php.ini')
@@ -214,23 +214,23 @@ class WOInfoController(CementBaseController):
@expose(hide=True) @expose(hide=True)
def info_mysql(self): def info_mysql(self):
"""Display MySQL information""" """Display MySQL information"""
version = os.popen("mysql -V | awk '{print($5)}' | cut -d ',' " version = os.popen("/usr/bin/mysql -V | awk '{print($5)}' | cut -d ',' "
"-f1 | tr -d '\n'").read() "-f1 | tr -d '\n'").read()
host = "localhost" host = "localhost"
port = os.popen("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() "'{print($2)}' | tr -d '\n'").read()
wait_timeout = os.popen("mysql -e \"show variables\" | grep " wait_timeout = os.popen("/usr/bin/mysql -e \"show variables\" | grep "
"^wait_timeout | awk '{print($2)}' | " "^wait_timeout | awk '{print($2)}' | "
"tr -d '\n'").read() "tr -d '\n'").read()
interactive_timeout = os.popen("mysql -e \"show variables\" | grep " interactive_timeout = os.popen("/usr/bin/mysql -e \"show variables\" | grep "
"^interactive_timeout | awk " "^interactive_timeout | awk "
"'{print($2)}' | tr -d '\n'").read() "'{print($2)}' | tr -d '\n'").read()
max_used_connections = os.popen("mysql -e \"show global status\" | " max_used_connections = os.popen("/usr/bin/mysql -e \"show global status\" | "
"grep Max_used_connections | awk " "grep Max_used_connections | awk "
"'{print($2)}' | tr -d '\n'").read() "'{print($2)}' | tr -d '\n'").read()
datadir = os.popen("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() " '{print($2)}' | tr -d '\n'").read()
socket = os.popen("mysql -e \"show variables\" | grep \"^socket\" | " socket = os.popen("/usr/bin/mysql -e \"show variables\" | grep \"^socket\" | "
"awk '{print($2)}' | tr -d '\n'").read() "awk '{print($2)}' | tr -d '\n'").read()
data = dict(version=version, host=host, port=port, data = dict(version=version, host=host, port=port,
wait_timeout=wait_timeout, wait_timeout=wait_timeout,

View File

@@ -16,7 +16,6 @@ from wo.core.git import WOGit
from wo.core.checkfqdn import check_fqdn from wo.core.checkfqdn import check_fqdn
from pynginxconfig import NginxConfig from pynginxconfig import NginxConfig
from wo.core.services import WOService from wo.core.services import WOService
from wo.core.variables import WOVariables
import random import random
import string import string
import configparser import configparser