Browse Source

build: fix index upload error on 15-x-y (#34314)

Keeley Hammond 2 years ago
parent
commit
54432ab8b2
1 changed files with 7 additions and 3 deletions
  1. 7 3
      script/release/uploaders/upload-index-json.py

+ 7 - 3
script/release/uploaders/upload-index-json.py

@@ -4,7 +4,11 @@ from __future__ import print_function
 import json
 import os
 import sys
-import urllib2
+# Python 3 / 2 compat import
+try:
+  from urllib.request import Request, urlopen
+except ImportError:
+  from urllib2 import Request, urlopen
 
 sys.path.append(
   os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../.."))
@@ -28,12 +32,12 @@ def is_json(myjson):
 
 def get_content(retry_count = 5):
   try:
-    request = urllib2.Request(
+    request = Request(
       BASE_URL + version,
       headers={"Authorization" : authToken}
     )
 
-    proposed_content = urllib2.urlopen(
+    proposed_content = urlopen(
       request
     ).read()