diff --git a/ee/cli/plugins/clean.py b/ee/cli/plugins/clean.py index b345150c..13d3d805 100644 --- a/ee/cli/plugins/clean.py +++ b/ee/cli/plugins/clean.py @@ -53,11 +53,11 @@ class EECleanController(CementBaseController): try: if(EEAptGet.is_installed("memcached")): EEService.restart_service(self, "memcached") - Log.info(self, "Cleaning memcache..") + Log.info(self, "Cleaning memcache...") else: - Log.error(self, "Memcache not installed") + Log.error(self, "Memcache not installed{0}".format("[FAIL]")) except: - Log.error(self, "Unable to restart memcached") + Log.error(self, "Unable to restart memcached{0}".format("[FAIL]")) @expose(hide=True) def clean_fastcgi(self): @@ -65,16 +65,18 @@ class EECleanController(CementBaseController): Log.info(self, "Cleaning NGINX FastCGI cache, please wait...") EEShellExec.cmd_exec(self, "rm -rf /var/run/nginx-cache/*") else: - Log.error(self, "Unable to clean FastCGI cache") + Log.error(self, "Unable to clean FastCGI cache{0}" + .format("[FAIL]")) @expose(hide=True) def clean_opcache(self): try: - Log.info(self, "Cleaning opcache.... ") + Log.info(self, "Cleaning opcache... ") wp = urllib.request.urlopen(" https://127.0.0.1:22222/cache" "/opcache/opgui.php?page=reset").read() except Exception as e: - Log.error(self, "Unable to clean opacache {0}".format(e)) + Log.error(self, "Unable to clean opacache {0:10}{1}" + .format(e, "[FAIL]")) def load(app): diff --git a/ee/cli/plugins/secure.py b/ee/cli/plugins/secure.py index 400962f6..fc336e77 100644 --- a/ee/cli/plugins/secure.py +++ b/ee/cli/plugins/secure.py @@ -75,14 +75,16 @@ class EEsecureController(CementBaseController): "/etc/nginx/sites-available/22222" .format(port=port)) else: - Log.info(self, "Unable to change EasyEngine admin port") + Log.info(self, "Unable to change EasyEngine admin port{0}" + .format("[FAIL]")) if EEVariables.ee_platform_distro == 'Debian': EEShellExec.cmd_exec(self, "sed -i \"s/listen.*/listen " "{port} default_server ssl;/\" " "/etc/nginx/sites-available/22222" .format(port=port)) else: - Log.info(self, "Unable to change EasyEngine admin port") + Log.info(self, "Unable to change EasyEngine admin port{0}" + .format("[FAIL]")) @expose(hide=True) def secure_ip(self): diff --git a/ee/cli/plugins/stack_services.py b/ee/cli/plugins/stack_services.py index 4f081d15..666b404e 100644 --- a/ee/cli/plugins/stack_services.py +++ b/ee/cli/plugins/stack_services.py @@ -124,4 +124,4 @@ class EEStackStatusController(CementBaseController): services = services + ['nginx', 'php5-fpm', 'mysql', 'postfix'] for service in services: if EEService.get_service_status(self, service): - Log.info(self, "{0}: Running".format(service)) + Log.info(self, "{0:10}: {1}".format(service, "Running")) diff --git a/ee/core/download.py b/ee/core/download.py index c7a22e8f..f2be973a 100644 --- a/ee/core/download.py +++ b/ee/core/download.py @@ -22,12 +22,12 @@ class EEDownload(): Log.info(self, "Downloading "+pkg_name+" ...") urllib.request.urlretrieve(url, filename) except urllib.error.URLError as e: - Log.error(self, "Unable to donwload file, [{err}] [FAIL]" - .format(err=str(e.reason))) + Log.error(self, "Unable to donwload file, [{err}]{1}" + .format("[FAIL]", err=str(e.reason))) return False except urllib.error.HTTPError as e: - Log.error(self, "Package download failed. [{err}] [FAIL]" - .format(err=str(e.reason))) + Log.error(self, "Package download failed. [{err}] {1}" + .format("[FAIL]", err=str(e.reason))) return False except urllib.error.ContentTooShortError as e: Log.error(self, "Package download failed. The amount of the" diff --git a/ee/core/extract.py b/ee/core/extract.py index 91f58d53..a25d7306 100644 --- a/ee/core/extract.py +++ b/ee/core/extract.py @@ -15,6 +15,6 @@ class EEExtract(): os.remove(file) return True except tarfile.TarError as e: - Log.error(self, 'Unable to extract file \{0} {1} [FAIL]' - .format(e.errno, e.strerror)) + Log.error(self, 'Unable to extract file \{0} {1}{2}' + .format(e.errno, e.strerror, "[FAIL]")) return False diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index d497eed3..66afde52 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -35,8 +35,8 @@ class EEFileUtils(): try: os.symlink(src, dst) except Exception as e: - Log.error(self, "Unable to create symbolic link ...\n {0}" - " {1}".format(e.errno, e.strerror)) + Log.error(self, "Unable to create symbolic link ...\n {0} " + " {1} {2}".format(e.errno, e.strerror, "[FAIL]")) sys.exit(1) else: Log.debug(self, "Destination: {0} exists".format(dst)) @@ -45,8 +45,8 @@ class EEFileUtils(): try: os.unlink(filepath) except Exception as e: - Log.error(self, "Unable to reomove symbolic link ...\n {0} {1}" - .format(e.errno, e.strerror)) + Log.error(self, "Unable to reomove symbolic link ...\n {0} {1} {2}" + .format(e.errno, e.strerror, "[FAIL]")) sys.exit(1) def copyfile(self, src, dest): @@ -69,16 +69,16 @@ class EEFileUtils(): try: shutil.move(src, dst) except shutil.Error as e: - Log.error(self, 'Unable to move file {err}' - .format(err=str(e.reason))) + Log.error(self, 'Unable to move file {err}{1}' + .format("[FAIL]", err=str(e.reason))) sys.exit(1) def chdir(self, path): try: os.chdir(path) except OSError as e: - Log.error(self, 'Unable to Change Directory {err}' - .format(err=e.strerror)) + Log.error(self, 'Unable to Change Directory {1}{err}' + .format("[FAIL]", err=e.strerror)) sys.exit(1) def chown(self, path, user, group, recursive=False): @@ -94,10 +94,12 @@ class EEFileUtils(): else: shutil.chown(path, user=user, group=group) except shutil.Error as e: - Log.error(self, "Unable to change owner : {0} ".format(e)) + Log.error(self, "Unable to change owner : {0}{1}" + .format(e, "[FAIL]")) sys.exit(1) except Exception as e: - Log.error(self, "Unable to change owner {0}".format(e)) + Log.error(self, "Unable to change owner {0}{1}" + .format(e, "[FAIL]")) sys.exit(1) def chmod(self, path, perm, recursive=False): @@ -111,15 +113,16 @@ class EEFileUtils(): else: os.chmod(path, perm) except OSError as e: - Log.error(self, "Unable to change owner {0}".format(e.strerror)) + Log.error(self, "Unable to change owner {0}{1}" + .format(e.strerror, "[FAIL]")) sys.exit(1) def mkdir(self, path): try: os.makedirs(path) except OSError as e: - Log.error(self, "Unable to create directory {0}" - .format(e.strerror)) + Log.error(self, "Unable to create directory {0}{1} " + .format(e.strerror, "[FAIL]")) sys.exit(1) def isexist(self, path): @@ -129,8 +132,8 @@ class EEFileUtils(): else: return (False) except OSError as e: - Log.error(self, "Unable to check path {0}" - .format(e.strerror)) + Log.error(self, "Unable to check path {0}{1}" + .format(e.strerror, "[FAIL]")) sys.exit(1) def grep(self, fnm, sstr): @@ -139,6 +142,6 @@ class EEFileUtils(): if sstr in line: return line except OSError as e: - Log.error(self, "Unable to Search string {0}" - .format(e.strerror)) + Log.error(self, "Unable to Search string {0}{1}" + .format(e.strerror, "[FAIL]")) sys.exit(1) diff --git a/ee/core/mysql.py b/ee/core/mysql.py index 883752f2..ff2ee15e 100644 --- a/ee/core/mysql.py +++ b/ee/core/mysql.py @@ -30,15 +30,15 @@ class EEMysql(): user=user, passwd=passwd) cur = conn.cursor() except Exception as e: - Log.error(self, 'Unable to connect to database: {0}' - .format(e)) + Log.error(self, 'Unable to connect to database: {0} {1}' + .format(e, "[FAIL]")) sys.exit(1) try: cur.execute(statement) except Exception as e: - Log.error(self, 'Error occured while executing: {0}' - .format(e)) + Log.error(self, 'Unable to execute statement: {0} {1}' + .format(e, "[FAIL]")) cur.close() conn.close() sys.exit(1) diff --git a/ee/core/services.py b/ee/core/services.py index b8c3ee0f..445c522c 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -4,6 +4,7 @@ import sys import subprocess from subprocess import Popen from ee.core.logging import Log +import pystache class EEService(): @@ -17,13 +18,13 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} start' .format(service_name)) if retcode[0] == 0: - Log.info(self, "Started : {0} [ok]" - .format(service_name)) + Log.info(self, "Started : {0:10}{1}" + .format(service_name, "[OK]")) else: Log.error(self, retcode[1]) except OSError as e: - Log.error(self, "Failed to start service {0} {1} [FAIL]" - .format(e.errno, e.strerror)) + Log.error(self, "Failed to start service {0} {1} {2}" + .format(e.errno, e.strerror, "[FAIL]")) return False def stop_service(self, service_name): @@ -31,25 +32,25 @@ class EEService(): retcode = subprocess.getstatusoutput('service {0} stop' .format(service_name)) if retcode[0] == 0: - Log.info(self, "Stopped : {0} [OK]" - .format(service_name)) + Log.info(self, "Stopped : {0:10}{1}" + .format(service_name, "[OK]")) return True else: return False except OSError as e: - Log.error(self, "Failed to stop service : {0}{1} [FAIL]" - .format(e.errno, e.strerror)) + Log.error(self, "Failed to stop service : {0}{1}{2}" + .format(e.errno, e.strerror, "[FAIL]")) return False def restart_service(self, service_name): try: EEService.stop_service(self, service_name) EEService.start_service(self, service_name) - Log.info(self, "restart : {0} [OK]" - .format(service_name)) + Log.info(self, "restart : {0:10}{1}" + .format(service_name, "[OK]")) except OSError as e: - Log.error(self, "Failed to restart services \{0} {1} [FAIL]" - .format(e.errno, e.strerror)) + Log.error(self, "Failed to restart services \{0} {1} {2}" + .format(e.errno, e.strerror, "[FAIL]")) def reload_service(self, service_name): try: @@ -59,34 +60,32 @@ class EEService(): if retcode[0] == 0: subprocess.getstatusoutput('service {0} reload' .format(service_name)) - Log.info(self, "reload : {0} [OK]" - .format(service_name)) + Log.info(self, "reload : {0} {0:10}" + .format(service_name, "[OK]")) return True else: - Log.error(self, "reload : {0} [FAIL]" - .format(service_name)) - Log.debug("{0}" - .format(retcode[1])) + Log.error(self, "reload : {0}{1}" + .format(service_name, "[FAIL]")) + Log.debug("{0}".format(retcode[1])) return False retcode = subprocess.getstatusoutput('service {0} reload' .format(service_name)) if retcode[0] == 0: - Log.info(self, "reload : {0} [OK]" - .format(service_name)) + Log.info(self, "reload : {0:10}{1}" + .format(service_name, "[OK]")) return True else: return False except OSError as e: - - Log.error(self, "Failed to reload {0} {1} [FAIL]" - .format(service_name, e)) - sys.exit(1) + Log.error(self, "Failed to reload {0} {1} {2}" + .format(service_name, e, "[FAIL]")) + sys.exit(1) def get_service_status(self, service_name): try: is_exist = subprocess.getstatusoutput('which {0}' - .format(service_name))[0] + .format(service_name)) if is_exist == 0: retcode = subprocess.getstatusoutput('service {0} status' .format(service_name)) @@ -97,6 +96,6 @@ class EEService(): else: return False except OSError as e: - Log.error(self, "Unable to get services status \ {0}{1} [FAIL]" - .format(e.errno, e.strerror)) + Log.error(self, "Unable to get services status \ {0}{1}{2}" + .format(e.errno, e.strerror, "[FAIL]")) return False diff --git a/ee/core/shellexec.py b/ee/core/shellexec.py index 45130607..54c85f1f 100644 --- a/ee/core/shellexec.py +++ b/ee/core/shellexec.py @@ -24,10 +24,8 @@ class EEShellExec(): if errormsg: Log.error(self, errormsg) else: - Log.error(self, "Unable to execute command \ {0}{1}" - .format(e.errno, e.strerror)) - Log.debug(self, "Unable to execute command \ {0}{1}" - .format(e.errno, e.strerror)) + Log.error(self, "Unable to execute command \ {0}{1}{2}" + .format(e.errno, e.strerror, "[FAIL]")) sys.exit(1) def invoke_editor(self, filepath, errormsg=''): @@ -37,8 +35,6 @@ class EEShellExec(): if errormsg: Log.error(self, errormsg) else: - Log.error(self, "Unable to edit file \ {0}{1}" - .format(e.errno, e.strerror)) - Log.debug(self, "Unable to edit file \ {0}{1}" - .format(e.errno, e.strerror)) + Log.error(self, "Unable to edit file \ {0}{1}{2}" + .format(e.errno, e.strerror, "[FAIL]")) sys.exit(1)