Commit 33e68311 authored by Marco Mariani's avatar Marco Mariani

"except ... as .." syntax

parent 956dea7a
......@@ -109,7 +109,7 @@ def run():
serve(config)
return_code = 0
except SystemExit, err:
except SystemExit as err:
# Catch exception raise by optparse
return_code = err
......
......@@ -98,7 +98,7 @@ class fileBrowser(object):
shutil.rmtree(file)
else:
os.unlink(file)
except Exception, e:
except Exception as e:
return str(e)
return '{result: \'1\'}'
......@@ -126,7 +126,7 @@ class fileBrowser(object):
shutil.copy(realfile, dest)
if del_source:
os.unlink(realfile)
except Exception, e:
except Exception as e:
return str(e)
return '{result: \'1\'}'
......
......@@ -48,7 +48,7 @@ def cloneRepo(data):
if data["email"] != "":
config_writer.set_value("user", "email", data["email"])
code = 1
except Exception, e:
except Exception as e:
json = safeResult(str(e))
if os.path.exists(workDir):
shutil.rmtree(workDir)
......@@ -69,7 +69,7 @@ def gitStatus(project):
branch = git.branch().replace(' ', '').split('\n')
isdirty = repo.is_dirty(untracked_files=True)
code = 1
except Exception, e:
except Exception as e:
json = safeResult(str(e))
return jsonify(code=code, result=json, branch=branch, dirty=isdirty)
......@@ -91,7 +91,7 @@ def switchBranch(project, name):
git = repo.git
git.checkout(name)
code = 1
except Exception, e:
except Exception as e:
json = safeResult(str(e))
return jsonify(code=code, result=json)
......@@ -113,7 +113,7 @@ def addBranch(project, name, onlyCheckout=False):
else:
git.checkout(name)
code = 1
except Exception, e:
except Exception as e:
json = safeResult(str(e))
return jsonify(code=code, result=json)
......@@ -125,7 +125,7 @@ def getDiff(project):
git = repo.git
current_branch = repo.active_branch.name
result = git.diff(current_branch)
except Exception, e:
except Exception as e:
result = safeResult(str(e))
return result
......@@ -155,7 +155,7 @@ def gitPush(project, msg):
else:
json = "Nothing to be commited"
code = 1
except Exception, e:
except Exception as e:
if undo_commit:
git.reset("HEAD~") #undo previous commit
json = safeResult(str(e))
......@@ -169,7 +169,7 @@ def gitPull(project):
git = repo.git
git.pull()
code = 1
except Exception, e:
except Exception as e:
result = safeResult(str(e))
return jsonify(code=code, result=result)
......
......@@ -90,7 +90,7 @@ def saveSession(config, account):
#save new account data
open(user, 'w').write((';'.join(account)).encode("utf-8"))
return True
except Exception, e:
except Exception as e:
try:
if backup:
os.remove(user)
......@@ -212,7 +212,7 @@ def recursifKill(pids):
try:
os.kill(pid, signal.SIGKILL) #kill current process
except Exception:
pass
pass
recursifKill(ppids) #kill all children of this process
def pidppid(pid):
......
......@@ -299,7 +299,7 @@ def createFile():
else:
os.mkdir(path)
return jsonify(code=1, result="")
except Exception, e:
except Exception as e:
return jsonify(code=0, result=str(e))
#remove file or directory
......@@ -311,7 +311,7 @@ def removeFile():
else:
os.remove(request.form['path'])
return jsonify(code=1, result="")
except Exception, e:
except Exception as e:
return jsonify(code=0, result=str(e))
@login_required()
......@@ -320,7 +320,7 @@ def removeSoftwareDir():
data = removeSoftwareByName(app.config, request.form['md5'],
request.form['title'])
return jsonify(code=1, result=data)
except Exception, e:
except Exception as e:
return jsonify(code=0, result=str(e))
#read file and return content to ajax
......@@ -459,7 +459,7 @@ def saveParameterXml():
f.write(content)
f.close()
result = readParameters(param_path)
except Exception, e:
except Exception as e:
result = str(e)
software_type = None
if request.form['software_type']:
......@@ -469,7 +469,7 @@ def saveParameterXml():
else:
try:
updateInstanceParameter(app.config, software_type)
except Exception, e:
except Exception as e:
return jsonify(code=0, result="An error occurred while applying your settings!<br/>" + str(e))
return jsonify(code=1, result="")
......@@ -591,7 +591,7 @@ def fileBrowser():
result = file_request.unzipFile(dir, filename, newfilename)
else:
result = "ARGS PARSE ERROR: Bad option..."
except Exception, e:
except Exception as e:
return str(e)
return result
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment