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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
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
Show 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():
...
@@ -109,7 +109,7 @@ def run():
serve
(
config
)
serve
(
config
)
return_code
=
0
return_code
=
0
except
SystemExit
,
err
:
except
SystemExit
as
err
:
# Catch exception raise by optparse
# Catch exception raise by optparse
return_code
=
err
return_code
=
err
...
...
slapos/runner/fileBrowser.py
View file @
33e68311
...
@@ -98,7 +98,7 @@ class fileBrowser(object):
...
@@ -98,7 +98,7 @@ class fileBrowser(object):
shutil.rmtree(file)
shutil.rmtree(file)
else:
else:
os.unlink(file)
os.unlink(file)
except Exception
,
e:
except Exception
as
e:
return str(e)
return str(e)
return '{result:
\
'
1
\
'
}'
return '{result:
\
'
1
\
'
}'
...
@@ -126,7 +126,7 @@ class fileBrowser(object):
...
@@ -126,7 +126,7 @@ class fileBrowser(object):
shutil.copy(realfile, dest)
shutil.copy(realfile, dest)
if del_source:
if del_source:
os.unlink(realfile)
os.unlink(realfile)
except Exception
,
e:
except Exception
as
e:
return str(e)
return str(e)
return '{result:
\
'
1
\
'
}'
return '{result:
\
'
1
\
'
}'
...
...
slapos/runner/gittools.py
View file @
33e68311
...
@@ -48,7 +48,7 @@ def cloneRepo(data):
...
@@ -48,7 +48,7 @@ def cloneRepo(data):
if
data
[
"email"
]
!=
""
:
if
data
[
"email"
]
!=
""
:
config_writer
.
set_value
(
"user"
,
"email"
,
data
[
"email"
])
config_writer
.
set_value
(
"user"
,
"email"
,
data
[
"email"
])
code
=
1
code
=
1
except
Exception
,
e
:
except
Exception
as
e
:
json
=
safeResult
(
str
(
e
))
json
=
safeResult
(
str
(
e
))
if
os
.
path
.
exists
(
workDir
):
if
os
.
path
.
exists
(
workDir
):
shutil
.
rmtree
(
workDir
)
shutil
.
rmtree
(
workDir
)
...
@@ -69,7 +69,7 @@ def gitStatus(project):
...
@@ -69,7 +69,7 @@ def gitStatus(project):
branch
=
git
.
branch
().
replace
(
' '
,
''
).
split
(
'
\
n
'
)
branch
=
git
.
branch
().
replace
(
' '
,
''
).
split
(
'
\
n
'
)
isdirty
=
repo
.
is_dirty
(
untracked_files
=
True
)
isdirty
=
repo
.
is_dirty
(
untracked_files
=
True
)
code
=
1
code
=
1
except
Exception
,
e
:
except
Exception
as
e
:
json
=
safeResult
(
str
(
e
))
json
=
safeResult
(
str
(
e
))
return
jsonify
(
code
=
code
,
result
=
json
,
branch
=
branch
,
dirty
=
isdirty
)
return
jsonify
(
code
=
code
,
result
=
json
,
branch
=
branch
,
dirty
=
isdirty
)
...
@@ -91,7 +91,7 @@ def switchBranch(project, name):
...
@@ -91,7 +91,7 @@ def switchBranch(project, name):
git
=
repo
.
git
git
=
repo
.
git
git
.
checkout
(
name
)
git
.
checkout
(
name
)
code
=
1
code
=
1
except
Exception
,
e
:
except
Exception
as
e
:
json
=
safeResult
(
str
(
e
))
json
=
safeResult
(
str
(
e
))
return
jsonify
(
code
=
code
,
result
=
json
)
return
jsonify
(
code
=
code
,
result
=
json
)
...
@@ -113,7 +113,7 @@ def addBranch(project, name, onlyCheckout=False):
...
@@ -113,7 +113,7 @@ def addBranch(project, name, onlyCheckout=False):
else
:
else
:
git
.
checkout
(
name
)
git
.
checkout
(
name
)
code
=
1
code
=
1
except
Exception
,
e
:
except
Exception
as
e
:
json
=
safeResult
(
str
(
e
))
json
=
safeResult
(
str
(
e
))
return
jsonify
(
code
=
code
,
result
=
json
)
return
jsonify
(
code
=
code
,
result
=
json
)
...
@@ -125,7 +125,7 @@ def getDiff(project):
...
@@ -125,7 +125,7 @@ def getDiff(project):
git
=
repo
.
git
git
=
repo
.
git
current_branch
=
repo
.
active_branch
.
name
current_branch
=
repo
.
active_branch
.
name
result
=
git
.
diff
(
current_branch
)
result
=
git
.
diff
(
current_branch
)
except
Exception
,
e
:
except
Exception
as
e
:
result
=
safeResult
(
str
(
e
))
result
=
safeResult
(
str
(
e
))
return
result
return
result
...
@@ -155,7 +155,7 @@ def gitPush(project, msg):
...
@@ -155,7 +155,7 @@ def gitPush(project, msg):
else
:
else
:
json
=
"Nothing to be commited"
json
=
"Nothing to be commited"
code
=
1
code
=
1
except
Exception
,
e
:
except
Exception
as
e
:
if
undo_commit
:
if
undo_commit
:
git
.
reset
(
"HEAD~"
)
#undo previous commit
git
.
reset
(
"HEAD~"
)
#undo previous commit
json
=
safeResult
(
str
(
e
))
json
=
safeResult
(
str
(
e
))
...
@@ -169,7 +169,7 @@ def gitPull(project):
...
@@ -169,7 +169,7 @@ def gitPull(project):
git
=
repo
.
git
git
=
repo
.
git
git
.
pull
()
git
.
pull
()
code
=
1
code
=
1
except
Exception
,
e
:
except
Exception
as
e
:
result
=
safeResult
(
str
(
e
))
result
=
safeResult
(
str
(
e
))
return
jsonify
(
code
=
code
,
result
=
result
)
return
jsonify
(
code
=
code
,
result
=
result
)
...
...
slapos/runner/utils.py
View file @
33e68311
...
@@ -90,7 +90,7 @@ def saveSession(config, account):
...
@@ -90,7 +90,7 @@ def saveSession(config, account):
#save new account data
#save new account data
open
(
user
,
'w'
).
write
((
';'
.
join
(
account
)).
encode
(
"utf-8"
))
open
(
user
,
'w'
).
write
((
';'
.
join
(
account
)).
encode
(
"utf-8"
))
return
True
return
True
except
Exception
,
e
:
except
Exception
as
e
:
try
:
try
:
if
backup
:
if
backup
:
os
.
remove
(
user
)
os
.
remove
(
user
)
...
...
slapos/runner/views.py
View file @
33e68311
...
@@ -299,7 +299,7 @@ def createFile():
...
@@ -299,7 +299,7 @@ def createFile():
else
:
else
:
os
.
mkdir
(
path
)
os
.
mkdir
(
path
)
return
jsonify
(
code
=
1
,
result
=
""
)
return
jsonify
(
code
=
1
,
result
=
""
)
except
Exception
,
e
:
except
Exception
as
e
:
return
jsonify
(
code
=
0
,
result
=
str
(
e
))
return
jsonify
(
code
=
0
,
result
=
str
(
e
))
#remove file or directory
#remove file or directory
...
@@ -311,7 +311,7 @@ def removeFile():
...
@@ -311,7 +311,7 @@ def removeFile():
else
:
else
:
os
.
remove
(
request
.
form
[
'path'
])
os
.
remove
(
request
.
form
[
'path'
])
return
jsonify
(
code
=
1
,
result
=
""
)
return
jsonify
(
code
=
1
,
result
=
""
)
except
Exception
,
e
:
except
Exception
as
e
:
return
jsonify
(
code
=
0
,
result
=
str
(
e
))
return
jsonify
(
code
=
0
,
result
=
str
(
e
))
@
login_required
()
@
login_required
()
...
@@ -320,7 +320,7 @@ def removeSoftwareDir():
...
@@ -320,7 +320,7 @@ def removeSoftwareDir():
data
=
removeSoftwareByName
(
app
.
config
,
request
.
form
[
'md5'
],
data
=
removeSoftwareByName
(
app
.
config
,
request
.
form
[
'md5'
],
request
.
form
[
'title'
])
request
.
form
[
'title'
])
return
jsonify
(
code
=
1
,
result
=
data
)
return
jsonify
(
code
=
1
,
result
=
data
)
except
Exception
,
e
:
except
Exception
as
e
:
return
jsonify
(
code
=
0
,
result
=
str
(
e
))
return
jsonify
(
code
=
0
,
result
=
str
(
e
))
#read file and return content to ajax
#read file and return content to ajax
...
@@ -459,7 +459,7 @@ def saveParameterXml():
...
@@ -459,7 +459,7 @@ def saveParameterXml():
f
.
write
(
content
)
f
.
write
(
content
)
f
.
close
()
f
.
close
()
result
=
readParameters
(
param_path
)
result
=
readParameters
(
param_path
)
except
Exception
,
e
:
except
Exception
as
e
:
result
=
str
(
e
)
result
=
str
(
e
)
software_type
=
None
software_type
=
None
if
request
.
form
[
'software_type'
]:
if
request
.
form
[
'software_type'
]:
...
@@ -469,7 +469,7 @@ def saveParameterXml():
...
@@ -469,7 +469,7 @@ def saveParameterXml():
else
:
else
:
try
:
try
:
updateInstanceParameter
(
app
.
config
,
software_type
)
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
=
0
,
result
=
"An error occurred while applying your settings!<br/>"
+
str
(
e
))
return
jsonify
(
code
=
1
,
result
=
""
)
return
jsonify
(
code
=
1
,
result
=
""
)
...
@@ -591,7 +591,7 @@ def fileBrowser():
...
@@ -591,7 +591,7 @@ def fileBrowser():
result
=
file_request
.
unzipFile
(
dir
,
filename
,
newfilename
)
result
=
file_request
.
unzipFile
(
dir
,
filename
,
newfilename
)
else
:
else
:
result
=
"ARGS PARSE ERROR: Bad option..."
result
=
"ARGS PARSE ERROR: Bad option..."
except
Exception
,
e
:
except
Exception
as
e
:
return
str
(
e
)
return
str
(
e
)
return
result
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