Browse Source

Merged branch Python

bugfixes
harshadyeola 10 years ago
parent
commit
2ec17aa3f7
  1. 11
      config/bash_completion.d/ee_auto.rc
  2. 8
      config/plugins.d/log.conf
  3. 23
      ee/cli/plugins/debug.py
  4. 76
      ee/cli/plugins/log.py
  5. 12
      ee/cli/plugins/site.py
  6. 72
      ee/cli/plugins/site_functions.py
  7. 2
      ee/cli/plugins/stack.py
  8. 2
      ee/core/variables.py
  9. 2
      install
  10. 2
      setup.py

11
config/bash_completion.d/ee_auto.rc

@ -11,7 +11,7 @@ _ee_complete()
# SETUP THE BASE LEVEL (everything after "ee")
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $(compgen \
-W "stack site debug clean secure import-slow-log" \
-W "stack site debug clean secure import-slow-log log" \
-- $cur) )
@ -57,6 +57,12 @@ _ee_complete()
-- $cur) )
;;
"log")
COMPREPLY=( $(compgen \
-W "--mysql --php --nginx --all" \
-- $cur) )
;;
# EVERYTHING ELSE
*)
;;
@ -147,6 +153,9 @@ _ee_complete()
retlist="--nginx --php --mysql --postfix --memcache --dovecot"
elif [[ ${COMP_WORDS[1]} == "debug" ]]; then
retlist="--start --nginx --php --fpm --mysql -i --interactive --stop"
if [[ $prev == '--mysql' ]]; then
retlist="--start --nginx --php --fpm --mysql -i --interactive --stop --import-slow-log"
fi
fi
ret="${retlist[@]/$prev}"
COMPREPLY=( $(compgen \

8
config/plugins.d/log.conf

@ -0,0 +1,8 @@
### Example Plugin Configuration for EasyEngine
[log]
### If enabled, load a plugin named `example` either from the Python module
### `ee.cli.plugins.example` or from the file path
### `/var/lib/ee/plugins/example.py`
enable_plugin = true

23
ee/cli/plugins/debug.py

@ -12,6 +12,7 @@ import os
import configparser
import glob
import signal
import subprocess
def debug_plugin_hook(app):
@ -160,7 +161,7 @@ class EEDebugController(CementBaseController):
# PHP global debug stop
else:
if EEShellExec.cmd_exec(self, "sed -n \"/upstream php {/,/}/p\" "
if EEShellExec.cmd_exec(self, " sed -n \"/upstream php {/,/}/p\" "
"/etc/nginx/conf.d/upstream.conf "
"| grep 9001"):
Log.info(self, "Disabling PHP debug")
@ -241,13 +242,16 @@ class EEDebugController(CementBaseController):
cron_time = int(self.app.pargs.interval)
except Exception as e:
cron_time = 5
EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l 2> "
"/dev/null | {{ cat; echo -e"
" \\\"#EasyEngine start MySQL slow"
" log \\n*/{0} * * * * "
"/usr/local/sbin/ee import-slow-log\\"
"n#EasyEngine end MySQL slow log\\\";"
" }} | crontab -\"".format(cron_time))
EEShellExec.cmd_exec(self, "/bin/bash -c \"crontab -l "
"2> /dev/null | {{ cat; echo -e"
" \\\"#EasyEngine start MySQL "
"slow log \\n*/{0} * * * * "
"/usr/local/bin/ee "
"import-slow-log\\n"
"#EasyEngine end MySQL slow log"
"\\\"; }} | crontab -\""
.format(cron_time))
else:
Log.info(self, "MySQL slow log is already enabled")
@ -296,7 +300,8 @@ class EEDebugController(CementBaseController):
" {0}".format(wp_config))
EEShellExec.cmd_exec(self, "cd {0}/htdocs/ && wp"
" plugin --allow-root install "
"developer".format(webroot))
"developer query-monitor"
.format(webroot))
EEShellExec.cmd_exec(self, "chown -R {1}: {0}/htdocs/"
"wp-content/plugins"
.format(webroot,

76
ee/cli/plugins/log.py

@ -0,0 +1,76 @@
"""Debug Plugin for EasyEngine"""
from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
from ee.core.logging import Log
from ee.cli.plugins.site_functions import logwatch
from ee.core.variables import EEVariables
import os
import glob
def log_plugin_hook(app):
# do something with the ``app`` object here.
pass
class EELogController(CementBaseController):
class Meta:
label = 'log'
description = 'Show Nginx, PHP, MySQL log file'
stacked_on = 'base'
stacked_type = 'nested'
arguments = [
(['--all'],
dict(help='Show All logs file', action='store_true')),
(['--nginx'],
dict(help='Show Nginx logs file', action='store_true')),
(['--php'],
dict(help='Show PHP logs file', action='store_true')),
(['--mysql'],
dict(help='Show MySQL logs file', action='store_true')),
]
@expose(hide=True)
def default(self):
"""Default function of debug"""
self.msg = []
if ((not self.app.pargs.nginx) and (not self.app.pargs.php)
and (not self.app.pargs.mysql)):
self.app.pargs.nginx = True
self.app.pargs.php = True
self.app.pargs.mysql = True
if self.app.pargs.nginx:
self.msg = self.msg + ["/var/log/nginx/*error.log"]
if self.app.pargs.php:
open('/var/log/php5/slow.log', 'a').close()
open('/var/log/php5/fpm.log', 'a').close()
self.msg = self.msg + ['/var/log/php5/slow.log',
'/var/log/php5/fpm.log']
if self.app.pargs.mysql:
# MySQL debug will not work for remote MySQL
if EEVariables.ee_mysql_host is "localhost":
if os.path.isfile('/var/log/mysql/mysql-slow.log'):
self.msg = self.msg + ['/var/log/mysql/mysql-slow.log']
else:
Log.error(self, "Unable to find MySQL slow log file,"
"Please generate it using commnad ee debug "
"--mysql")
else:
Log.warn(self, "Remote MySQL found, EasyEngine is not able to"
"show MySQL log file")
watch_list = []
for w_list in self.msg:
watch_list = watch_list + glob.glob(w_list)
logwatch(self, watch_list)
def load(app):
# register the plugin class.. this only happens if the plugin is enabled
handler.register(EELogController)
# register a hook (function) to run after arguments are parsed.
hook.register('post_argument_parsing', log_plugin_hook)

12
ee/cli/plugins/site.py

@ -513,7 +513,7 @@ class EESiteCreateController(CementBaseController):
setwebrootpermissions(self, data['webroot'])
if ee_auth and len(ee_auth):
for msg in ee_auth:
Log.info(self, Log.ENDC + msg)
Log.info(self, Log.ENDC + msg, log=False)
if data['wp']:
Log.info(self, Log.ENDC + "WordPress admin user :"
@ -976,12 +976,12 @@ class EESiteUpdateController(CementBaseController):
for msg in ee_auth:
Log.info(self, Log.ENDC + msg)
display_cache_settings(self, data)
if data['wp'] and oldsitetype in ['html', 'php', 'mysql']:
Log.info(self, "\n\n" + Log.ENDC + "WordPress admin user :"
" {0}".format(ee_wp_creds['wp_user']))
Log.info(self, Log.ENDC + "WordPress admin password : {0}"
.format(ee_wp_creds['wp_pass']) + "\n\n")
display_cache_settings(self, data)
updateSiteInfo(self, ee_www_domain, stype=stype, cache=cache)
Log.info(self, "Successfully updated site"
" http://{0}".format(ee_domain))
@ -1100,15 +1100,15 @@ class EESiteDeleteController(CementBaseController):
'DB_HOST').split(',')[1]
.split(')')[0].strip().replace('\'', ''))
try:
Log.debug(self, "dropping database {0}".format(ee_db_name))
Log.debug(self, "dropping database `{0}`".format(ee_db_name))
EEMysql.execute(self,
"drop database {0}".format(ee_db_name),
"drop database `{0}`".format(ee_db_name),
errormsg='Unable to drop database {0}'
.format(ee_db_name))
if ee_db_user != 'root':
Log.debug(self, "dropping user {0}".format(ee_db_user))
Log.debug(self, "dropping user `{0}`".format(ee_db_user))
EEMysql.execute(self,
"drop user {0}@{1}"
"drop user `{0}`@`{1}`"
.format(ee_db_user, ee_db_host))
EEMysql.execute(self,
"flush privileges")

72
ee/cli/plugins/site_functions.py

@ -184,7 +184,8 @@ def setupwordpress(self, data):
Log.debug(self, "Generating wp-config for WordPress Single site")
Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root "
+ "core config "
+ "--dbname={0} --dbprefix={1} --dbuser={2} --dbhost={3} "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' "
"--dbhost=\'{3}\' "
.format(data['ee_db_name'], ee_wp_prefix,
data['ee_db_user'], data['ee_db_host'])
+ "--dbpass= "
@ -193,22 +194,25 @@ def setupwordpress(self, data):
"\n\ndefine(\'WP_DEBUG\', false);"))
EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root "
+ "core config "
+ "--dbname={0} --dbprefix={1} --dbuser={2} --dbhost={3} "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' "
"--dbuser=\'{2}\' --dbhost=\'{3}\' "
.format(data['ee_db_name'], ee_wp_prefix,
data['ee_db_user'], data['ee_db_host'])
+ "--dbpass={0} "
data['ee_db_user'], data['ee_db_host'])
+ "--dbpass=\'{0}\' "
"--extra-php<<PHP \n {1}\nPHP\""
.format(data['ee_db_pass'],
"\n\ndefine(\'WP_DEBUG\', false);"),
log=False
)
) or Log.error(self,
"Unable to Generate "
"wp-config")
else:
Log.debug(self, "Generating wp-config for WordPress multisite")
Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root "
+ "core config "
+ "--dbname={0} --dbprefix={1} --dbhost={2} "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' "
.format(data['ee_db_name'], ee_wp_prefix, data['ee_db_host'])
+ "--dbuser={0} --dbpass= "
+ "--dbuser=\'{0}\' --dbpass= "
"--extra-php<<PHP \n {2} {3} {4}\nPHP\""
.format(data['ee_db_user'], data['ee_db_pass'],
"\ndefine(\'WP_ALLOW_MULTISITE\', "
@ -218,9 +222,11 @@ def setupwordpress(self, data):
"\n\ndefine(\'WP_DEBUG\', false);"))
EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root "
+ "core config "
+ "--dbname={0} --dbprefix={1} --dbhost={2} "
.format(data['ee_db_name'], ee_wp_prefix, data['ee_db_host'])
+ "--dbuser={0} --dbpass={1} "
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' "
"--dbhost=\'{2}\' "
.format(data['ee_db_name'], ee_wp_prefix,
data['ee_db_host'])
+ "--dbuser=\'{0}\' --dbpass=\'{1}\' "
"--extra-php<<PHP \n {2} {3} {4}\nPHP\""
.format(data['ee_db_user'], data['ee_db_pass'],
"\ndefine(\'WP_ALLOW_MULTISITE\', "
@ -229,7 +235,9 @@ def setupwordpress(self, data):
" true);",
"\n\ndefine(\'WP_DEBUG\', false);"),
log=False
)
) or Log.error(self,
"Unable to Generate "
"wp-config")
EEFileUtils.mvfile(self, os.getcwd()+'/wp-config.php',
os.path.abspath(os.path.join(os.getcwd(), os.pardir)))
@ -257,43 +265,61 @@ def setupwordpress(self, data):
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to input WordPress user email")
try:
while not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$",
ee_wp_email):
Log.info(self, "EMail not Valid in config, "
"Please provide valid email id")
ee_wp_email = input("Enter your email: ")
except EOFError as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to input WordPress user email")
Log.debug(self, "Setting up WordPress tables")
if not data['multisite']:
Log.debug(self, "Creating tables for WordPress Single site")
Log.debug(self, "php /usr/bin/wp --allow-root core install "
"--url={0} --title={0} --admin_name={1} "
"--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
.format(data['www_domain'], ee_wp_user)
+ "--admin_password= --admin_email={1}"
+ "--admin_password= --admin_email=\'{1}\'"
.format(ee_wp_pass, ee_wp_email))
EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core install "
"--url={0} --title={0} --admin_name={1} "
"--url=\'{0}\' --title=\'{0}\' "
"--admin_name=\'{1}\' "
.format(data['www_domain'], ee_wp_user)
+ "--admin_password={0} --admin_email={1}"
+ "--admin_password=\'{0}\' --admin_email=\'{1}\'"
.format(ee_wp_pass, ee_wp_email),
errormsg="Unable to setup WordPress Tables",
log=False)
log=False) or Log.error(self,
"Unable to setup "
"WordPress Tables")
else:
Log.debug(self, "Creating tables for WordPress multisite")
Log.debug(self, "php /usr/bin/wp --allow-root "
"core multisite-install "
"--url={0} --title={0} --admin_name={1} "
"--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
.format(data['www_domain'], ee_wp_user)
+ "--admin_password= --admin_email={1} "
+ "--admin_password= --admin_email=\'{1}\' "
"{subdomains}"
.format(ee_wp_pass, ee_wp_email,
subdomains='--subdomains'
if not data['wpsubdir'] else ''))
EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root "
"core multisite-install "
"--url={0} --title={0} --admin_name={1} "
"--url=\'{0}\' --title=\'{0}\' "
"--admin_name=\'{1}\' "
.format(data['www_domain'], ee_wp_user)
+ "--admin_password={0} --admin_email={1} "
+ "--admin_password=\'{0}\' "
"--admin_email=\'{1}\' "
"{subdomains}"
.format(ee_wp_pass, ee_wp_email,
subdomains='--subdomains'
if not data['wpsubdir'] else ''),
errormsg="Unable to setup WordPress Tables")
errormsg="Unable to setup WordPress Tables",
log=False) or Log.error(self,
"Unable to setup "
"WordPress Tables")
Log.debug(self, "Updating WordPress permalink")
EEShellExec.cmd_exec(self, " php /usr/bin/wp --allow-root "
@ -323,7 +349,7 @@ def setupwordpressnetwork(self, data):
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
Log.info(self, "Setting up WordPress Network \t", end='')
EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert'
' --title={0} {subdomains}'
' --title=\'{0}\' {subdomains}'
.format(data['www_domain'], subdomains='--subdomains'
if not data['wpsubdir'] else ''))
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
@ -331,7 +357,7 @@ def setupwordpressnetwork(self, data):
def installwp_plugin(self, plugin_name, data):
ee_site_webroot = data['webroot']
Log.debug(self, "Installing plugin {0}".format(plugin_name))
Log.info(self, "Installing plugin {0}".format(plugin_name))
EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin --allow-root install "
"{0}".format(plugin_name),

2
ee/cli/plugins/stack.py

@ -1308,7 +1308,7 @@ class EEStackController(CementBaseController):
self.pre_pref(apt_packages)
if len(apt_packages):
EESwap.add(self)
Log.debug(self, "Updating apt-cache")
Log.info(self, "Updating apt-cache")
EEAptGet.update(self)
EEAptGet.install(self, apt_packages)
if len(packages):

2
ee/core/variables.py

@ -12,7 +12,7 @@ class EEVariables():
"""Intialization of core variables"""
# EasyEngine version
ee_version = "3.0.3"
ee_version = "3.0.4"
# EasyEngine packages versions
ee_wp_cli = "0.18.0"

2
install

@ -5,7 +5,7 @@
# to update current EasyEngine from 2.x to 3.x
old_ee_version="2.2.3"
new_ee_version="3.0.3"
new_ee_version="3.0.4"
branch=$1
# Define echo function

2
setup.py

@ -54,7 +54,7 @@ except Exception as e:
os.system("git config --global user.email {0}".format(ee_email))
setup(name='ee',
version='3.0.3',
version='3.0.4',
description=long_description,
long_description=long_description,
classifiers=[],

Loading…
Cancel
Save