Use a with block to create index.html.
Also, updates our IO so we write to a .tmp file and rename it only after the file IO is completed. This wards off a potential race where a user could load a page that hadn't been fully flushed to disk. Change-Id: I04bfb7def801f11e3fcae83272879f660a8d1825
This commit is contained in:
parent
80b63eced6
commit
a409123c9b
|
@ -44,8 +44,8 @@ def create_report(out_dir, name_space={}):
|
|||
|
||||
prep_out_dir(out_dir)
|
||||
|
||||
out_file = open(os.path.join(out_dir, 'index.html'), "w")
|
||||
out_file.write(str(t))
|
||||
out_file.close()
|
||||
with open(os.path.join(out_dir, 'index.html.tmp'), "w") as f:
|
||||
f.write(str(t))
|
||||
os.rename(f.name, os.path.join(out_dir, 'index.html'))
|
||||
|
||||
_create_json(out_dir, name_space=name_space)
|
||||
|
|
Loading…
Reference in New Issue