From ec69cc6090ccd92ccd91e98f4be5ee729fdee054 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Thu, 12 Feb 2015 15:12:54 +0530 Subject: [PATCH] Traceback handled --- ee/cli/plugins/site.py | 18 ++++++++++++++---- ee/cli/plugins/site_functions.py | 8 +++++--- ee/core/aptget.py | 1 + 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index f73ea40c..58f9c006 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -47,12 +47,14 @@ class EESiteController(CementBaseController): .format(ee_domain), '/etc/nginx/sites-enabled/{0}' .format(ee_domain)]) - + EEGit.add(self, ["/etc/nginx"], + msg="Enabled {0} " + .format(ee_domain)) updateSiteInfo(self, ee_domain, enabled=True) Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") EEService.reload_service(self, 'nginx') else: - Log.error(self, " site {0} does not exists".format(ee_domain)) + Log.error(self, "\nsite {0} does not exists".format(ee_domain)) @expose(help="Disable site example.com") def disable(self): @@ -62,12 +64,15 @@ class EESiteController(CementBaseController): .format(ee_domain)): if not os.path.isfile('/etc/nginx/sites-enabled/{0}' .format(ee_domain)): - Log.debug(self, "Site {0} already disabled" + ee_domain) + Log.debug(self, "Site {0} already disabled".format(ee_domain)) Log.info(self, "[" + Log.FAIL + "Failed" + Log.OKBLUE+"]") else: EEFileUtils.remove_symlink(self, '/etc/nginx/sites-enabled/{0}' .format(ee_domain)) + EEGit.add(self, ["/etc/nginx"], + msg="Disabled {0} " + .format(ee_domain)) updateSiteInfo(self, ee_domain, enabled=False) Log.info(self, "[" + Log.ENDC + "OK" + Log.OKBLUE + "]") EEService.reload_service(self, 'nginx') @@ -934,7 +939,7 @@ class EESiteDeleteController(CementBaseController): label = 'delete' stacked_on = 'site' stacked_type = 'nested' - description = 'To delete website' + description = 'delete an existing website' arguments = [ (['site_name'], dict(help='domain name to be deleted')), @@ -950,6 +955,7 @@ class EESiteDeleteController(CementBaseController): ] @expose(help="Delete website configuration and files") + @expose(hide=True) def default(self): # TODO Write code for ee site update here (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) @@ -1011,7 +1017,11 @@ class EESiteDeleteController(CementBaseController): Log.debug(self, "Removing Nginx configuration") EEFileUtils.rm(self, '/etc/nginx/sites-available/{0}' .format(ee_domain)) + EEGit.add(self, ["/etc/nginx"], + msg="Deleted {0} " + .format(ee_domain)) deleteSiteInfo(self, ee_domain) + Log.info(self, "Deleted site {0}".format(ee_domain)) else: Log.error(self, " site {0} does not exists".format(ee_domain)) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index e4460a7a..cad422a5 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -112,20 +112,22 @@ def setupdatabase(self, data): Log.info(self, "Setting up database\t\t", end='') Log.debug(self, "Creating databse {0}".format(ee_db_name)) EEMysql.execute(self, "create database {0}" - .format(ee_db_name)) + .format(ee_db_name), errormsg="Cannot create database") # Create MySQL User Log.debug(self, "Creating user {0}".format(ee_db_username)) EEMysql.execute(self, "create user {0}@{1} identified by '{2}'" .format(ee_db_username, ee_mysql_grant_host, - ee_db_password)) + ee_db_password), + errormsg="Cannot setup database user") # Grant permission Log.debug(self, "Setting up user privileges") EEMysql.execute(self, "grant all privileges on {0}.* to {1}@{2}" - .format(ee_db_name, ee_db_username, ee_mysql_grant_host)) + .format(ee_db_name, ee_db_username, ee_mysql_grant_host), + errormsg="Cannot setup database user privileges") Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]") data['ee_db_name'] = ee_db_name diff --git a/ee/core/aptget.py b/ee/core/aptget.py index b33b3d1d..74c1aeb5 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -4,6 +4,7 @@ import apt_pkg import sys from ee.core.logging import Log from sh import apt_get +from sh import ErrorReturnCode class EEAptGet():