Bobby R. Bruce has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/51327 )

Change subject: python: Update gem5 lib downloader for new url_base field
......................................................................

python: Update gem5 lib downloader for new url_base field

This patch is designed to accomodate the upcoming change to the gem5
resources resources.json file:
https://gem5-review.googlesource.com/c/public/gem5-resources/+/51167.
The change extracts the base url ('http://dist.gem5.org/dist/develop')
from the urls. This patch is both compataible with the current
resources.json scheme and the upcoming schema.

Change-Id: I2a5b87cf94ba1afcb47d1f7d3ea48d0945ff21c4
---
M src/python/gem5/resources/downloader.py
1 file changed, 33 insertions(+), 1 deletion(-)



diff --git a/src/python/gem5/resources/downloader.py b/src/python/gem5/resources/downloader.py
index 5163724..13213bb 100644
--- a/src/python/gem5/resources/downloader.py
+++ b/src/python/gem5/resources/downloader.py
@@ -66,6 +66,17 @@
     with urllib.request.urlopen(_get_resources_json_uri()) as url:
         return json.loads(base64.b64decode(url.read()).decode("utf-8"))

+def _get_url_base() -> str:
+    """
+    Obtains the "url_base" string from the resources.json file.
+
+    :returns: The "url_base" string value from the resources.json file.
+    """
+    json = _get_resources_json()
+    if "url_base" in json.keys():
+        return json["url_base"]
+    return ""
+

 def _get_resources(resources_group: Dict) -> Dict[str, Dict]:
     """
@@ -243,7 +254,12 @@
# TODO: Might be nice to have some kind of download status bar here.
         # TODO: There might be a case where this should be silenced.
print("'{}' not found locally. Downloading...".format(resource_name))
-        _download(url=resource_json["url"], download_to=download_dest)
+
+ # Get the URL. The URL may contain '{url_base}' which needs replaced
+        # with the correct value.
+        url=resource_json["url"].format(url_base=_get_url_base())
+
+        _download(url=url, download_to=download_dest)
         print("Finished downloading '{}'.".format(resource_name))

         if run_unzip:

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/51327
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I2a5b87cf94ba1afcb47d1f7d3ea48d0945ff21c4
Gerrit-Change-Number: 51327
Gerrit-PatchSet: 1
Gerrit-Owner: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to