stdlib: Update the resources.json URL

It is important this URL remains stable across releases. Pulling
directly from the Google Source git repo is not stable and may change
over time. This patch updates the URL to
https://resources.gem5.org/resources.json. As the gem5.org domain is
under the gem5 project's control, we can ensure this does not change.

In order to ensure this downloader remains stable, the reading of the
resources.json file has been updated to either accept plain-text of
base64.

Change-Id: I549fabb1525ee1df68cb1641c1bd82ea8bd32262
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/59269
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
diff --git a/src/python/gem5/resources/downloader.py b/src/python/gem5/resources/downloader.py
index 2cb73ba..2a857e5 100644
--- a/src/python/gem5/resources/downloader.py
+++ b/src/python/gem5/resources/downloader.py
@@ -48,13 +48,7 @@
     return "21.2"
 
 def _get_resources_json_uri() -> str:
-    uri = (
-        "https://gem5.googlesource.com/public/gem5-resources/"
-        + "+/refs/heads/stable/resources.json?format=TEXT"
-    )
-
-    return uri
-
+    return "https://resources.gem5.org/resources.json"
 
 def _get_resources_json() -> Dict:
     """
@@ -63,11 +57,18 @@
     :returns: The Resources JSON (as a Python Dictionary).
     """
 
-    # Note: Google Source does not properly support obtaining files as raw
-    # text. Therefore when we open the URL we receive the JSON in base64
-    # format. Conversion is needed before it can be loaded.
+
     with urllib.request.urlopen(_get_resources_json_uri()) as url:
-        to_return = json.loads(base64.b64decode(url.read()).decode("utf-8"))
+        try:
+            to_return = json.loads(url.read())
+        except json.JSONDecodeError:
+            # This is a bit of a hack. If the URL specified exists in a Google
+            # Source repo (which is the case when on the gem5 develop branch)
+            # we retrieve the JSON in base64 format. This cannot be loaded
+            # directly as text. Conversion is therefore needed.
+            to_return = json.loads(
+                base64.b64decode(url.read()).decode("utf-8")
+            )
 
     # If the current version pulled is not correct, look up the
     # "previous-versions" field to find the correct one.
@@ -77,9 +78,12 @@
             with urllib.request.urlopen(
                     to_return["previous-versions"][version]
                 ) as url:
-                to_return = json.loads(
-                    base64.b64decode(url.read()).decode("utf-8")
-                )
+                try:
+                    to_return = json.loads(url.read())
+                except json.JSONDecodeError:
+                    to_return = json.loads(
+                        base64.b64decode(url.read()).decode("utf-8")
+                    )
         else:
             # This should never happen, but we thrown an exception to explain
             # that we can't find the version.