aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorNicholas Corgan <nick.corgan@ettus.com>2013-11-13 06:59:47 -0800
committerNicholas Corgan <nick.corgan@ettus.com>2013-11-13 06:59:47 -0800
commit402a39feb2600c2f366b8218ebd4c6b8562b4af4 (patch)
tree0b81680374ef64f8ca73f14f5dfc9a2689ea07de /host
parentd02adc5693fa34f81278c0d5c9d94bfd3bee7943 (diff)
downloaduhd-402a39feb2600c2f366b8218ebd4c6b8562b4af4.tar.gz
uhd-402a39feb2600c2f366b8218ebd4c6b8562b4af4.tar.bz2
uhd-402a39feb2600c2f366b8218ebd4c6b8562b4af4.zip
uhd_images_downloader: redundancy fixes, better error handling
Diffstat (limited to 'host')
-rw-r--r--host/utils/uhd_images_downloader.py.in26
1 files changed, 14 insertions, 12 deletions
diff --git a/host/utils/uhd_images_downloader.py.in b/host/utils/uhd_images_downloader.py.in
index 91f32825f..93abffaf4 100644
--- a/host/utils/uhd_images_downloader.py.in
+++ b/host/utils/uhd_images_downloader.py.in
@@ -46,8 +46,9 @@ class temp_dir():
def __exit__(self, type, value, traceback):
try:
shutil.rmtree(self.name)
- except OSError:
+ except OSError,e:
#Utility should have already detected this, but this is for safety
+ print str(e)
raise Exception("Could not install images! Make sure you have write permissions.")
if __name__ == "__main__":
@@ -76,9 +77,7 @@ if __name__ == "__main__":
with temp_dir() as dirname:
os.chdir(dirname)
- if options.install_location == default_images_dir:
- images_dir = default_images_dir
- elif os.path.isabs(options.install_location):
+ if os.path.isabs(options.install_location):
#Custom absolute path given
images_dir = options.install_location
else:
@@ -127,29 +126,32 @@ if __name__ == "__main__":
os.remove(filename)
os.chdir("/".join(images_dir.split("/")[:-1]))
else:
+ temp_path = "tempdir"
+
#Extracting contents of zip file
- if os.path.exists("tempdir"):
- shutil.rmtree("tempdir")
- os.mkdir("tempdir")
+ if os.path.exists(temp_path):
+ shutil.rmtree(temp_path)
+ os.mkdir(temp_path)
images_zip = zipfile.ZipFile(filename)
- images_zip.extractall("tempdir")
+ images_zip.extractall(temp_path)
#Removing images currently in images_dir
if os.path.exists(images_dir):
try:
shutil.rmtree(images_dir)
- except OSError:
+ except OSError,e:
+ print str(e)
print "Make sure you have write permissions in the images directory."
sys.exit(1)
#Copying downloaded images into images_dir
- shutil.copytree(os.path.join('tempdir', os.path.splitext(filename)[0], 'share', 'uhd', 'images'), images_dir)
+ shutil.copytree(os.path.join(temp_path, os.path.splitext(filename)[0], 'share', 'uhd', 'images'), images_dir)
#Removing tempdir and zip file
- shutil.rmtree("tempdir")
+ shutil.rmtree(temp_path)
images_zip.close()
os.remove(filename)
os.chdir(images_dir)
- print "\nImages successfully installed to: %s" % images_dir
+ print "\n\nImages successfully installed!"