Bobby R. Bruce has submitted this change. ( 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
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51327
Reviewed-by: Bobby R. Bruce <bbr...@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbr...@ucdavis.edu>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/python/gem5/resources/downloader.py
1 file changed, 38 insertions(+), 1 deletion(-)

Approvals:
  Bobby R. Bruce: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/python/gem5/resources/downloader.py b/src/python/gem5/resources/downloader.py
index 5163724..faeddb0 100644
--- a/src/python/gem5/resources/downloader.py
+++ b/src/python/gem5/resources/downloader.py
@@ -67,6 +67,18 @@
         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]:
     """
     A recursive function to get all the resources.
@@ -243,7 +255,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: 3
Gerrit-Owner: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
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