File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change 17
17
import sys
18
18
import json
19
19
import re
20
- import requests
21
20
22
21
from platformio .public import PlatformBase , to_unix_path
23
22
@@ -349,16 +348,15 @@ def _prepare_url_for_index_file(url_items):
349
348
)
350
349
351
350
index_file_url = _prepare_url_for_index_file (url_items )
352
- r = requests .get (index_file_url , timeout = 10 )
353
- if r .status_code != 200 :
354
- raise ValueError (
355
- (
356
- "Failed to download package index file due to a bad response (%d) "
357
- "from the remote `%s`"
358
- )
359
- % (r .status_code , index_file_url )
360
- )
361
- return r .json ()
351
+
352
+ try :
353
+ from platformio .public import fetch_http_content
354
+ content = fetch_http_content (index_file_url )
355
+ except ImportError :
356
+ import requests
357
+ content = requests .get (index_file_url , timeout = 5 ).text
358
+
359
+ return json .loads (content )
362
360
363
361
def configure_arduino_toolchains (self , package_index ):
364
362
if not package_index :
You can’t perform that action at this time.
0 commit comments