Browse Source

custom error msg

bugfixes
harshadyeola 10 years ago
parent
commit
5a8c9f1b7d
  1. 16
      ee/core/fileutils.py
  2. 10
      ee/core/mysql.py

16
ee/core/fileutils.py

@ -142,3 +142,19 @@ class EEFileUtils():
Log.error(self, "Unable to Search string {0}" Log.error(self, "Unable to Search string {0}"
.format(e.strerror)) .format(e.strerror))
sys.exit(1) sys.exit(1)
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.error(self, "Unable to remove directory : {0} {1}"
.format(path, e))
sys.exit(1)
except OSError as e:
Log.error(self, "Unable to remove file : {0} {1}"
.format(path, e))
sys.exit(1)

10
ee/core/mysql.py

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

Loading…
Cancel
Save