0

Fix update_bucket script for windows

Windows was not allowing copying of the temp file while it was still
open.  However, calling close by default causes the file to get deleted
automaticaly.  This defers that deletion.

Change-Id: I8ce712a4eb3de9d4d14f43389d341b016a64bae1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1539871
Reviewed-by: Klaus Weidner <klausw@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644482}
This commit is contained in:
Alex Cooper
2019-03-26 20:21:51 +00:00
committed by Commit Bot
parent a3724e3783
commit 8a864ab554

@ -153,10 +153,14 @@ def write_index():
content = template.render({'items': items})
logging.debug('index.html content:\n%s', content)
with tempfile.NamedTemporaryFile(suffix='.html') as temp:
temp.write(content)
temp.seek(0)
run_modify('gsutil.py', 'cp', temp.name, BUCKET + '/index.html')
with tempfile.NamedTemporaryFile(suffix='.html', delete=False) as temp:
try:
temp.write(content)
temp.seek(0)
temp.close()
run_modify('gsutil.py', 'cp', temp.name, BUCKET + '/index.html')
finally:
os.unlink(temp.name)
def update_test_copies():
"""Uploads a new test copy if available"""