Browse Source

Added git plugin db access functions

feature/plugin
gau1991 10 years ago
parent
commit
89c8635a8d
  1. 35
      ee/cli/plugins/pluginsdb.py

35
ee/cli/plugins/pluginsdb.py

@ -9,49 +9,40 @@ import sys
import glob import glob
def addNewPlugin(self, site, stype, cache, path, def addNewPlugin(self, plugin, plugin_type, plugin_version,
enabled=True, ssl=False, fs='ext4', db='mysql', plugin_enabled):
db_name=None, db_user=None, db_password=None,
db_host='localhost', hhvm=0, pagespeed=0):
""" """
Add New Site record information into ee database. Add New Site record information into ee database.
""" """
try: try:
newRec = PluginDB(site, stype, cache, path, enabled, ssl, fs, db, newRec = PluginDB(plugin, plugin_type, plugin_version,
db_name, db_user, db_password, db_host, hhvm, plugin_enabled)
pagespeed)
db_session.add(newRec) db_session.add(newRec)
db_session.commit() db_session.commit()
except Exception as e: except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to add site to database") Log.error(self, "Unable to add site to database")
def getPluginInfo(self, site): def getPluginInfo(self, plugin):
""" """
Retrieves site record from ee databse Retrieves site record from ee databse
""" """
try: try:
q = PluginDB.query.filter(PluginDB.sitename == site).first() q = PluginDB.query.filter(PluginDB.pluginname == plugin).first()
return q return q
except Exception as e: except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to query database for site info") Log.error(self, "Unable to query database for site info")
def updatePluginInfo(self, site, stype='', cache='', webroot='', def updatePluginInfo(self, plugin, type='', version='', enabled=True):
enabled=True, ssl=False, fs='', db='', db_name=None,
db_user=None, db_password=None, db_host=None, hhvm=None,
pagespeed=None):
"""updates site record in database""" """updates site record in database"""
try: try:
q = PluginDB.query.filter(PluginDB.sitename == site).first() q = PluginDB.query.filter(PluginDB.pluginname == plugin).first()
except Exception as e: except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to query database for site info") Log.error(self, "Unable to query database for site info")
if not q: if not q:
Log.error(self, "{0} does not exist in database".format(site)) Log.error(self, "{0} is not installed".format(site))
# Check if new record matches old if not then only update database # Check if new record matches old if not then only update database
if stype and q.site_type != stype: if stype and q.site_type != stype:
@ -95,22 +86,21 @@ def updatePluginInfo(self, site, stype='', cache='', webroot='',
Log.error(self, "Unable to update site info in application database.") Log.error(self, "Unable to update site info in application database.")
def deletePluginInfo(self, site): def deletePluginInfo(self, plugin):
"""Delete site record in database""" """Delete site record in database"""
try: try:
q = PluginDB.query.filter(PluginDB.sitename == site).first() q = PluginDB.query.filter(PluginDB.pluginname == plugin).first()
except Exception as e: except Exception as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to query database") Log.error(self, "Unable to query database")
if not q: if not q:
Log.error(self, "{0} does not exist in database".format(site)) Log.error(self, "{0} does not exist".format(site))
try: try:
db_session.delete(q) db_session.delete(q)
db_session.commit() db_session.commit()
except Exception as e: except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to delete site from application database.") Log.error(self, "Unable to delete site from application database.")
@ -122,5 +112,4 @@ def getAllplugins(self):
q = PluginDB.query.all() q = PluginDB.query.all()
return q return q
except Exception as e: except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to query database") Log.error(self, "Unable to query database")

Loading…
Cancel
Save