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

Change subject: python: Update the gem5 lib downloader 'is_zipped' checker
......................................................................

python: Update the gem5 lib downloader 'is_zipped' checker

Previously, gem5 resources' resources.json file set the 'is_zipped'
field to a string, either "True" or "False". As JSON supports booleans,
this was updated in an upcoming patch to use boolean values instead:
https://gem5-review.googlesource.com/c/public/gem5-resources/+/51168.

This patch updates the gem5 library downloader to use the new true/false
values but remains backwards compataible with the old string-based way
of declaring the value of this field.

Change-Id: I804ce66e8ca1989955b09041b7d1c894de74dac0
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51329
Reviewed-by: Jason Lowe-Power <power...@gmail.com>
Maintainer: Jason Lowe-Power <power...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/python/gem5/resources/downloader.py
1 file changed, 40 insertions(+), 1 deletion(-)

Approvals:
  Jason Lowe-Power: 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 a097f24..28f813d 100644
--- a/src/python/gem5/resources/downloader.py
+++ b/src/python/gem5/resources/downloader.py
@@ -251,7 +251,24 @@
                 )

         download_dest = to_path
-        run_unzip = unzip and resource_json["is_zipped"].lower() == "true"
+
+        # This if-statement is remain backwards compatable with the older,
+        # string-based way of doing things. It can be refactored away over
+        # time:
+ # https://gem5-review.googlesource.com/c/public/gem5-resources/+/51168
+        if isinstance(resource_json["is_zipped"], str):
+ run_unzip = unzip and resource_json["is_zipped"].lower() == "true"
+        elif isinstance(resource_json["is_zipped"], bool):
+            run_unzip = unzip and resource_json["is_zipped"]
+        else:
+            raise Exception(
+                "The resource.json entry for '{}' has a value for the "
+                "'is_zipped' field which is neither a string or a boolean."
+                .format(
+                    resource_name
+                )
+            )
+
         if run_unzip:
             download_dest += ".gz"


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/51329
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: I804ce66e8ca1989955b09041b7d1c894de74dac0
Gerrit-Change-Number: 51329
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