From 33d7b3aefc9622bba732268ea65440e7cc444894 Mon Sep 17 00:00:00 2001 From: Daniel Ehlers Date: Wed, 1 Jan 2014 18:59:33 +0100 Subject: [PATCH] Write new file to a temporary and move it afterwards. --- bat2nodes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bat2nodes.py b/bat2nodes.py index 8204ce7..af1f10f 100755 --- a/bat2nodes.py +++ b/bat2nodes.py @@ -67,6 +67,10 @@ rrd.update_images() m = D3MapBuilder(db) -nodes_json = open(options['destination_directory'] + '/nodes.json','w') +#Write nodes json +nodes_json = open(options['destination_directory'] + '/nodes.json.new','w') nodes_json.write(m.build()) nodes_json.close() + +#Move to destination +os.rename(options['destination_directory'] + '/nodes.json.new',options['destination_directory'] + '/nodes.json')