aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Kozel <derek.kozel@ettus.com>2017-07-14 13:18:10 +0100
committerMartin Braun <martin.braun@ettus.com>2017-07-17 09:23:55 -0700
commit684fd3a3ffaf31b9fa726ccf2fdea2627f6ea10d (patch)
treec0ffa2d64135d48f3036143275b234a1d10404e2
parent38723f62183227068dc3163278cd7d2de8c01218 (diff)
downloaduhd-684fd3a3ffaf31b9fa726ccf2fdea2627f6ea10d.tar.gz
uhd-684fd3a3ffaf31b9fa726ccf2fdea2627f6ea10d.tar.bz2
uhd-684fd3a3ffaf31b9fa726ccf2fdea2627f6ea10d.zip
utils: Added warnings and checks to images downloader
-rw-r--r--host/utils/uhd_images_downloader.py.in14
1 files changed, 14 insertions, 0 deletions
diff --git a/host/utils/uhd_images_downloader.py.in b/host/utils/uhd_images_downloader.py.in
index 593f7759f..84be10902 100644
--- a/host/utils/uhd_images_downloader.py.in
+++ b/host/utils/uhd_images_downloader.py.in
@@ -252,6 +252,8 @@ def main():
help="Do not clear images directory before extracting new files [default=%default]")
parser.add_option("-v", "--verbose", action="store_true", default=False,
help="Enable verbose output [default=%default]")
+ parser.add_option("--force-delete", action="store_true", default=False,
+ help="Delete all files in the target images directory without prompting [default=%default]")
(options, args) = parser.parse_args()
if options.buffer_size <= 0:
print("Invalid buffer size: %s" % (options.buffer_size))
@@ -287,6 +289,18 @@ def main():
else:
print("Images destination: %s" % (images_dir))
+ ### Check contradictory arguments
+ if options.force_delete and options.keep:
+ print("Error: Keep and force delete options contradict.\n")
+ parser.print_help()
+ return 1
+
+ ### Prevent accidental file deletion
+ if options.install_location != default_images_dir and options.force_delete == False and options.keep != True:
+ print("Custom install location specified, defaulting to overwriting only image files.\n"
+ "Use \'--force-delete\' to clean the target directory first.")
+ options.keep = True
+
### Download or copy
downloader = uhd_images_downloader()
try: