reformat code according to pep8
This commit is contained in:
@@ -191,22 +191,22 @@ class WODebugController(CementBaseController):
|
|||||||
nc.savef('/etc/nginx/conf.d/upstream.conf')
|
nc.savef('/etc/nginx/conf.d/upstream.conf')
|
||||||
|
|
||||||
# Enable xdebug
|
# Enable xdebug
|
||||||
WOFileUtils.searchreplace(self, "/etc/{0}/mods-available/".format("php/7.2" if (WOVariables.wo_platform_distro == 'ubuntu') else "php/7.2") +
|
WOFileUtils.searchreplace(self, "/etc/{0}/"
|
||||||
|
"mods-available/".format("php/7.2") +
|
||||||
"xdebug.ini",
|
"xdebug.ini",
|
||||||
";zend_extension",
|
";zend_extension",
|
||||||
"zend_extension")
|
"zend_extension")
|
||||||
|
|
||||||
# Fix slow log is not enabled default in PHP5.6
|
# Fix slow log is not enabled default in PHP5.6
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('/etc/{0}/fpm/pool.d/debug.conf'.format(
|
config.read('/etc/{0}/fpm/pool.d/debug.conf'.format("php/7.2"))
|
||||||
"php/7.2" if (WOVariables.wo_platform_distro == 'ubuntu') else "php5"))
|
config['debug']['slowlog'] = '/var/log/{0}/slow.log'.format(
|
||||||
config['debug']['slowlog'] = '/var/log/{0}/slow.log'.format("php/7.2" if (
|
"php/7.2")
|
||||||
WOVariables.wo_platform_distro == 'ubuntu') else "php5")
|
|
||||||
config['debug']['request_slowlog_timeout'] = '10s'
|
config['debug']['request_slowlog_timeout'] = '10s'
|
||||||
with open('/etc/{0}/fpm/pool.d/debug.conf'.format("php/7.2" if (WOVariables.wo_platform_distro == 'ubuntu') else "php5"),
|
with open('/etc/{0}/fpm/pool.d/debug.conf'.format("php/7.2"),
|
||||||
encoding='utf-8', mode='w') as confifile:
|
encoding='utf-8', mode='w') as confifile:
|
||||||
Log.debug(self, "Writting debug.conf configuration into "
|
Log.debug(self, "Writting debug.conf configuration into "
|
||||||
"/etc/{0}/fpm/pool.d/debug.conf".format("php/7.2" if (WOVariables.wo_platform_distro == 'ubuntu') else "php5"))
|
"/etc/{0}/fpm/pool.d/debug.conf".format("php/7.2"))
|
||||||
config.write(confifile)
|
config.write(confifile)
|
||||||
|
|
||||||
self.trigger_php = True
|
self.trigger_php = True
|
||||||
@@ -214,8 +214,7 @@ class WODebugController(CementBaseController):
|
|||||||
else:
|
else:
|
||||||
Log.info(self, "PHP debug is already enabled")
|
Log.info(self, "PHP debug is already enabled")
|
||||||
|
|
||||||
self.msg = self.msg + ['/var/log/{0}/slow.log'.format("php/7.2" if (
|
self.msg = self.msg + ['/var/log/{0}/slow.log'.format("php/7.2")]
|
||||||
WOVariables.wo_platform_distro == 'ubuntu') else "php5")]
|
|
||||||
|
|
||||||
# PHP global debug stop
|
# PHP global debug stop
|
||||||
elif (self.app.pargs.php == 'off' and not self.app.pargs.site_name):
|
elif (self.app.pargs.php == 'off' and not self.app.pargs.site_name):
|
||||||
@@ -231,7 +230,8 @@ class WODebugController(CementBaseController):
|
|||||||
nc.savef('/etc/nginx/conf.d/upstream.conf')
|
nc.savef('/etc/nginx/conf.d/upstream.conf')
|
||||||
|
|
||||||
# Disable xdebug
|
# Disable xdebug
|
||||||
WOFileUtils.searchreplace(self, "/etc/{0}/mods-available/".format("php/7.2" if (WOVariables.wo_platform_distro == 'ubuntu') else "php5") +
|
WOFileUtils.searchreplace(self, "/etc/{0}/"
|
||||||
|
"mods-available/".format("php/7.2") +
|
||||||
"xdebug.ini",
|
"xdebug.ini",
|
||||||
"zend_extension",
|
"zend_extension",
|
||||||
";zend_extension")
|
";zend_extension")
|
||||||
@@ -247,43 +247,41 @@ class WODebugController(CementBaseController):
|
|||||||
# PHP5-FPM start global debug
|
# PHP5-FPM start global debug
|
||||||
if (self.app.pargs.fpm == 'on' and not self.app.pargs.site_name):
|
if (self.app.pargs.fpm == 'on' and not self.app.pargs.site_name):
|
||||||
if not WOShellExec.cmd_exec(self, "grep \"log_level = debug\" "
|
if not WOShellExec.cmd_exec(self, "grep \"log_level = debug\" "
|
||||||
"/etc/{0}/fpm/php-fpm.conf".format("php/7.2" if (WOVariables.wo_platform_distro == 'ubuntu') else "php5")):
|
"/etc/{0}/"
|
||||||
|
"fpm/php-fpm.conf".format("php/7.2")):
|
||||||
Log.info(self, "Setting up PHP5-FPM log_level = debug")
|
Log.info(self, "Setting up PHP5-FPM log_level = debug")
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('/etc/{0}/fpm/php-fpm.conf'.format("php/7.2" if (
|
config.read('/etc/{0}/fpm/php-fpm.conf'.format("php/7.2"))
|
||||||
WOVariables.wo_platform_distro == 'ubuntu') else "php5"))
|
|
||||||
config.remove_option('global', 'include')
|
config.remove_option('global', 'include')
|
||||||
config['global']['log_level'] = 'debug'
|
config['global']['log_level'] = 'debug'
|
||||||
config['global']['include'] = '/etc/{0}/fpm/pool.d/*.conf'.format("php/7.2" if (
|
config['global']['include'] = '/etc/{0}/fpm/pool.d/*.conf'.format(
|
||||||
WOVariables.wo_platform_distro == 'ubuntu') else "php5")
|
"php/7.2")
|
||||||
with open('/etc/{0}/fpm/php-fpm.conf'.format("php/7.2" if (WOVariables.wo_platform_distro == 'ubuntu') else "php5"),
|
with open('/etc/{0}/fpm/php-fpm.conf'.format("php/7.2"),
|
||||||
encoding='utf-8', mode='w') as configfile:
|
encoding='utf-8', mode='w') as configfile:
|
||||||
Log.debug(self, "Writting php5-FPM configuration into "
|
Log.debug(self, "Writting php5-FPM configuration into "
|
||||||
"/etc/{0}/fpm/php-fpm.conf".format("php/7.2" if (WOVariables.wo_platform_distro == 'ubuntu') else "php5"))
|
"/etc/{0}/fpm/php-fpm.conf".format("php/7.2"))
|
||||||
config.write(configfile)
|
config.write(configfile)
|
||||||
self.trigger_php = True
|
self.trigger_php = True
|
||||||
else:
|
else:
|
||||||
Log.info(self, "PHP5-FPM log_level = debug already setup")
|
Log.info(self, "PHP5-FPM log_level = debug already setup")
|
||||||
|
|
||||||
self.msg = self.msg + ['/var/log/{0}/fpm.log'.format("php/7.2" if (
|
self.msg = self.msg + ['/var/log/{0}/fpm.log'.format("php/7.2")]
|
||||||
WOVariables.wo_platform_distro == 'ubuntu') else "php5")]
|
|
||||||
|
|
||||||
# PHP5-FPM stop global debug
|
# PHP5-FPM stop global debug
|
||||||
elif (self.app.pargs.fpm == 'off' and not self.app.pargs.site_name):
|
elif (self.app.pargs.fpm == 'off' and not self.app.pargs.site_name):
|
||||||
if WOShellExec.cmd_exec(self, "grep \"log_level = debug\" "
|
if WOShellExec.cmd_exec(self, "grep \"log_level = debug\" "
|
||||||
"/etc/{0}/fpm/php-fpm.conf".format("php/7.2" if (WOVariables.wo_platform_distro == 'ubuntu') else "php5")):
|
"/etc/{0}/fpm/php-fpm.conf".format("php/7.2")):
|
||||||
Log.info(self, "Disabling PHP5-FPM log_level = debug")
|
Log.info(self, "Disabling PHP5-FPM log_level = debug")
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read('/etc/{0}/fpm/php-fpm.conf'.format("php/7.2" if (
|
config.read('/etc/{0}/fpm/php-fpm.conf'.format("php/7.2"))
|
||||||
WOVariables.wo_platform_distro == 'ubuntu') else "php5"))
|
|
||||||
config.remove_option('global', 'include')
|
config.remove_option('global', 'include')
|
||||||
config['global']['log_level'] = 'notice'
|
config['global']['log_level'] = 'notice'
|
||||||
config['global']['include'] = '/etc/{0}/fpm/pool.d/*.conf'.format("php/7.2" if (
|
config['global']['include'] = '/etc/{0}/fpm/pool.d/*.conf'.format(
|
||||||
WOVariables.wo_platform_distro == 'ubuntu') else "php5")
|
"php/7.2")
|
||||||
with open('/etc/{0}/fpm/php-fpm.conf'.format("php/7.2" if (WOVariables.wo_platform_distro == 'ubuntu') else "php5"),
|
with open('/etc/{0}/fpm/php-fpm.conf'.format("php/7.2"),
|
||||||
encoding='utf-8', mode='w') as configfile:
|
encoding='utf-8', mode='w') as configfile:
|
||||||
Log.debug(self, "writting php5 configuration into "
|
Log.debug(self, "writting php5 configuration into "
|
||||||
"/etc/{0}/fpm/php-fpm.conf".format("php/7.2" if (WOVariables.wo_platform_distro == 'ubuntu') else "php5"))
|
"/etc/{0}/fpm/php-fpm.conf".format("php/7.2"))
|
||||||
config.write(configfile)
|
config.write(configfile)
|
||||||
|
|
||||||
self.trigger_php = True
|
self.trigger_php = True
|
||||||
@@ -335,7 +333,8 @@ class WODebugController(CementBaseController):
|
|||||||
|
|
||||||
# PHP global debug stop
|
# PHP global debug stop
|
||||||
elif (self.app.pargs.php73 == 'off' and not self.app.pargs.site_name):
|
elif (self.app.pargs.php73 == 'off' and not self.app.pargs.site_name):
|
||||||
if WOShellExec.cmd_exec(self, " sed -n \"/upstream php72 {/,/}/p\" "
|
if WOShellExec.cmd_exec(self, " sed -n \"/upstream "
|
||||||
|
"php72 {/,/}/p\" "
|
||||||
"/etc/nginx/conf.d/upstream.conf "
|
"/etc/nginx/conf.d/upstream.conf "
|
||||||
"| grep 9172"):
|
"| grep 9172"):
|
||||||
Log.info(self, "Disabling PHP 7.2 debug")
|
Log.info(self, "Disabling PHP 7.2 debug")
|
||||||
@@ -399,7 +398,8 @@ class WODebugController(CementBaseController):
|
|||||||
config.write(configfile)
|
config.write(configfile)
|
||||||
self.trigger_php = True
|
self.trigger_php = True
|
||||||
else:
|
else:
|
||||||
Log.info(self, "PHP7.3-FPM log_level = debug already disabled")
|
Log.info(self, "PHP7.3-FPM log_level "
|
||||||
|
"= debug already disabled")
|
||||||
|
|
||||||
@expose(hide=True)
|
@expose(hide=True)
|
||||||
def debug_mysql(self):
|
def debug_mysql(self):
|
||||||
@@ -536,8 +536,8 @@ class WODebugController(CementBaseController):
|
|||||||
self.msg = self.msg + ['/var/log/nginx/*.error.log']
|
self.msg = self.msg + ['/var/log/nginx/*.error.log']
|
||||||
|
|
||||||
# Stop Nginx rewrite debug globally
|
# Stop Nginx rewrite debug globally
|
||||||
elif (self.app.pargs.rewrite == 'off'
|
elif (self.app.pargs.rewrite == 'off' and
|
||||||
and not self.app.pargs.site_name):
|
not self.app.pargs.site_name):
|
||||||
if WOShellExec.cmd_exec(self, "grep \"rewrite_log on;\" "
|
if WOShellExec.cmd_exec(self, "grep \"rewrite_log on;\" "
|
||||||
"/etc/nginx/nginx.conf"):
|
"/etc/nginx/nginx.conf"):
|
||||||
Log.info(self, "Disabling Nginx rewrite logs")
|
Log.info(self, "Disabling Nginx rewrite logs")
|
||||||
@@ -644,10 +644,10 @@ class WODebugController(CementBaseController):
|
|||||||
(not self.app.pargs.fpm73) and (not self.app.pargs.mysql) and
|
(not self.app.pargs.fpm73) and (not self.app.pargs.mysql) and
|
||||||
(not self.app.pargs.wp) and (not self.app.pargs.rewrite) and
|
(not self.app.pargs.wp) and (not self.app.pargs.rewrite) and
|
||||||
(not self.app.pargs.all) and (not self.app.pargs.site_name) and
|
(not self.app.pargs.all) and (not self.app.pargs.site_name) and
|
||||||
(not self.app.pargs.import_slow_log)
|
(not self.app.pargs.import_slow_log) and
|
||||||
and (not self.app.pargs.interval)):
|
(not self.app.pargs.interval)):
|
||||||
if self.app.pargs.stop or self.app.pargs.start:
|
if self.app.pargs.stop or self.app.pargs.start:
|
||||||
print("--start/stop option is deprecated since ee v3.0.5")
|
print("--start/stop option is deprecated since wo v3.0.5")
|
||||||
self.app.args.print_help()
|
self.app.args.print_help()
|
||||||
else:
|
else:
|
||||||
self.app.args.print_help()
|
self.app.args.print_help()
|
||||||
@@ -778,8 +778,8 @@ class WODebugController(CementBaseController):
|
|||||||
if len(self.msg) > 0:
|
if len(self.msg) > 0:
|
||||||
if not self.app.pargs.interactive:
|
if not self.app.pargs.interactive:
|
||||||
disp_msg = ' '.join(self.msg)
|
disp_msg = ' '.join(self.msg)
|
||||||
Log.info(self, "Use following command to check debug logs:\n"
|
Log.info(self, "Use following command to check debug logs:\n" +
|
||||||
+ Log.ENDC + "tail -f {0}".format(disp_msg))
|
Log.ENDC + "tail -f {0}".format(disp_msg))
|
||||||
else:
|
else:
|
||||||
signal.signal(signal.SIGINT, self.signal_handler)
|
signal.signal(signal.SIGINT, self.signal_handler)
|
||||||
watch_list = []
|
watch_list = []
|
||||||
@@ -797,18 +797,18 @@ class WODebugController(CementBaseController):
|
|||||||
# Get Anemometer user name and password
|
# Get Anemometer user name and password
|
||||||
Log.info(self, "Importing MySQL slow log to Anemometer")
|
Log.info(self, "Importing MySQL slow log to Anemometer")
|
||||||
host = os.popen("grep -e \"\'host\'\" {0}22222/htdocs/"
|
host = os.popen("grep -e \"\'host\'\" {0}22222/htdocs/"
|
||||||
.format(WOVariables.wo_webroot)
|
.format(WOVariables.wo_webroot) +
|
||||||
+ "db/anemometer/conf/config.inc.php "
|
"db/anemometer/conf/config.inc.php "
|
||||||
"| head -1 | cut -d\\\' -f4 | "
|
"| head -1 | cut -d\\\' -f4 | "
|
||||||
"tr -d '\n'").read()
|
"tr -d '\n'").read()
|
||||||
user = os.popen("grep -e \"\'user\'\" {0}22222/htdocs/"
|
user = os.popen("grep -e \"\'user\'\" {0}22222/htdocs/"
|
||||||
.format(WOVariables.wo_webroot)
|
.format(WOVariables.wo_webroot) +
|
||||||
+ "db/anemometer/conf/config.inc.php "
|
"db/anemometer/conf/config.inc.php "
|
||||||
"| head -1 | cut -d\\\' -f4 | "
|
"| head -1 | cut -d\\\' -f4 | "
|
||||||
"tr -d '\n'").read()
|
"tr -d '\n'").read()
|
||||||
password = os.popen("grep -e \"\'password\'\" {0}22222/"
|
password = os.popen("grep -e \"\'password\'\" {0}22222/"
|
||||||
.format(WOVariables.wo_webroot)
|
.format(WOVariables.wo_webroot) +
|
||||||
+ "htdocs/db/anemometer/conf"
|
"htdocs/db/anemometer/conf"
|
||||||
"/config.inc.php "
|
"/config.inc.php "
|
||||||
"| head -1 | cut -d\\\' -f4 | "
|
"| head -1 | cut -d\\\' -f4 | "
|
||||||
"tr -d '\n'").read()
|
"tr -d '\n'").read()
|
||||||
@@ -836,9 +836,9 @@ class WODebugController(CementBaseController):
|
|||||||
" so not imported slow logs")
|
" so not imported slow logs")
|
||||||
else:
|
else:
|
||||||
Log.error(self, "Anemometer is not installed." +
|
Log.error(self, "Anemometer is not installed." +
|
||||||
Log.ENDC + "\n Install Anemometer with:"
|
Log.ENDC + "\n Install Anemometer with:" +
|
||||||
+ Log.BOLD + "\n `wo stack install --utils`"
|
Log.BOLD + "\n `wo stack install --utils`" +
|
||||||
+ Log.ENDC)
|
Log.ENDC)
|
||||||
|
|
||||||
|
|
||||||
def load(app):
|
def load(app):
|
||||||
|
|||||||
@@ -444,7 +444,8 @@ class WOLogMailController(CementBaseController):
|
|||||||
(['--nginx'],
|
(['--nginx'],
|
||||||
dict(help='Mail Nginx Error logs file', action='store_true')),
|
dict(help='Mail Nginx Error logs file', action='store_true')),
|
||||||
(['--php'],
|
(['--php'],
|
||||||
dict(help='Mail PHP 7.2 Error logs file', action='store_true')),
|
dict(help='Mail PHP 7.2 Error logs file',
|
||||||
|
action='store_true')),
|
||||||
(['--fpm'],
|
(['--fpm'],
|
||||||
dict(help='Mail PHP 7.2-fpm slow logs file',
|
dict(help='Mail PHP 7.2-fpm slow logs file',
|
||||||
action='store_true')),
|
action='store_true')),
|
||||||
|
|||||||
@@ -107,7 +107,8 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
if self.app.pargs.php:
|
if self.app.pargs.php:
|
||||||
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||||
if not WOAptGet.is_installed(self, 'php7.3-fpm'):
|
if not WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||||
apt_packages = apt_packages + WOVariables.wo_php + WOVariables.wo_php_extra
|
apt_packages = apt_packages + WOVariables.wo_php + \
|
||||||
|
WOVariables.wo_php_extra
|
||||||
else:
|
else:
|
||||||
apt_packages = apt_packages + WOVariables.wo_php
|
apt_packages = apt_packages + WOVariables.wo_php
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ Set CRON on LINUX system.
|
|||||||
|
|
||||||
|
|
||||||
class WOCron():
|
class WOCron():
|
||||||
def setcron_weekly(self, cmd, comment='Cron set by WordOps', user='root', min=0, hour=12):
|
def setcron_weekly(self, cmd, comment='Cron set by WordOps', user='root',
|
||||||
if not WOShellExec.cmd_exec(self, "crontab -l | grep -q \'{0}\'".format(cmd)):
|
min=0, hour=12):
|
||||||
|
if not WOShellExec.cmd_exec(self, "crontab -l "
|
||||||
|
"| grep -q \'{0}\'".format(cmd)):
|
||||||
|
|
||||||
WOShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l "
|
WOShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l "
|
||||||
"2> /dev/null | {{ cat; echo -e"
|
"2> /dev/null | {{ cat; echo -e"
|
||||||
@@ -20,7 +22,8 @@ class WOCron():
|
|||||||
Log.debug(self, "Cron set")
|
Log.debug(self, "Cron set")
|
||||||
|
|
||||||
def remove_cron(self, cmd):
|
def remove_cron(self, cmd):
|
||||||
if WOShellExec.cmd_exec(self, "crontab -l | grep -q \'{0}\'".format(cmd)):
|
if WOShellExec.cmd_exec(self, "crontab -l "
|
||||||
|
"| grep -q \'{0}\'".format(cmd)):
|
||||||
if not WOShellExec.cmd_exec(self, "/bin/bash -c "
|
if not WOShellExec.cmd_exec(self, "/bin/bash -c "
|
||||||
"\"crontab "
|
"\"crontab "
|
||||||
"-l | sed '/{0}/d'"
|
"-l | sed '/{0}/d'"
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class WOMysql():
|
|||||||
" --single-transaction".format(dbs),
|
" --single-transaction".format(dbs),
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE, shell=True)
|
stderr=subprocess.PIPE, shell=True)
|
||||||
p2 = subprocess.Popen("gzip -c > /var/wo-mysqlbackup/{0}{1}.s"
|
p2 = subprocess.Popen("pigz -c > /var/wo-mysqlbackup/{0}{1}.s"
|
||||||
"ql.gz".format(dbs, WOVariables.wo_date),
|
"ql.gz".format(dbs, WOVariables.wo_date),
|
||||||
stdin=p1.stdout,
|
stdin=p1.stdout,
|
||||||
shell=True)
|
shell=True)
|
||||||
|
|||||||
@@ -116,7 +116,8 @@ class WOService():
|
|||||||
try:
|
try:
|
||||||
is_exist = subprocess.getstatusoutput('which {0}'
|
is_exist = subprocess.getstatusoutput('which {0}'
|
||||||
.format(service_name))
|
.format(service_name))
|
||||||
if is_exist[0] == 0 or service_name in ['php7.2-fpm', 'php7.3-fpm']:
|
if is_exist[0] == 0 or service_name in ['php7.2-fpm',
|
||||||
|
'php7.3-fpm']:
|
||||||
retcode = subprocess.getstatusoutput('service {0} status'
|
retcode = subprocess.getstatusoutput('service {0} status'
|
||||||
.format(service_name))
|
.format(service_name))
|
||||||
if retcode[0] == 0:
|
if retcode[0] == 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user