mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 02:27:13 +02:00
Minor improvements
This commit is contained in:
@ -163,7 +163,7 @@ class SerialPortFinder:
|
||||
for item in list_serial_ports(as_objects=True):
|
||||
if item.vid == device.vid and item.pid == device.pid:
|
||||
candidates.append(item)
|
||||
if len(candidates) == 1:
|
||||
if len(candidates) <= 1:
|
||||
return device.device
|
||||
for item in candidates:
|
||||
if ("GDB" if self.prefer_gdb_port else "UART") in item.description:
|
||||
|
@ -81,7 +81,7 @@ class InvalidSettingValue(UserSideException):
|
||||
MESSAGE = "Invalid value '{0}' for the setting '{1}'"
|
||||
|
||||
|
||||
class InvalidJSONFile(PlatformioException):
|
||||
class InvalidJSONFile(ValueError, UserSideException):
|
||||
MESSAGE = "Could not load broken JSON: {0}"
|
||||
|
||||
|
||||
|
@ -157,7 +157,10 @@ class HTTPClient:
|
||||
with ContentCache("http") as cc:
|
||||
result = cc.get(cache_key)
|
||||
if result is not None:
|
||||
return json.loads(result)
|
||||
try:
|
||||
return json.loads(result)
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
response = self.send_request(method, path, **kwargs)
|
||||
data = self._parse_json_response(response)
|
||||
cc.set(cache_key, response.text, cache_valid)
|
||||
|
@ -15,7 +15,7 @@
|
||||
import os
|
||||
from time import sleep, time
|
||||
|
||||
from platformio.exception import PlatformioException
|
||||
from platformio.exception import UserSideException
|
||||
|
||||
LOCKFILE_TIMEOUT = 3600 # in seconds, 1 hour
|
||||
LOCKFILE_DELAY = 0.2
|
||||
@ -36,11 +36,11 @@ except ImportError:
|
||||
LOCKFILE_CURRENT_INTERFACE = None
|
||||
|
||||
|
||||
class LockFileExists(PlatformioException):
|
||||
class LockFileExists(UserSideException):
|
||||
pass
|
||||
|
||||
|
||||
class LockFileTimeoutError(PlatformioException):
|
||||
class LockFileTimeoutError(UserSideException):
|
||||
pass
|
||||
|
||||
|
||||
|
@ -25,12 +25,13 @@ from platformio.registry.mirror import RegistryFileMirrorIterator
|
||||
|
||||
class PackageManagerRegistryMixin:
|
||||
def install_from_registry(self, spec, search_qualifiers=None):
|
||||
package = version = None
|
||||
if spec.owner and spec.name and not search_qualifiers:
|
||||
package = self.fetch_registry_package(spec)
|
||||
if not package:
|
||||
raise UnknownPackageError(spec.humanize())
|
||||
version = self.pick_best_registry_version(package["versions"], spec)
|
||||
else:
|
||||
elif spec.id or spec.name:
|
||||
packages = self.search_registry_packages(spec, search_qualifiers)
|
||||
if not packages:
|
||||
raise UnknownPackageError(spec.humanize())
|
||||
|
@ -17,7 +17,7 @@ import os
|
||||
from platformio import fs, util
|
||||
from platformio.compat import MISSING
|
||||
from platformio.debug.exception import DebugInvalidOptionsError, DebugSupportError
|
||||
from platformio.exception import UserSideException
|
||||
from platformio.exception import InvalidJSONFile, UserSideException
|
||||
from platformio.platform.exception import InvalidBoardManifest
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ class PlatformBoardConfig:
|
||||
self.manifest_path = manifest_path
|
||||
try:
|
||||
self._manifest = fs.load_json(manifest_path)
|
||||
except ValueError as exc:
|
||||
except InvalidJSONFile as exc:
|
||||
raise InvalidBoardManifest(manifest_path) from exc
|
||||
if not set(["name", "url", "vendor"]) <= set(self._manifest):
|
||||
raise UserSideException(
|
||||
|
Reference in New Issue
Block a user