Fixed an issue with "KeyError: 'versions'" when dependency does not exist in the registry // Resolve #3666

This commit is contained in:
Ivan Kravets
2020-09-11 21:16:18 +03:00
parent ea21f3fba0
commit 7bc170a53e
3 changed files with 10 additions and 6 deletions

View File

@ -8,6 +8,11 @@ PlatformIO Core 5
**A professional collaborative platform for embedded development**
5.0.2 (2020-09-??)
~~~~~~~~~~~~~~~~~~
- Fixed an issue with "KeyError: 'versions'" when dependency does not exist in the registry (`issue #3666 <https://github.com/platformio/platformio-core/issues/3666>`_)
5.0.1 (2020-09-10)
~~~~~~~~~~~~~~~~~~

View File

@ -14,7 +14,7 @@
import sys
VERSION = (5, 0, 1)
VERSION = (5, 0, "2a1")
__version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio"

View File

@ -133,9 +133,7 @@ class HTTPClient(object):
def fetch_json_data(self, method, path, **kwargs):
cache_valid = kwargs.pop("cache_valid") if "cache_valid" in kwargs else None
if not cache_valid:
return self.raise_error_from_response(
self.send_request(method, path, **kwargs)
)
return self._parse_json_response(self.send_request(method, path, **kwargs))
cache_key = ContentCache.key_from_args(
method, path, kwargs.get("params"), kwargs.get("data")
)
@ -144,11 +142,12 @@ class HTTPClient(object):
if result is not None:
return json.loads(result)
response = self.send_request(method, path, **kwargs)
data = self._parse_json_response(response)
cc.set(cache_key, response.text, cache_valid)
return self.raise_error_from_response(response)
return data
@staticmethod
def raise_error_from_response(response, expected_codes=(200, 201, 202)):
def _parse_json_response(response, expected_codes=(200, 201, 202)):
if response.status_code in expected_codes:
try:
return response.json()