Skip to content
Snippets Groups Projects
Commit 503c8492 authored by Tim O'Donnell's avatar Tim O'Donnell
Browse files

Switch downloads_command to use mkstemp instead of NamedTemporaryFile for...

Switch downloads_command to use mkstemp instead of NamedTemporaryFile for windows support. Fixes #79
parent 62794808
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ import os
from pipes import quote
import errno
import tarfile
from tempfile import NamedTemporaryFile
from tempfile import mkstemp
try:
from urllib.request import urlretrieve
except ImportError:
......@@ -186,8 +186,8 @@ def fetch_subcommand(args):
# making an incomplete extract if the process is killed.
for item in items_to_fetch:
metadata = downloads[item]['metadata']
with NamedTemporaryFile(delete=not args.keep) as temp_fd:
target_path = temp_fd.name
(temp_fd, target_path) = mkstemp()
try:
qprint("Downloading: %s" % metadata['url'])
urlretrieve(metadata['url'], target_path)
qprint("Downloaded to: %s" % quote(target_path))
......@@ -208,6 +208,9 @@ def fetch_subcommand(args):
tar.close()
qprint("Extracted %d files to: %s" % (
len(names), quote(result_dir)))
finally:
if not args.keep:
os.remove(target_path)
def info_subcommand(args):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment