diff options
| author | Brent Stapleton <brent.stapleton@ettus.com> | 2018-03-16 11:17:02 -0700 | 
|---|---|---|
| committer | Martin Braun <martin.braun@ettus.com> | 2018-03-16 14:27:05 -0700 | 
| commit | 329b41b753b27b8e9af8b8e12bea6ccf4bfbbc63 (patch) | |
| tree | b70bfe831d4ef0d1b1419e53194d464760ae6226 /host/utils/uhd_images_downloader.py.in | |
| parent | f5241fcab30385fe066358272f1e23fbac0fd543 (diff) | |
| download | uhd-329b41b753b27b8e9af8b8e12bea6ccf4bfbbc63.tar.gz uhd-329b41b753b27b8e9af8b8e12bea6ccf4bfbbc63.tar.bz2 uhd-329b41b753b27b8e9af8b8e12bea6ccf4bfbbc63.zip | |
utils: downloader supports multiple RegExs
uhd_images_downloader now accepts multiple '--types' options, each of
which is a RegEx. Targets which match to all of the provided `types`
are downloaded.
Example usage:
`uhd_images_downloader -t n3xx -t fpga`
will match the following targets:
- n3xx_n310_fpga_default
- n3xx_n310_fpga_aurora
- n3xx_n300_fpga_default
Diffstat (limited to 'host/utils/uhd_images_downloader.py.in')
| -rw-r--r-- | host/utils/uhd_images_downloader.py.in | 15 | 
1 files changed, 9 insertions, 6 deletions
| diff --git a/host/utils/uhd_images_downloader.py.in b/host/utils/uhd_images_downloader.py.in index 4c39aece2..b08a1df99 100644 --- a/host/utils/uhd_images_downloader.py.in +++ b/host/utils/uhd_images_downloader.py.in @@ -55,7 +55,7 @@ def log(level, message):  def parse_args():      """Setup argument parser and parse"""      parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) -    parser.add_argument('-t', '--types', type=str, default="", +    parser.add_argument('-t', '--types', action='append',                          help="RegEx to select image sets from the manifest file.")      parser.add_argument('-i', '--install-location',                          default=None, @@ -155,7 +155,7 @@ def write_inventory(inventory, inventory_fn):          return False -def lookup_urls(regex, manifest, inventory, refetch=False): +def lookup_urls(regex_l, manifest, inventory, refetch=False):      """Takes a list of RegExs to match within the manifest, returns a list of tuples with      (hash, URL) that match the targets and are not in the inventory"""      selected_targets = [] @@ -163,7 +163,7 @@ def lookup_urls(regex, manifest, inventory, refetch=False):          # Iterate through the possible targets in the manifest.          # If any of them match any of the RegExs supplied, add the URL to the          # return list -        if re.findall(regex, target): +        if all(map((lambda regex: re.findall(regex, target)), regex_l)):              log("TRACE", "Selected target: {}".format(target))              target_info = manifest.get(target)              target_url = target_info.get("url") @@ -328,10 +328,13 @@ def main():          ))          # Determine the URLs to download based on the input regular expressions -        types_regex = _DEFAULT_TARGET_REGEX if args.types == "" else args.types +        if not args.types: +            types_regex_l = [_DEFAULT_TARGET_REGEX] +        else: +            types_regex_l = args.types -        log("TRACE", "RegEx for target selection: {}".format(types_regex)) -        targets_info = lookup_urls(types_regex, manifest, inventory, args.refetch) +        log("TRACE", "RegExs for target selection: {}".format(types_regex_l)) +        targets_info = lookup_urls(types_regex_l, manifest, inventory, args.refetch)          # Exit early if we don't have anything to download          if targets_info:              target_urls = [info.get("url") for info in targets_info] | 
