From 684fd3a3ffaf31b9fa726ccf2fdea2627f6ea10d Mon Sep 17 00:00:00 2001 From: Derek Kozel Date: Fri, 14 Jul 2017 13:18:10 +0100 Subject: utils: Added warnings and checks to images downloader --- host/utils/uhd_images_downloader.py.in | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'host') 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: -- cgit v1.2.3