From aa2eeb0b100f778cd6a9305c01d1f02f81eef873 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Fri, 16 Jan 2015 19:38:06 +0530 Subject: [PATCH] ee stack service messaged modified --- ee/cli/controllers/base.py | 26 ++---------- ee/cli/plugins/site.py | 81 ++++++++++++++++++++++---------------- ee/cli/plugins/sitedb.py | 13 +++++- ee/core/fileutils.py | 2 +- ee/core/services.py | 2 +- setup.py | 10 ++--- 6 files changed, 69 insertions(+), 65 deletions(-) diff --git a/ee/cli/controllers/base.py b/ee/cli/controllers/base.py index aad1d5c5..b19b224a 100644 --- a/ee/cli/controllers/base.py +++ b/ee/cli/controllers/base.py @@ -6,28 +6,10 @@ from cement.core.controller import CementBaseController, expose class EEBaseController(CementBaseController): class Meta: label = 'base' - description = 'easyengine is the commandline tool to manage your \ - websites based on wordpress and nginx with easy to \ - use commands.' - arguments = [ - (['-f', '--foo'], - dict(help='the notorious foo option', dest='foo', action='store', - metavar='TEXT')), - ] + description = ("easyengine is the commandline tool to manage your" + " websites based on wordpress and nginx with easy to" + " use commands.") @expose(hide=True) def default(self): - data = dict(foo='EEBaseController.default().') - self.app.render((data), 'default.mustache') - - # print("Inside EEBaseController.default().") - - # If using an output handler such as 'mustache', you could also - # render a data dictionary using a template. For example: - # - # data = dict(foo='bar') - # self.app.render(data, 'default.mustache') - # - # - # The 'default.mustache' file would be loaded from - # ``ee.cli.templates``, or ``/var/lib/ee/templates/``. + self.app.args.print_help() diff --git a/ee/cli/plugins/site.py b/ee/cli/plugins/site.py index 597ce5cb..b78de277 100644 --- a/ee/cli/plugins/site.py +++ b/ee/cli/plugins/site.py @@ -458,30 +458,30 @@ class EESiteUpdateController(CementBaseController): help of the following subcommands' arguments = [ (['site_name'], - dict(help='website name')), + dict(help='domain name for the site to be updated')), (['--html'], - dict(help="html site", action='store_true')), + dict(help="update to html site", action='store_true')), (['--php'], - dict(help="php site", action='store_true')), + dict(help="update to php site", action='store_true')), (['--mysql'], - dict(help="mysql site", action='store_true')), + dict(help="update to mysql site", action='store_true')), (['--wp'], - dict(help="wordpress site", action='store_true')), + dict(help="update to wordpress single site", + action='store_true')), (['--wpsubdir'], - dict(help="wpsubdir site", action='store_true')), + dict(help="update to wpsubdir site", action='store_true')), (['--wpsubdomain'], - dict(help="wpsubdomain site", action='store_true')), + dict(help="update to wpsubdomain site", action='store_true')), (['--w3tc'], - dict(help="w3tc", action='store_true')), + dict(help="update to w3tc cache", action='store_true')), (['--wpfc'], - dict(help="wpfc", action='store_true')), + dict(help="update to wpfc cache", action='store_true')), (['--wpsc'], - dict(help="wpsc", action='store_true')), + dict(help="update to wpsc cache", action='store_true')), ] - @expose(help="update example.com") + @expose(help="update site type or cache") def default(self): - # TODO Write code for ee site update here (ee_domain, ee_www_domain, ) = ValidateDomain(self.app.pargs.site_name) ee_site_webroot = EEVariables.ee_webroot + ee_domain @@ -810,10 +810,8 @@ class EESiteUpdateController(CementBaseController): data['ee_db_host'])) eedbconfig.close() except IOError as e: - Log.error(self, " Unable to create ee-config.php for " - "{0}" - .format(ee_domain)) - Log.debug(self, "{0} {1}".format(e.errno, e.strerror)) + Log.debug(self, "{0}".format(e)) + Log.error(self, " Unable to create ee-config.php.") if oldsitetype == 'mysql': config_file = (ee_site_webroot + '/backup/{0}/ee-config.php' @@ -892,12 +890,17 @@ class EESiteDeleteController(CementBaseController): dict(help="delete webroot only", action='store_true')), ] - @expose(help="delete example.com") + @expose(help="delete site") def default(self): # TODO Write code for ee site update here (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name) ee_db_name = '' ee_prompt = '' + + if ((not self.app.pargs.db) and (not self.app.pargs.files) and + (not self.app.pargs.all)): + self.app.pargs.all = True + if os.path.isfile('/etc/nginx/sites-available/{0}' .format(ee_domain)): ee_site_webroot = EEVariables.ee_webroot + ee_domain @@ -907,44 +910,49 @@ class EESiteDeleteController(CementBaseController): if self.app.pargs.db: if not ee_prompt: - ee_db_prompt = input('Do you want to delete database:' - '[Y/N] ') + ee_db_prompt = input('Do you want to delete database' + '[Y/N]: ') else: ee_db_prompt = 'Y' - if ee_db_prompt == 'Y': + ee_nginx_prompt = 'Y' + if ee_db_prompt == 'Y' or ee_db_prompt == 'y': self.deleteDB(ee_site_webroot) if self.app.pargs.files: if not ee_prompt: - ee_web_prompt = input('Do you want to delete webroot:' - '[Y/N] ') + ee_web_prompt = input('Do you want to delete webroot' + '[Y/N]: ') else: ee_web_prompt = 'Y' - if ee_web_prompt == 'Y': + ee_nginx_prompt = 'Y' + + if ee_web_prompt == 'Y' or ee_web_prompt == 'y': self.deleteWebRoot(ee_site_webroot) if self.app.pargs.all: if not ee_prompt: - ee_db_prompt = input('Do you want to delete database:' - '[Y/N] ' + ee_db_prompt = input('Do you want to delete database' + '[Y/N]: ' ) - ee_web_prompt = input('Do you want to delete webroot:' - '[Y/N] ') + ee_web_prompt = input('Do you want to delete webroot' + '[Y/N]: ') ee_nginx_prompt = input('Do you want to delete NGINX' - ' configuration:[Y/N] ') + ' configuration [Y/N]: ') else: ee_db_prompt = 'Y' ee_web_prompt = 'Y' ee_nginx_prompt = 'Y' - if ee_db_prompt == 'Y': + if ee_db_prompt == 'Y' or ee_db_prompt == 'y': self.deleteDB(ee_site_webroot) - if ee_web_prompt == 'Y': + if ee_web_prompt == 'Y' or ee_web_prompt == 'y': self.deleteWebRoot(ee_site_webroot) - if ee_nginx_prompt == 'Y': + + if (ee_nginx_prompt == 'Y' or ee_nginx_prompt == 'y'): EEFileUtils.rm(self, '/etc/nginx/sites-available/{0}' .format(ee_domain)) - deleteSiteInfo(self, 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)) @@ -966,18 +974,20 @@ class EESiteDeleteController(CementBaseController): 'DB_HOST').split(',')[1] .split(')')[0].strip().replace('\'', '')) try: + Log.debug(self, "dropping database {0}".format(ee_db_name)) EEMysql.execute(self, "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)) EEMysql.execute(self, "drop user {0}@{1}" .format(ee_db_user, ee_db_host)) EEMysql.execute(self, "flush privileges") except Exception as e: - Log.error(self, " Error occured while deleting database") + Log.error(self, "Error occured while deleting database") @expose(hide=True) def deleteWebRoot(self, webroot): @@ -1001,7 +1011,7 @@ class EESiteListController(CementBaseController): def default(self): sites = getAllsites(self) if not sites: - self.app.close(1) + pass if self.app.pargs.enabled: for site in sites: @@ -1011,6 +1021,9 @@ class EESiteListController(CementBaseController): for site in sites: if not site.is_enabled: Log.info(self, "{0}".format(site.sitename)) + else: + for site in sites: + Log.info(self, "{0}".format(site.sitename)) def load(app): diff --git a/ee/cli/plugins/sitedb.py b/ee/cli/plugins/sitedb.py index c8f2acd6..318beb46 100644 --- a/ee/cli/plugins/sitedb.py +++ b/ee/cli/plugins/sitedb.py @@ -9,7 +9,7 @@ from ee.core.models import SiteDB def addNewSite(self, site, stype, cache, path, - enabled=True, ssl=False, fs='ext4', db='mysql'): + enabled=True, ssl=False, fs='ext4', db=''): try: newRec = SiteDB(site, stype, cache, path, enabled, ssl, fs, db) db_session.add(newRec) @@ -41,7 +41,7 @@ def updateSiteInfo(self, site, stype='', cache='', if cache and q.cache_type != cache: q.cache_type = cache - if enabled and q.is_enabled != enabled: + if q.is_enabled != enabled: q.is_enabled = enabled if ssl and q.is_ssl != ssl: @@ -67,3 +67,12 @@ def deleteSiteInfo(self, site): except Exception as e: Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to delete site from application database.") + + +def getAllsites(self): + try: + q = SiteDB.query.all() + return q + except Exception as e: + Log.debug(self, "{0}".format(e)) + Log.error(self, "Unable to query database :") diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index 74195a45..d67bd3a3 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -43,7 +43,7 @@ class EEFileUtils(): try: os.unlink(filepath) except Exception as e: - Log.debug(self, "{0}{1}".format(e.errno, e.strerror)) + Log.debug(self, "{0}".format(e)) Log.error(self, "Unable to reomove symbolic link ...\n") def copyfile(self, src, dest): diff --git a/ee/core/services.py b/ee/core/services.py index c344a2f8..bf533e9f 100644 --- a/ee/core/services.py +++ b/ee/core/services.py @@ -95,7 +95,7 @@ class EEService(): return False except OSError as e: Log.debug(self, "{0}".format(e)) - Log.error(self, "Failed to reload service {0}" + Log.error(self, "\nFailed to reload service {0}" .format(service_name)) def get_service_status(self, service_name): diff --git a/setup.py b/setup.py index d98e9f4d..001b2fe6 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,9 @@ import glob conf = [] templates = [] +long_description = '''EasyEngine is the commandline tool to manage your + Websites based on WordPress and NGINX with easy to use + commands''' for name in glob.glob('config/plugins.d/*.conf'): conf.insert(1, name) @@ -22,11 +25,8 @@ if not os.path.exists('/var/lib/ee/'): setup(name='ee', version='3.0', - description=('EasyEngine is the commandline tool to manage your Websites' - 'based on WordPress and NGINX with easy to use commands.'), - long_description=('EasyEngine is the commandline tool to manage your ' - 'Websites based on WordPress and NGINX with easy' - 'to use commands.'), + description=long_description, + long_description=long_description, classifiers=[], keywords='', author='rtCamp Soultions Pvt. LTD',