diff --git a/ee/core/fileutils.py b/ee/core/fileutils.py index d497eed3..a07d2f7d 100644 --- a/ee/core/fileutils.py +++ b/ee/core/fileutils.py @@ -142,3 +142,19 @@ class EEFileUtils(): Log.error(self, "Unable to Search string {0}" .format(e.strerror)) 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) diff --git a/ee/core/mysql.py b/ee/core/mysql.py index 883752f2..4bf07cac 100644 --- a/ee/core/mysql.py +++ b/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,7 +30,13 @@ class EEMysql(): user=user, passwd=passwd) cur = conn.cursor() 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)) sys.exit(1)