Browse Source

added log message

bugfixes
shital.rtcamp 10 years ago
parent
commit
cff8bfc5de
  1. 16
      ee/core/fileutils.py
  2. 15
      ee/core/mysql.py

16
ee/core/fileutils.py

@ -142,3 +142,19 @@ class EEFileUtils():
Log.debug(self, "{0}".format(e.strerror))
Log.error(self, "Unable to Search string {0} in {1}"
.format(sstr, fnm))
def rm(self, path):
if EEFileUtils.isexist(self, path):
try:
if os.path.isdir(path):
shutil.rmtree(path)
else:
os.remove(path)
except shutil.Error as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to remove directory : {0} "
.format(path))
except OSError as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to remove file : {0} "
.format(path))

15
ee/core/mysql.py

@ -9,7 +9,7 @@ from ee.core.logging import Log
class EEMysql():
"""Method for MySQL connection"""
def execute(self, statement):
def execute(self, statement, errormsg=''):
config = configparser.RawConfigParser()
cnfpath = expanduser("~")+"/.my.cnf"
if [cnfpath] == config.read(cnfpath):
@ -30,9 +30,16 @@ class EEMysql():
user=user, passwd=passwd)
cur = conn.cursor()
except Exception as e:
Log.error(self, 'Unable to connect to database: ')
Log.debug(self, "{0}".format(e))
sys.exit(1)
if errormsg:
Log.debug(self, '{0}'
.format(e))
Log.error(self, '{0}'
.format(errormsg))
else:
Log.debug(self, '{0}'
.format(e))
Log.error(self, 'Unable to connect to database: {0}'
.format(e))
try:
cur.execute(statement)

Loading…
Cancel
Save