From 7014e9447c78af90578c75e5e0ebb91be3dfebb6 Mon Sep 17 00:00:00 2001 From: Brent Stapleton Date: Tue, 13 Feb 2018 17:27:39 -0800 Subject: utils: images downloader: adding --keep support When users supply the --keep argument, image archives are saved in the images directory alongside the image files. --- host/utils/uhd_images_downloader.py.in | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'host/utils') diff --git a/host/utils/uhd_images_downloader.py.in b/host/utils/uhd_images_downloader.py.in index 26715fcbe..a64330e15 100644 --- a/host/utils/uhd_images_downloader.py.in +++ b/host/utils/uhd_images_downloader.py.in @@ -72,7 +72,7 @@ def parse_args(): help=("Select archiving function (options: {})" .format(",".join(_ARCHIVE_ALGS)))) parser.add_argument("-k", "--keep", action="store_true", default=False, - help="Do not clear images directory before extracting new files") + help="Keep the downloaded images archives in the image directory") parser.add_argument("-n", "--dry-run", action="store_true", default=False, help="Print selected target without actually downloading them.") parser.add_argument("--refetch", action="store_true", default=False, @@ -262,9 +262,6 @@ def main(): if archive_type not in _ARCHIVE_ALGS: log("ERROR", "Selected archive type not supported: {}".format(archive_type)) return 1 - # TODO: keep not implemented - if args.keep: - log("WARN", "--keep not implemented. Downloaded archives will be deleted.") # Set the verbosity global _LOG_LEVEL log("TRACE", "Default log level: {}".format(_LOG_LEVEL)) @@ -350,6 +347,11 @@ def main(): delete_from_inv(filename, inventory, images_dir) archive_namelist = extract(temp_path, images_dir, archive_type) + if args.keep: + # If the user wants to keep the downloaded archive, + # save it to the images directory and add it to the inventory + shutil.copy(temp_path, images_dir) + archive_namelist.append(filename) inventory[filename] = {"repo_hash": target_hash, "contents": archive_namelist} else: log("INFO", "[Dry run] {} successfully downloaded" -- cgit v1.2.3