diff options
Diffstat (limited to 'host')
-rw-r--r-- | host/utils/uhd_images_downloader.py.in | 18 |
1 files 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 <http://www.gnu.org/licenses/>. # +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" |