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
Gabriel Monnerat
slapos.toolbox
Commits
ab224625
Commit
ab224625
authored
Jul 26, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner: use context manager for open(.., 'w')
parent
ccd8605a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
10 deletions
+7
-10
slapos/runner/runnertest.py
slapos/runner/runnertest.py
+2
-3
slapos/runner/utils.py
slapos/runner/utils.py
+2
-3
slapos/runner/views.py
slapos/runner/views.py
+3
-4
No files found.
slapos/runner/runnertest.py
View file @
ab224625
...
@@ -89,9 +89,8 @@ class SlaprunnerTestCase(unittest.TestCase):
...
@@ -89,9 +89,8 @@ class SlaprunnerTestCase(unittest.TestCase):
self
.
app
=
views
.
app
.
test_client
()
self
.
app
=
views
.
app
.
test_client
()
self
.
app
.
config
=
views
.
app
.
config
self
.
app
.
config
=
views
.
app
.
config
#Create password recover code
#Create password recover code
rpwd
=
open
(
os
.
path
.
join
(
views
.
app
.
config
[
'etc_dir'
],
'.rcode'
),
'w'
)
with
open
(
os
.
path
.
join
(
views
.
app
.
config
[
'etc_dir'
],
'.rcode'
),
'w'
)
as
rpwd
:
rpwd
.
write
(
self
.
rcode
)
rpwd
.
write
(
self
.
rcode
)
rpwd
.
close
()
def
tearDown
(
self
):
def
tearDown
(
self
):
"""Remove all test data"""
"""Remove all test data"""
...
...
slapos/runner/utils.py
View file @
ab224625
...
@@ -296,9 +296,8 @@ def config_SR_folder(config):
...
@@ -296,9 +296,8 @@ def config_SR_folder(config):
#create symlink
#create symlink
os
.
symlink
(
source
,
destination
)
os
.
symlink
(
source
,
destination
)
#write config file
#write config file
cf
=
open
(
cfg
,
'w'
)
with
open
(
cfg
,
'w'
)
as
cf
:
cf
.
write
(
current_project
+
"#"
+
folder
)
cf
.
write
(
current_project
+
'#'
+
folder
)
cf
.
close
()
def
loadSoftwareRList
(
config
):
def
loadSoftwareRList
(
config
):
...
...
slapos/runner/views.py
View file @
ab224625
...
@@ -536,9 +536,8 @@ def saveParameterXml():
...
@@ -536,9 +536,8 @@ def saveParameterXml():
content
=
request
.
form
[
'parameter'
].
encode
(
"utf-8"
)
content
=
request
.
form
[
'parameter'
].
encode
(
"utf-8"
)
param_path
=
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".parameter.xml"
)
param_path
=
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".parameter.xml"
)
try
:
try
:
f
=
open
(
param_path
,
'w'
)
with
open
(
param_path
,
'w'
)
as
f
:
f
.
write
(
content
)
f
.
write
(
content
)
f
.
close
()
result
=
readParameters
(
param_path
)
result
=
readParameters
(
param_path
)
except
Exception
as
e
:
except
Exception
as
e
:
result
=
str
(
e
)
result
=
str
(
e
)
...
...
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