From 89516f74c78a2f89776c72969ef21990f2f57bb8 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Tue, 24 Mar 2015 15:19:31 +0530 Subject: [PATCH] modified functions to access ee database --- ee/cli/plugins/site_functions.py | 6 ++++-- ee/cli/plugins/sitedb.py | 27 +++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index d7dcd6fe..62cb3f1a 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -359,7 +359,8 @@ def setupwordpressnetwork(self, data): def installwp_plugin(self, plugin_name, data): ee_site_webroot = data['webroot'] - Log.info(self, "Installing plugin {0}".format(plugin_name)) + Log.info(self, "Installing plugin {0}, please wait ..." + .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), @@ -376,7 +377,8 @@ def installwp_plugin(self, plugin_name, data): def uninstallwp_plugin(self, plugin_name, data): ee_site_webroot = data['webroot'] - Log.debug(self, "Uninstalling plugin {0}".format(plugin_name)) + Log.debug(self, "Uninstalling plugin {0}, please wait ..." + .format(plugin_name)) EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot)) EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin --allow-root uninstall " "{0}".format(plugin_name), diff --git a/ee/cli/plugins/sitedb.py b/ee/cli/plugins/sitedb.py index cb7e1bde..e177544d 100644 --- a/ee/cli/plugins/sitedb.py +++ b/ee/cli/plugins/sitedb.py @@ -9,12 +9,15 @@ import sys def addNewSite(self, site, stype, cache, path, - enabled=True, ssl=False, fs='ext4', db='mysql'): + enabled=True, ssl=False, fs='ext4', db='mysql', + db_name=None, db_user=None, db_password=None, + db_host='localhost'): """ Add New Site record information into ee database. """ try: - newRec = SiteDB(site, stype, cache, path, enabled, ssl, fs, db) + newRec = SiteDB(site, stype, cache, path, enabled, ssl, fs, db, + db_name, db_user, db_password, db_host) db_session.add(newRec) db_session.commit() except Exception as e: @@ -34,8 +37,9 @@ def getSiteInfo(self, site): Log.error(self, "Unable to query database for site info") -def updateSiteInfo(self, site, stype='', cache='', - enabled=True, ssl=False, fs='', db=''): +def updateSiteInfo(self, site, stype='', cache='', webroot='', + enabled=True, ssl=False, fs='', db='', db_name=None, + db_user=None, db_password=None, db_host=None): """updates site record in database""" try: q = SiteDB.query.filter(SiteDB.sitename == site).first() @@ -59,6 +63,21 @@ def updateSiteInfo(self, site, stype='', cache='', if ssl and q.is_ssl != ssl: q.is_ssl = ssl + if db_name and q.db_name != db_name: + q.db_name = db_name + + if db_user and q.db_user != db_user: + q.db_user = db_user + + if db_user and q.db_password != db_password: + q.db_password = db_password + + if db_host and q.db_host != db_host: + q.db_host = db_host + + if webroot and q.site_path != webroot: + q.site_path = webroot + try: q.created_on = func.now() db_session.commit()