Commit ab224625 authored by Marco Mariani's avatar Marco Mariani

runner: use context manager for open(.., 'w')

parent ccd8605a
......@@ -89,9 +89,8 @@ class SlaprunnerTestCase(unittest.TestCase):
self.app = views.app.test_client()
self.app.config = views.app.config
#Create password recover code
rpwd = open(os.path.join(views.app.config['etc_dir'], '.rcode'), 'w')
rpwd.write(self.rcode)
rpwd.close()
with open(os.path.join(views.app.config['etc_dir'], '.rcode'), 'w') as rpwd:
rpwd.write(self.rcode)
def tearDown(self):
"""Remove all test data"""
......
......@@ -296,9 +296,8 @@ def config_SR_folder(config):
#create symlink
os.symlink(source, destination)
#write config file
cf = open(cfg, 'w')
cf.write(current_project + "#" + folder)
cf.close()
with open(cfg, 'w') as cf:
cf.write(current_project + '#' + folder)
def loadSoftwareRList(config):
......
......@@ -536,12 +536,11 @@ def saveParameterXml():
content = request.form['parameter'].encode("utf-8")
param_path = os.path.join(app.config['etc_dir'], ".parameter.xml")
try:
f = open(param_path, 'w')
f.write(content)
f.close()
with open(param_path, 'w') as f:
f.write(content)
result = readParameters(param_path)
except Exception as e:
result = str(e)
result = str(e)
software_type = None
if request.form['software_type']:
software_type = request.form['software_type']
......
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