diff options
author | Brent Stapleton <brent.stapleton@ettus.com> | 2018-02-13 17:27:39 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-02-15 03:24:14 +0100 |
commit | 7014e9447c78af90578c75e5e0ebb91be3dfebb6 (patch) | |
tree | 2c341ec29f061d4ee09f339a84a7c253cb253fa3 /host/utils/uhd_images_downloader.py.in | |
parent | 2a508aabd38a512d1c91c180b3e97fe027a1e80e (diff) | |
download | uhd-7014e9447c78af90578c75e5e0ebb91be3dfebb6.tar.gz uhd-7014e9447c78af90578c75e5e0ebb91be3dfebb6.tar.bz2 uhd-7014e9447c78af90578c75e5e0ebb91be3dfebb6.zip |
utils: images downloader: adding --keep support
When users supply the --keep argument, image archives are saved in the
images directory alongside the image files.
Diffstat (limited to 'host/utils/uhd_images_downloader.py.in')
-rw-r--r-- | host/utils/uhd_images_downloader.py.in | 10 |
1 files changed, 6 insertions, 4 deletions
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" |