Simplify some file logic with "with"

This commit is contained in:
Daniel Martí 2015-08-28 18:37:23 -07:00
parent 2894786ec9
commit 6fe8d96e85
4 changed files with 48 additions and 63 deletions

View file

@ -1097,9 +1097,8 @@ def main():
build_succeeded.append(app)
wikilog = "Build succeeded"
except BuildException as be:
logfile = open(os.path.join(log_dir, appid + '.log'), 'a+')
logfile.write(str(be))
logfile.close()
with open(os.path.join(log_dir, appid + '.log'), 'a+') as f:
f.write(str(be))
print("Could not build app %s due to BuildException: %s" % (appid, be))
if options.stop:
sys.exit(1)