From 61ea2e9142df524cf6d1dc32d2fde9f4ce477b36 Mon Sep 17 00:00:00 2001 From: Nicholas Corgan Date: Wed, 7 Nov 2012 14:30:13 -0800 Subject: utils: fixed images downloader Mac incompatibility issue --- host/utils/uhd_images_downloader.py.in | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/host/utils/uhd_images_downloader.py.in b/host/utils/uhd_images_downloader.py.in index 6aa619660..59c0fbafe 100644 --- a/host/utils/uhd_images_downloader.py.in +++ b/host/utils/uhd_images_downloader.py.in @@ -16,11 +16,13 @@ # along with this program. If not, see . # +import atexit from optparse import OptionParser import os import os.path import shutil import sys +import tempfile import urllib2 import zipfile @@ -28,18 +30,24 @@ if __name__ == "__main__": #Command line options parser = OptionParser() - parser.add_option("--download-location", type="string", default="@CMAKE_INSTALL_PREFIX@/share/uhd/images", help="Set custom download location for images, [default=%default]") + parser.add_option("--install-location", type="string", default="@CMAKE_INSTALL_PREFIX@/share/uhd/images", help="Set custom install location for images, [default=%default]") parser.add_option("--buffer-size", type="int", default=8192, help="Set download buffer size, [default=%default]",) (options, args) = parser.parse_args() #Configuring image download info images_src = "@UHD_IMAGES_DOWNLOAD_SRC@" filename = images_src.split("/")[-1] - + + #Create temporary directory + download_dir = tempfile.mkdtemp() + atexit.register(lambda: shutil.rmtree(download_dir)) + + #Make sure we download into the correct directory + os.chdir(download_dir) + #Configuring image destination - cmake_install_prefix = "@CMAKE_INSTALL_PREFIX@" - if options.download_location != "": - images_dir = options.download_location + if options.install_location != "": + images_dir = options.install_location else: images_dir = "@CMAKE_INSTALL_PREFIX@/share/uhd/images" -- cgit v1.2.3