Use "platformio.public.fetch_http_content" API for HTTP requests
This commit is contained in:
+9
-11
@@ -17,7 +17,6 @@ import urllib
|
|||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import requests
|
|
||||||
|
|
||||||
from platformio.public import PlatformBase, to_unix_path
|
from platformio.public import PlatformBase, to_unix_path
|
||||||
|
|
||||||
@@ -349,16 +348,15 @@ class Espressif32Platform(PlatformBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
index_file_url = _prepare_url_for_index_file(url_items)
|
index_file_url = _prepare_url_for_index_file(url_items)
|
||||||
r = requests.get(index_file_url, timeout=10)
|
|
||||||
if r.status_code != 200:
|
try:
|
||||||
raise ValueError(
|
from platformio.public import fetch_http_content
|
||||||
(
|
content = fetch_http_content(index_file_url)
|
||||||
"Failed to download package index file due to a bad response (%d) "
|
except ImportError:
|
||||||
"from the remote `%s`"
|
import requests
|
||||||
)
|
content = requests.get(index_file_url, timeout=5).text
|
||||||
% (r.status_code, index_file_url)
|
|
||||||
)
|
return json.loads(content)
|
||||||
return r.json()
|
|
||||||
|
|
||||||
def configure_arduino_toolchains(self, package_index):
|
def configure_arduino_toolchains(self, package_index):
|
||||||
if not package_index:
|
if not package_index:
|
||||||
|
|||||||
Reference in New Issue
Block a user