Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.toolbox
Commits
33e68311
Commit
33e68311
authored
Oct 11, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"except ... as .." syntax
parent
956dea7a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
18 deletions
+18
-18
slapos/runner/__init__.py
slapos/runner/__init__.py
+1
-1
slapos/runner/fileBrowser.py
slapos/runner/fileBrowser.py
+2
-2
slapos/runner/gittools.py
slapos/runner/gittools.py
+7
-7
slapos/runner/utils.py
slapos/runner/utils.py
+2
-2
slapos/runner/views.py
slapos/runner/views.py
+6
-6
No files found.
slapos/runner/__init__.py
View file @
33e68311
...
...
@@ -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
...
...
slapos/runner/fileBrowser.py
View file @
33e68311
...
...
@@ -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
\
'
}'
...
...
slapos/runner/gittools.py
View file @
33e68311
...
...
@@ -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
)
...
...
slapos/runner/utils.py
View file @
33e68311
...
...
@@ -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
):
...
...
slapos/runner/views.py
View file @
33e68311
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment