aboutsummaryrefslogtreecommitdiffstats
path: root/host/utils
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2018-10-30 11:25:46 -0700
committerBrent Stapleton <bstapleton@g.hmc.edu>2018-11-13 12:12:09 -0800
commit07b0cc1b14ca8534234c89fdf0bd57a273f3f32a (patch)
tree306aed9e7ca074c4584ea0a71d0087a9e4d9a048 /host/utils
parent4f2e5b645cc14fe7cccffb64d3922d6a7fc328bd (diff)
downloaduhd-07b0cc1b14ca8534234c89fdf0bd57a273f3f32a.tar.gz
uhd-07b0cc1b14ca8534234c89fdf0bd57a273f3f32a.tar.bz2
uhd-07b0cc1b14ca8534234c89fdf0bd57a273f3f32a.zip
utils: Fix downloader return value for main()
This is effectively a refactoring: The main() function now returns True on success. This fixes a bug where one branch would simply return (None) instead of returning a value.
Diffstat (limited to 'host/utils')
-rw-r--r--host/utils/uhd_images_downloader.py.in18
1 files changed, 11 insertions, 7 deletions
diff --git a/host/utils/uhd_images_downloader.py.in b/host/utils/uhd_images_downloader.py.in
index f01eaed11..ef0bdd4ee 100644
--- a/host/utils/uhd_images_downloader.py.in
+++ b/host/utils/uhd_images_downloader.py.in
@@ -478,7 +478,11 @@ def update_target(target_info, temp_dir, images_dir, inventory, args):
def main():
- """Download the image files requested by the user"""
+ """
+ Main function; does whatever the user requested (download or list files).
+
+ Returns True on successful execution.
+ """
args = parse_args()
images_dir = get_images_dir(args)
log("INFO", "Images destination: {}".format(os.path.abspath(images_dir)))
@@ -489,7 +493,7 @@ def main():
manifest,
args
)
- return 0
+ return True
log("TRACE", "Manifest:\n{}".format(
"\n".join("{}".format(item) for item in manifest.items())
))
@@ -520,14 +524,14 @@ def main():
"\n".join("{}".format(item) for item in target_urls)
))
else:
- return 0
+ return True
## Now download all the images archives into a temp directory
if args.dry_run:
for target_info in targets_info:
log("INFO", "[Dry Run] Fetch target: {}".format(
target_info.get("filename")))
- return
+ return True
with TemporaryDirectory() as temp_dir:
for target_info in targets_info:
update_target(
@@ -551,11 +555,11 @@ def main():
# execute this in a shell.
if not _YES and platform.system() == 'Windows':
input('Hit Enter to continue.')
- return 1
+ return False
log("INFO", "Images download complete.")
- return 0
+ return True
# Placing this near the end of the file so we don't clutter the top
_MANIFEST_CONTENTS = """@CMAKE_MANIFEST_CONTENTS@"""
if __name__ == "__main__":
- sys.exit(main())
+ sys.exit(not main())