summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-06-04 12:56:35 +0200
committerMichael Stahl <mstahl@redhat.com>2015-06-04 21:51:25 +0200
commite5f9ee18476697a64d7ef646a072f8c76cf95b50 (patch)
tree17c03422f79fe65ceed5f7ed5fc1173466972a21 /bin
parentbd2eee0bd4ae83ff453522b7cf09b69f1b8b5e1b (diff)
get-bugzilla-attachments: avoid writing incomplete files
Change-Id: I7d1139ddf8c88626dd716aa537a305c31b5be5d9
Diffstat (limited to 'bin')
-rwxr-xr-xbin/get-bugzilla-attachments-by-mimetype12
1 files changed, 9 insertions, 3 deletions
diff --git a/bin/get-bugzilla-attachments-by-mimetype b/bin/get-bugzilla-attachments-by-mimetype
index fbc4031a9e98..a5f15702a4ea 100755
--- a/bin/get-bugzilla-attachments-by-mimetype
+++ b/bin/get-bugzilla-attachments-by-mimetype
@@ -94,9 +94,11 @@ def get_from_bug_url_via_xml(url, mimetype, prefix, suffix):
continue
print('downloading as ' + download)
- f = open(download, 'wb')
+ tmpfile = download + ".tmp"
+ f = open(tmpfile, 'wb')
f.write(base64.b64decode(node.firstChild.nodeValue))
f.close()
+ os.rename(tmpfile, download)
break
def get_novell_bug_via_xml(url, mimetype, prefix, suffix):
@@ -138,9 +140,11 @@ def get_novell_bug_via_xml(url, mimetype, prefix, suffix):
continue
print('downloading as ' + download)
- f = open(download, 'wb')
+ tmpfile = download + ".tmp"
+ f = open(tmpfile, 'wb')
f.write(handle.read())
f.close()
+ os.rename(tmpfile, download)
def create_query(mimetype):
query = dict()
@@ -327,9 +331,11 @@ def get_launchpad_bugs(prefix):
print('mimetype is ' + handle.content_type + ' downloading as ' + download)
- f = open(download, "w")
+ tmpfile = download + ".tmp"
+ f = open(tmpfile, "wb")
f.write(handle.read())
f.close()
+ os.rename(tmpfile, download)
rss_bugzillas = (
( 'abi', 'http://bugzilla.abisource.com/buglist.cgi' ), #added for abiword