aboutsummaryrefslogtreecommitdiffstats
path: root/host/utils
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2018-10-30 11:21:18 -0700
committerBrent Stapleton <bstapleton@g.hmc.edu>2018-11-13 12:12:09 -0800
commit4f2e5b645cc14fe7cccffb64d3922d6a7fc328bd (patch)
tree5262301b54c98a13741aad99c922a73ab25a9062 /host/utils
parent49f9e44966566bfe8608351363434cb343f1df84 (diff)
downloaduhd-4f2e5b645cc14fe7cccffb64d3922d6a7fc328bd.tar.gz
uhd-4f2e5b645cc14fe7cccffb64d3922d6a7fc328bd.tar.bz2
uhd-4f2e5b645cc14fe7cccffb64d3922d6a7fc328bd.zip
utils: Downloader stall on error for Windows users
If platform.system() is 'Windows', the Python script will stall on error before terminating, e.g., when an import is missing or when an unexpected Exception occurred during the execution. The rationale is that many Windows users run this script directly, without a shell, and wouldn't have a way to see error messages from the script in that case.
Diffstat (limited to 'host/utils')
-rw-r--r--host/utils/uhd_images_downloader.py.in32
1 files changed, 30 insertions, 2 deletions
diff --git a/host/utils/uhd_images_downloader.py.in b/host/utils/uhd_images_downloader.py.in
index 0c19e9167..f01eaed11 100644
--- a/host/utils/uhd_images_downloader.py.in
+++ b/host/utils/uhd_images_downloader.py.in
@@ -18,6 +18,9 @@ import shutil
import sys
import tempfile
import zipfile
+import platform
+# For all the non-core-library imports, we will be extra paranoid and be very
+# nice with error messages so that everyone understands what's up.
try:
from urllib.parse import urljoin # Python 3
except ImportError:
@@ -26,8 +29,27 @@ try:
from builtins import input
except ImportError:
input = raw_input
-from six import iteritems
-import requests
+try:
+ from six import iteritems
+except ImportError:
+ sys.stdout.write(
+ "[ERROR] Missing module 'six'! Please install it, e.g., by "
+ "running 'pip install six' or any other tool that can install "
+ "Python modules.\n")
+ if platform.system() == 'Windows':
+ input('Hit Enter to continue.')
+ exit(0)
+try:
+ import requests
+except ImportError:
+ sys.stdout.write(
+ "[ERROR] Missing module 'requests'! Please install it, e.g., by "
+ "running 'pip install requests' or any other tool that can install "
+ "Python modules.\n")
+ if platform.system() == 'Windows':
+ input('Hit Enter to continue.')
+ exit(0)
+
_DEFAULT_TARGET_REGEX = "(fpga|fw|windrv)_default"
@@ -523,6 +545,12 @@ def main():
"You can run this again with the '--verbose' flag to see more information\n"
"If the problem persists, please email the output to: {contact}"
.format(contact=_CONTACT, ex=ex))
+ # Again, we wait on Windows systems because if this is executed in a
+ # window, and immediately fails, the user doesn't have a way to see the
+ # error message, and if they're not very savvy, they won't know how to
+ # execute this in a shell.
+ if not _YES and platform.system() == 'Windows':
+ input('Hit Enter to continue.')
return 1
log("INFO", "Images download complete.")
return 0