From 0a50eee46dc82a1992e74aa89c25715f65a4be55 Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Thu, 9 Jul 2015 16:28:10 +0000 Subject: reproducible: json: fix tempfile handling, to avoid (non-fatal) FileNotFoundError --- bin/reproducible_json.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/reproducible_json.py b/bin/reproducible_json.py index d5d7aaf5..3103147d 100755 --- a/bin/reproducible_json.py +++ b/bin/reproducible_json.py @@ -36,12 +36,12 @@ for row in result: log.debug(pkg) output.append(pkg) -tmpfile = tempfile.NamedTemporaryFile(dir=os.path.dirname(REPRODUCIBLE_JSON)) +tmpfile = tempfile.mkstemp(dir=os.path.dirname(REPRODUCIBLE_JSON))[1] -with open(tmpfile.name, 'w') as fd: +with open(tmpfile, 'w') as fd: json.dump(output, fd, indent=4, sort_keys=True) -os.rename(tmpfile.name, REPRODUCIBLE_JSON) +os.rename(tmpfile, REPRODUCIBLE_JSON) os.chmod(REPRODUCIBLE_JSON, 0o644) log.info(REPRODUCIBLE_URL + '/reproducible.json has been updated.') -- cgit v1.2.3-70-g09d2