Browse Source

removed sys.exit()

bugfixes
shital.rtcamp 10 years ago
parent
commit
766ac5116d
  1. 4
      ee/cli/plugins/clean.py
  2. 4
      ee/core/download.py
  3. 2
      ee/core/extract.py
  4. 42
      ee/core/fileutils.py
  5. 6
      ee/core/git.py
  6. 13
      ee/core/services.py
  7. 6
      ee/core/shellexec.py

4
ee/cli/plugins/clean.py

@ -57,8 +57,8 @@ class EECleanController(CementBaseController):
else:
Log.error(self, "Memcache not installed")
except Exception as e:
Log.error(self, "Unable to restart memcached")
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to restart memcached")
@expose(hide=True)
def clean_fastcgi(self):
@ -75,8 +75,8 @@ class EECleanController(CementBaseController):
wp = urllib.request.urlopen(" https://127.0.0.1:22222/cache"
"/opcache/opgui.php?page=reset").read()
except Exception as e:
Log.error(self, "Unable to clean opacache")
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to clean opacache")
def load(app):

4
ee/core/download.py

@ -22,9 +22,9 @@ class EEDownload():
Log.info(self, "Downloading "+pkg_name+" ...")
urllib.request.urlretrieve(url, filename)
except urllib.error.URLError as e:
Log.debug(self, "[{err}]".format(err=str(e.reason)))
Log.error(self, "Unable to donwload file, {0}"
.format(filename))
Log.debug(self, "[{err}]".format(err=str(e.reason)))
return False
except urllib.error.HTTPError as e:
Log.error(self, "Package download failed. {0}"
@ -32,8 +32,8 @@ class EEDownload():
Log.debug(self, "[{err}]".format(err=str(e.reason)))
return False
except urllib.error.ContentTooShortError as e:
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
Log.error(self, "Package download failed. The amount of the"
" downloaded data is less than "
"the expected amount \{0} ".format(pkg_name))
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
return False

2
ee/core/extract.py

@ -15,6 +15,6 @@ class EEExtract():
os.remove(file)
return True
except tarfile.TarError as e:
Log.error(self, 'Unable to extract file \{0}'.format(file))
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
Log.error(self, 'Unable to extract file \{0}'.format(file))
return False

42
ee/core/fileutils.py

@ -24,9 +24,8 @@ class EEFileUtils():
Log.info(self, "Removing "+os.path.basename(file)+"...")
shutil.rmtree(file)
except shutil.Error as e:
Log.error(self, 'Unable to Remove file ')
Log.debug(self, "{err}".format(err=str(e.reason)))
sys.exit(1)
Log.error(self, 'Unable to Remove file ')
def create_symlink(self, paths, errormsg=''):
src = paths[0]
@ -35,9 +34,8 @@ class EEFileUtils():
try:
os.symlink(src, dst)
except Exception as e:
Log.error(self, "Unable to create symbolic link ...\n ")
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
sys.exit(1)
Log.error(self, "Unable to create symbolic link ...\n ")
else:
Log.debug(self, "Destination: {0} exists".format(dst))
@ -45,21 +43,20 @@ class EEFileUtils():
try:
os.unlink(filepath)
except Exception as e:
Log.error(self, "Unable to reomove symbolic link ...\n")
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
sys.exit(1)
Log.error(self, "Unable to reomove symbolic link ...\n")
def copyfile(self, src, dest):
try:
shutil.copy2(src, dest)
except shutil.Error as e:
Log.debug(self, "{0}".format(e))
Log.error(self, 'Unable to copy file from {0} to {1}'
.format(src, dest))
Log.debug(self, "{0}".format(e))
except IOError as e:
Log.debug(self, "{e}".format(e.strerror))
Log.error(self, "Unable to copy file from {0} to {1}"
.fromat(src, dest))
Log.debug(self, "{e}".format(e.strerror))
def searchreplace(self, fnm, sstr, rstr):
try:
@ -67,26 +64,24 @@ class EEFileUtils():
print(line.replace(sstr, rstr), end='')
fileinput.close()
except Exception as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to search {0} and replace {1} {2}"
.format(fnm, sstr, rstr))
Log.debug(self, "{0}".format(e))
def mvfile(self, src, dst):
try:
shutil.move(src, dst)
except shutil.Error as e:
Log.debug(self, "{err}".format(err=str(e.reason)))
Log.error(self, 'Unable to move file from {0} to {1}'
.format(src, dst))
Log.debug(self, "{err}".format(err=str(e.reason)))
sys.exit(1)
def chdir(self, path):
try:
os.chdir(path)
except OSError as e:
Log.error(self, 'Unable to Change Directory {0}'.format(path))
Log.debug(self, "{err}".format(err=e.strerror))
sys.exit(1)
Log.error(self, 'Unable to Change Directory {0}'.format(path))
def chown(self, path, user, group, recursive=False):
try:
@ -101,13 +96,11 @@ class EEFileUtils():
else:
shutil.chown(path, user=user, group=group)
except shutil.Error as e:
Log.error(self, "Unable to change owner : {0}".format(path))
Log.debug(self, "{0}".format(e))
sys.exit(1)
Log.error(self, "Unable to change owner : {0}".format(path))
except Exception as e:
Log.error(self, "Unable to change owner : {0} ".format(path))
Log.debug(self, "{0}".format(e))
sys.exit(1)
Log.error(self, "Unable to change owner : {0} ".format(path))
def chmod(self, path, perm, recursive=False):
try:
@ -120,17 +113,15 @@ class EEFileUtils():
else:
os.chmod(path, perm)
except OSError as e:
Log.error(self, "Unable to change owner : {0}".format(path))
Log.debug(self, "{0}".format(e.strerror))
sys.exit(1)
Log.error(self, "Unable to change owner : {0}".format(path))
def mkdir(self, path):
try:
os.makedirs(path)
except OSError as e:
Log.error(self, "Unable to create directory {0} ".format(path))
Log.debug(self, "{0}".format(e.strerror))
sys.exit(1)
Log.error(self, "Unable to create directory {0} ".format(path))
def isexist(self, path):
try:
@ -139,9 +130,8 @@ class EEFileUtils():
else:
return (False)
except OSError as e:
Log.error(self, "Unable to check path {0}".format(path))
Log.debug(self, "{0}".format(e.strerror))
sys.exit(1)
Log.error(self, "Unable to check path {0}".format(path))
def grep(self, fnm, sstr):
try:
@ -149,6 +139,6 @@ class EEFileUtils():
if sstr in line:
return line
except OSError as e:
Log.error(self, "Unable to Search string {0}{1}"
.format(e.strerror, "[FAIL]"))
sys.exit(1)
Log.debug(self, "{0}".format(e.strerror))
Log.error(self, "Unable to Search string {0} in {1}"
.format(sstr, fnm))

6
ee/core/git.py

@ -21,10 +21,9 @@ class EEGit:
.format(path))
git.init(path)
except ErrorReturnCode as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to git init at {0}"
.format(path))
Log.error(self, "{0}".format(e))
sys.exit(1)
status = git.status("-s")
if len(status.splitlines()) > 0:
try:
@ -33,10 +32,9 @@ class EEGit:
git.add("--all")
git.commit("-am {0}".format(msg))
except ErrorReturnCode as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Unable to git commit at {0} "
.format(path))
Log.debug(self, "{0}".format(e))
sys.exit(1)
else:
Log.debug(self, "EEGit: Path {0} not present".format(path))

13
ee/core/services.py

@ -23,9 +23,9 @@ class EEService():
else:
Log.error(self, retcode[1])
except OSError as e:
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
Log.error(self, "Failed to start service {0}"
.format(service_name))
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
return False
def stop_service(self, service_name):
@ -39,9 +39,9 @@ class EEService():
else:
return False
except OSError as e:
Log.debug(self, "{0} {1}".format(e.errno, e.strerror))
Log.error(self, "Failed to stop service : {0}"
.format(service_name))
Log.debug(self, "{0} {1}".format(e.errno, e.strerror))
return False
def restart_service(self, service_name):
@ -51,9 +51,9 @@ class EEService():
Log.info(self, "restart : {0:10}{1}"
.format(service_name, "[OK]"))
except OSError as e:
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
Log.error(self, "Failed to restart services \{0}"
.format(service_name))
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
def reload_service(self, service_name):
try:
@ -67,8 +67,8 @@ class EEService():
.format(service_name, "[OK]"))
return True
else:
Log.error(self, "reload : {0}".format(service_name))
Log.debug("{0}".format(retcode[1]))
Log.error(self, "reload : {0}".format(service_name))
return False
retcode = subprocess.getstatusoutput('service {0} reload'
@ -80,10 +80,9 @@ class EEService():
else:
return False
except OSError as e:
Log.debug(self, "{0}".format(e))
Log.error(self, "Failed to reload service {0}"
.format(service_name))
Log.debug(self, "{0}".format(e))
sys.exit(1)
def get_service_status(self, service_name):
try:
@ -99,7 +98,7 @@ class EEService():
else:
return False
except OSError as e:
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
Log.error(self, "Unable to get services status of {0}"
.format(service_name))
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
return False

6
ee/core/shellexec.py

@ -24,10 +24,9 @@ class EEShellExec():
if errormsg:
Log.error(self, errormsg)
else:
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
Log.error(self, "Unable to execute command {0}"
.format(command))
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
sys.exit(1)
def invoke_editor(self, filepath, errormsg=''):
try:
@ -36,6 +35,5 @@ class EEShellExec():
if errormsg:
Log.error(self, errormsg)
else:
Log.error(self, "Unable to edit file {0}".format(filepath))
Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
sys.exit(1)
Log.error(self, "Unable to edit file {0}".format(filepath))

Loading…
Cancel
Save