mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Use PY3 super() zero-argument syntax
This commit is contained in:
2
docs
2
docs
Submodule docs updated: acdba4baec...c6172dcea4
@ -632,7 +632,7 @@ class MbedLibBuilder(LibBuilderBase):
|
|||||||
|
|
||||||
def process_extra_options(self):
|
def process_extra_options(self):
|
||||||
self._process_mbed_lib_confs()
|
self._process_mbed_lib_confs()
|
||||||
return super(MbedLibBuilder, self).process_extra_options()
|
return super().process_extra_options()
|
||||||
|
|
||||||
def _process_mbed_lib_confs(self):
|
def _process_mbed_lib_confs(self):
|
||||||
mbed_lib_paths = [
|
mbed_lib_paths = [
|
||||||
@ -851,7 +851,7 @@ class ProjectAsLibBuilder(LibBuilderBase):
|
|||||||
def __init__(self, env, *args, **kwargs):
|
def __init__(self, env, *args, **kwargs):
|
||||||
# backup original value, will be reset in base.__init__
|
# backup original value, will be reset in base.__init__
|
||||||
project_src_filter = env.get("SRC_FILTER")
|
project_src_filter = env.get("SRC_FILTER")
|
||||||
super(ProjectAsLibBuilder, self).__init__(env, *args, **kwargs)
|
super().__init__(env, *args, **kwargs)
|
||||||
self.env["SRC_FILTER"] = project_src_filter
|
self.env["SRC_FILTER"] = project_src_filter
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -40,7 +40,7 @@ class AccountClient(HTTPClient): # pylint:disable=too-many-public-methods
|
|||||||
SUMMARY_CACHE_TTL = 60 * 60 * 24 * 7
|
SUMMARY_CACHE_TTL = 60 * 60 * 24 * 7
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(AccountClient, self).__init__(__accounts_api__)
|
super().__init__(__accounts_api__)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_refresh_token():
|
def get_refresh_token():
|
||||||
@ -63,7 +63,7 @@ class AccountClient(HTTPClient): # pylint:disable=too-many-public-methods
|
|||||||
|
|
||||||
def fetch_json_data(self, *args, **kwargs):
|
def fetch_json_data(self, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return super(AccountClient, self).fetch_json_data(*args, **kwargs)
|
return super().fetch_json_data(*args, **kwargs)
|
||||||
except HTTPClientError as exc:
|
except HTTPClientError as exc:
|
||||||
raise AccountError(exc) from exc
|
raise AccountError(exc) from exc
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ from platformio.exception import PlatformioException, UserSideException
|
|||||||
|
|
||||||
class HTTPClientError(PlatformioException):
|
class HTTPClientError(PlatformioException):
|
||||||
def __init__(self, message, response=None):
|
def __init__(self, message, response=None):
|
||||||
super(HTTPClientError, self).__init__()
|
super().__init__()
|
||||||
self.message = message
|
self.message = message
|
||||||
self.response = response
|
self.response = response
|
||||||
|
|
||||||
@ -47,16 +47,14 @@ class InternetIsOffline(UserSideException):
|
|||||||
|
|
||||||
class EndpointSession(requests.Session):
|
class EndpointSession(requests.Session):
|
||||||
def __init__(self, base_url, *args, **kwargs):
|
def __init__(self, base_url, *args, **kwargs):
|
||||||
super(EndpointSession, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.base_url = base_url
|
self.base_url = base_url
|
||||||
|
|
||||||
def request( # pylint: disable=signature-differs,arguments-differ
|
def request( # pylint: disable=signature-differs,arguments-differ
|
||||||
self, method, url, *args, **kwargs
|
self, method, url, *args, **kwargs
|
||||||
):
|
):
|
||||||
# print(self.base_url, method, url, args, kwargs)
|
# print(self.base_url, method, url, args, kwargs)
|
||||||
return super(EndpointSession, self).request(
|
return super().request(method, urljoin(self.base_url, url), *args, **kwargs)
|
||||||
method, urljoin(self.base_url, url), *args, **kwargs
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class EndpointSessionIterator(object):
|
class EndpointSessionIterator(object):
|
||||||
|
@ -21,7 +21,7 @@ from platformio.clients.http import HTTPClient, HTTPClientError
|
|||||||
|
|
||||||
class RegistryClient(HTTPClient):
|
class RegistryClient(HTTPClient):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(RegistryClient, self).__init__(__registry_api__)
|
super().__init__(__registry_api__)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def allowed_private_packages():
|
def allowed_private_packages():
|
||||||
|
@ -22,7 +22,7 @@ class PlatformioCLI(click.MultiCommand):
|
|||||||
leftover_args = []
|
leftover_args = []
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(PlatformioCLI, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._pio_cmds_dir = os.path.dirname(__file__)
|
self._pio_cmds_dir = os.path.dirname(__file__)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -41,7 +41,7 @@ class PlatformioCLI(click.MultiCommand):
|
|||||||
PlatformioCLI.leftover_args = ctx.args
|
PlatformioCLI.leftover_args = ctx.args
|
||||||
if hasattr(ctx, "protected_args"):
|
if hasattr(ctx, "protected_args"):
|
||||||
PlatformioCLI.leftover_args = ctx.protected_args + ctx.args
|
PlatformioCLI.leftover_args = ctx.protected_args + ctx.args
|
||||||
return super(PlatformioCLI, self).invoke(ctx)
|
return super().invoke(ctx)
|
||||||
|
|
||||||
def list_commands(self, ctx):
|
def list_commands(self, ctx):
|
||||||
cmds = []
|
cmds = []
|
||||||
|
@ -23,7 +23,7 @@ from platformio.commands.check.tools.base import CheckToolBase
|
|||||||
|
|
||||||
class CppcheckCheckTool(CheckToolBase):
|
class CppcheckCheckTool(CheckToolBase):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(CppcheckCheckTool, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._field_delimiter = "<&PIO&>"
|
self._field_delimiter = "<&PIO&>"
|
||||||
self._buffer = ""
|
self._buffer = ""
|
||||||
self.defect_fields = [
|
self.defect_fields = [
|
||||||
@ -207,7 +207,7 @@ class CppcheckCheckTool(CheckToolBase):
|
|||||||
return self._create_tmp_file("\n".join(result))
|
return self._create_tmp_file("\n".join(result))
|
||||||
|
|
||||||
def clean_up(self):
|
def clean_up(self):
|
||||||
super(CppcheckCheckTool, self).clean_up()
|
super().clean_up()
|
||||||
|
|
||||||
# delete temporary dump files generated by addons
|
# delete temporary dump files generated by addons
|
||||||
if not self.is_flag_set("--addon", self.get_flags("cppcheck")):
|
if not self.is_flag_set("--addon", self.get_flags("cppcheck")):
|
||||||
|
@ -27,7 +27,7 @@ from platformio.compat import IS_WINDOWS
|
|||||||
|
|
||||||
class PvsStudioCheckTool(CheckToolBase): # pylint: disable=too-many-instance-attributes
|
class PvsStudioCheckTool(CheckToolBase): # pylint: disable=too-many-instance-attributes
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(PvsStudioCheckTool, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._tmp_dir = tempfile.mkdtemp(prefix="piocheck")
|
self._tmp_dir = tempfile.mkdtemp(prefix="piocheck")
|
||||||
self._tmp_preprocessed_file = self._generate_tmp_file_path() + ".i"
|
self._tmp_preprocessed_file = self._generate_tmp_file_path() + ".i"
|
||||||
self._tmp_output_file = self._generate_tmp_file_path() + ".pvs"
|
self._tmp_output_file = self._generate_tmp_file_path() + ".pvs"
|
||||||
@ -208,7 +208,7 @@ class PvsStudioCheckTool(CheckToolBase): # pylint: disable=too-many-instance-at
|
|||||||
self._bad_input = True
|
self._bad_input = True
|
||||||
|
|
||||||
def clean_up(self):
|
def clean_up(self):
|
||||||
super(PvsStudioCheckTool, self).clean_up()
|
super().clean_up()
|
||||||
if os.path.isdir(self._tmp_dir):
|
if os.path.isdir(self._tmp_dir):
|
||||||
shutil.rmtree(self._tmp_dir)
|
shutil.rmtree(self._tmp_dir)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class Hexlify(DeviceMonitorFilter):
|
|||||||
NAME = "hexlify"
|
NAME = "hexlify"
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Hexlify, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._counter = 0
|
self._counter = 0
|
||||||
|
|
||||||
def rx(self, text):
|
def rx(self, text):
|
||||||
|
@ -23,7 +23,7 @@ class LogToFile(DeviceMonitorFilter):
|
|||||||
NAME = "log2file"
|
NAME = "log2file"
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(LogToFile, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._log_fp = None
|
self._log_fp = None
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
|
@ -19,7 +19,7 @@ class SendOnEnter(DeviceMonitorFilter):
|
|||||||
NAME = "send_on_enter"
|
NAME = "send_on_enter"
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(SendOnEnter, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._buffer = ""
|
self._buffer = ""
|
||||||
|
|
||||||
if self.options.get("eol") == "CR":
|
if self.options.get("eol") == "CR":
|
||||||
|
@ -21,7 +21,7 @@ class Timestamp(DeviceMonitorFilter):
|
|||||||
NAME = "time"
|
NAME = "time"
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(Timestamp, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._line_started = False
|
self._line_started = False
|
||||||
|
|
||||||
def rx(self, text):
|
def rx(self, text):
|
||||||
|
@ -26,7 +26,7 @@ class AsyncSession(requests.Session):
|
|||||||
async def request( # pylint: disable=signature-differs,invalid-overridden-method
|
async def request( # pylint: disable=signature-differs,invalid-overridden-method
|
||||||
self, *args, **kwargs
|
self, *args, **kwargs
|
||||||
):
|
):
|
||||||
func = super(AsyncSession, self).request
|
func = super().request
|
||||||
return await run_in_threadpool(func, *args, **kwargs)
|
return await run_in_threadpool(func, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class ProjectSyncAsyncCmd(AsyncCommandBase):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.psync = None
|
self.psync = None
|
||||||
self._upstream = None
|
self._upstream = None
|
||||||
super(ProjectSyncAsyncCmd, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
project_dir = os.path.join(
|
project_dir = os.path.join(
|
||||||
|
@ -23,7 +23,7 @@ class SSLContextFactory(ssl.ClientContextFactory):
|
|||||||
self.certificate_verified = False
|
self.certificate_verified = False
|
||||||
|
|
||||||
def getContext(self):
|
def getContext(self):
|
||||||
ctx = super(SSLContextFactory, self).getContext()
|
ctx = super().getContext()
|
||||||
ctx.set_verify(
|
ctx.set_verify(
|
||||||
SSL.VERIFY_PEER | SSL.VERIFY_FAIL_IF_NO_PEER_CERT, self.verifyHostname
|
SSL.VERIFY_PEER | SSL.VERIFY_FAIL_IF_NO_PEER_CERT, self.verifyHostname
|
||||||
)
|
)
|
||||||
|
@ -34,5 +34,5 @@ $INIT_BREAK
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(GenericDebugConfig, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.port = ":3333"
|
self.port = ":3333"
|
||||||
|
@ -38,11 +38,9 @@ $INIT_BREAK
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(JlinkDebugConfig, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.port = ":2331"
|
self.port = ":2331"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def server_ready_pattern(self):
|
def server_ready_pattern(self):
|
||||||
return super(JlinkDebugConfig, self).server_ready_pattern or (
|
return super().server_ready_pattern or ("Waiting for GDB connection")
|
||||||
"Waiting for GDB connection"
|
|
||||||
)
|
|
||||||
|
@ -32,5 +32,5 @@ $INIT_BREAK
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(MspdebugDebugConfig, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.port = ":2000"
|
self.port = ":2000"
|
||||||
|
@ -33,5 +33,5 @@ $INIT_BREAK
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(QemuDebugConfig, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.port = ":1234"
|
self.port = ":1234"
|
||||||
|
@ -35,11 +35,11 @@ monitor start
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(RenodeDebugConfig, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.port = ":3333"
|
self.port = ":3333"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def server_ready_pattern(self):
|
def server_ready_pattern(self):
|
||||||
return super(RenodeDebugConfig, self).server_ready_pattern or (
|
return super().server_ready_pattern or (
|
||||||
"GDB server with all CPUs started on port"
|
"GDB server with all CPUs started on port"
|
||||||
)
|
)
|
||||||
|
@ -27,7 +27,7 @@ from platformio.project.helpers import get_project_cache_dir
|
|||||||
|
|
||||||
class DebugClientProcess(DebugBaseProcess):
|
class DebugClientProcess(DebugBaseProcess):
|
||||||
def __init__(self, project_dir, debug_config):
|
def __init__(self, project_dir, debug_config):
|
||||||
super(DebugClientProcess, self).__init__()
|
super().__init__()
|
||||||
self.project_dir = project_dir
|
self.project_dir = project_dir
|
||||||
self.debug_config = debug_config
|
self.debug_config = debug_config
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ class DebugClientProcess(DebugBaseProcess):
|
|||||||
self.debug_config.port = await self._server_process.run()
|
self.debug_config.port = await self._server_process.run()
|
||||||
|
|
||||||
def connection_made(self, transport):
|
def connection_made(self, transport):
|
||||||
super(DebugClientProcess, self).connection_made(transport)
|
super().connection_made(transport)
|
||||||
self._lock_session(transport.get_pid())
|
self._lock_session(transport.get_pid())
|
||||||
# Disable SIGINT and allow GDB's Ctrl+C interrupt
|
# Disable SIGINT and allow GDB's Ctrl+C interrupt
|
||||||
signal.signal(signal.SIGINT, lambda *args, **kwargs: None)
|
signal.signal(signal.SIGINT, lambda *args, **kwargs: None)
|
||||||
@ -64,7 +64,7 @@ class DebugClientProcess(DebugBaseProcess):
|
|||||||
def process_exited(self):
|
def process_exited(self):
|
||||||
if self._server_process:
|
if self._server_process:
|
||||||
self._server_process.terminate()
|
self._server_process.terminate()
|
||||||
super(DebugClientProcess, self).process_exited()
|
super().process_exited()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._unlock_session()
|
self._unlock_session()
|
||||||
|
@ -29,12 +29,12 @@ class GDBClientProcess(DebugClientProcess):
|
|||||||
INIT_COMPLETED_BANNER = "PlatformIO: Initialization completed"
|
INIT_COMPLETED_BANNER = "PlatformIO: Initialization completed"
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(GDBClientProcess, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._target_is_running = False
|
self._target_is_running = False
|
||||||
self._errors_buffer = b""
|
self._errors_buffer = b""
|
||||||
|
|
||||||
async def run(self, extra_args): # pylint: disable=arguments-differ
|
async def run(self, extra_args): # pylint: disable=arguments-differ
|
||||||
await super(GDBClientProcess, self).run()
|
await super().run()
|
||||||
|
|
||||||
self.generate_init_script(os.path.join(self.working_dir, self.PIO_SRC_NAME))
|
self.generate_init_script(os.path.join(self.working_dir, self.PIO_SRC_NAME))
|
||||||
gdb_path = self.debug_config.client_executable_path or "gdb"
|
gdb_path = self.debug_config.client_executable_path or "gdb"
|
||||||
@ -109,7 +109,7 @@ class GDBClientProcess(DebugClientProcess):
|
|||||||
fp.write("\n".join(self.debug_config.reveal_patterns(commands)))
|
fp.write("\n".join(self.debug_config.reveal_patterns(commands)))
|
||||||
|
|
||||||
def stdin_data_received(self, data):
|
def stdin_data_received(self, data):
|
||||||
super(GDBClientProcess, self).stdin_data_received(data)
|
super().stdin_data_received(data)
|
||||||
if b"-exec-run" in data:
|
if b"-exec-run" in data:
|
||||||
if self._target_is_running:
|
if self._target_is_running:
|
||||||
token, _ = data.split(b"-", 1)
|
token, _ = data.split(b"-", 1)
|
||||||
@ -127,7 +127,7 @@ class GDBClientProcess(DebugClientProcess):
|
|||||||
self.transport.get_pipe_transport(0).write(data)
|
self.transport.get_pipe_transport(0).write(data)
|
||||||
|
|
||||||
def stdout_data_received(self, data):
|
def stdout_data_received(self, data):
|
||||||
super(GDBClientProcess, self).stdout_data_received(data)
|
super().stdout_data_received(data)
|
||||||
self._handle_error(data)
|
self._handle_error(data)
|
||||||
# go to init break automatically
|
# go to init break automatically
|
||||||
if self.INIT_COMPLETED_BANNER.encode() in data:
|
if self.INIT_COMPLETED_BANNER.encode() in data:
|
||||||
@ -170,7 +170,7 @@ class GDBClientProcess(DebugClientProcess):
|
|||||||
self._target_is_running = True
|
self._target_is_running = True
|
||||||
|
|
||||||
def stderr_data_received(self, data):
|
def stderr_data_received(self, data):
|
||||||
super(GDBClientProcess, self).stderr_data_received(data)
|
super().stderr_data_received(data)
|
||||||
self._handle_error(data)
|
self._handle_error(data)
|
||||||
|
|
||||||
def _handle_error(self, data):
|
def _handle_error(self, data):
|
||||||
|
@ -30,7 +30,7 @@ class DebugServerProcess(DebugBaseProcess):
|
|||||||
STD_BUFFER_SIZE = 1024
|
STD_BUFFER_SIZE = 1024
|
||||||
|
|
||||||
def __init__(self, debug_config):
|
def __init__(self, debug_config):
|
||||||
super(DebugServerProcess, self).__init__()
|
super().__init__()
|
||||||
self.debug_config = debug_config
|
self.debug_config = debug_config
|
||||||
self._ready = False
|
self._ready = False
|
||||||
self._std_buffer = {"out": b"", "err": b""}
|
self._std_buffer = {"out": b"", "err": b""}
|
||||||
@ -134,7 +134,7 @@ class DebugServerProcess(DebugBaseProcess):
|
|||||||
return self._ready
|
return self._ready
|
||||||
|
|
||||||
def stdout_data_received(self, data):
|
def stdout_data_received(self, data):
|
||||||
super(DebugServerProcess, self).stdout_data_received(
|
super().stdout_data_received(
|
||||||
escape_gdbmi_stream("@", data) if is_gdbmi_mode() else data
|
escape_gdbmi_stream("@", data) if is_gdbmi_mode() else data
|
||||||
)
|
)
|
||||||
self._std_buffer["out"] += data
|
self._std_buffer["out"] += data
|
||||||
@ -142,7 +142,7 @@ class DebugServerProcess(DebugBaseProcess):
|
|||||||
self._std_buffer["out"] = self._std_buffer["out"][-1 * self.STD_BUFFER_SIZE :]
|
self._std_buffer["out"] = self._std_buffer["out"][-1 * self.STD_BUFFER_SIZE :]
|
||||||
|
|
||||||
def stderr_data_received(self, data):
|
def stderr_data_received(self, data):
|
||||||
super(DebugServerProcess, self).stderr_data_received(data)
|
super().stderr_data_received(data)
|
||||||
self._std_buffer["err"] += data
|
self._std_buffer["err"] += data
|
||||||
self._check_ready_by_pattern(self._std_buffer["err"])
|
self._check_ready_by_pattern(self._std_buffer["err"])
|
||||||
self._std_buffer["err"] = self._std_buffer["err"][-1 * self.STD_BUFFER_SIZE :]
|
self._std_buffer["err"] = self._std_buffer["err"][-1 * self.STD_BUFFER_SIZE :]
|
||||||
|
@ -22,7 +22,7 @@ class PlatformioException(Exception):
|
|||||||
# pylint: disable=not-an-iterable
|
# pylint: disable=not-an-iterable
|
||||||
return self.MESSAGE.format(*self.args)
|
return self.MESSAGE.format(*self.args)
|
||||||
|
|
||||||
return super(PlatformioException, self).__str__()
|
return super().__str__()
|
||||||
|
|
||||||
|
|
||||||
class ReturnErrorCode(PlatformioException):
|
class ReturnErrorCode(PlatformioException):
|
||||||
|
@ -34,7 +34,7 @@ class ManifestParserError(ManifestException):
|
|||||||
|
|
||||||
class ManifestValidationError(ManifestException):
|
class ManifestValidationError(ManifestException):
|
||||||
def __init__(self, messages, data, valid_data):
|
def __init__(self, messages, data, valid_data):
|
||||||
super(ManifestValidationError, self).__init__()
|
super().__init__()
|
||||||
self.messages = messages
|
self.messages = messages
|
||||||
self.data = data
|
self.data = data
|
||||||
self.valid_data = valid_data
|
self.valid_data = valid_data
|
||||||
|
@ -64,7 +64,7 @@ class PackageManagerInstallMixin(object):
|
|||||||
# avoid circle dependencies
|
# avoid circle dependencies
|
||||||
if not self._INSTALL_HISTORY:
|
if not self._INSTALL_HISTORY:
|
||||||
self._INSTALL_HISTORY = {}
|
self._INSTALL_HISTORY = {}
|
||||||
if spec in self._INSTALL_HISTORY:
|
if not force and spec in self._INSTALL_HISTORY:
|
||||||
return self._INSTALL_HISTORY[spec]
|
return self._INSTALL_HISTORY[spec]
|
||||||
|
|
||||||
# check if package is already installed
|
# check if package is already installed
|
||||||
|
@ -24,7 +24,7 @@ from platformio.project.config import ProjectConfig
|
|||||||
|
|
||||||
class LibraryPackageManager(BasePackageManager): # pylint: disable=too-many-ancestors
|
class LibraryPackageManager(BasePackageManager): # pylint: disable=too-many-ancestors
|
||||||
def __init__(self, package_dir=None):
|
def __init__(self, package_dir=None):
|
||||||
super(LibraryPackageManager, self).__init__(
|
super().__init__(
|
||||||
PackageType.LIBRARY,
|
PackageType.LIBRARY,
|
||||||
package_dir
|
package_dir
|
||||||
or ProjectConfig.get_instance().get("platformio", "globallib_dir"),
|
or ProjectConfig.get_instance().get("platformio", "globallib_dir"),
|
||||||
@ -36,7 +36,7 @@ class LibraryPackageManager(BasePackageManager): # pylint: disable=too-many-anc
|
|||||||
|
|
||||||
def find_pkg_root(self, path, spec):
|
def find_pkg_root(self, path, spec):
|
||||||
try:
|
try:
|
||||||
return super(LibraryPackageManager, self).find_pkg_root(path, spec)
|
return super().find_pkg_root(path, spec)
|
||||||
except MissingPackageManifestError:
|
except MissingPackageManifestError:
|
||||||
pass
|
pass
|
||||||
assert isinstance(spec, PackageSpec)
|
assert isinstance(spec, PackageSpec)
|
||||||
@ -86,5 +86,5 @@ class LibraryPackageManager(BasePackageManager): # pylint: disable=too-many-anc
|
|||||||
if not any(not_builtin_conds):
|
if not any(not_builtin_conds):
|
||||||
not_builtin_conds.append(not is_builtin_lib(spec.name))
|
not_builtin_conds.append(not is_builtin_lib(spec.name))
|
||||||
if any(not_builtin_conds):
|
if any(not_builtin_conds):
|
||||||
return super(LibraryPackageManager, self).install_dependency(dependency)
|
return super().install_dependency(dependency)
|
||||||
return None
|
return None
|
||||||
|
@ -29,7 +29,7 @@ from platformio.project.config import ProjectConfig
|
|||||||
class PlatformPackageManager(BasePackageManager): # pylint: disable=too-many-ancestors
|
class PlatformPackageManager(BasePackageManager): # pylint: disable=too-many-ancestors
|
||||||
def __init__(self, package_dir=None):
|
def __init__(self, package_dir=None):
|
||||||
self.config = ProjectConfig.get_instance()
|
self.config = ProjectConfig.get_instance()
|
||||||
super(PlatformPackageManager, self).__init__(
|
super().__init__(
|
||||||
PackageType.PLATFORM,
|
PackageType.PLATFORM,
|
||||||
package_dir or self.config.get("platformio", "platforms_dir"),
|
package_dir or self.config.get("platformio", "platforms_dir"),
|
||||||
)
|
)
|
||||||
@ -47,16 +47,14 @@ class PlatformPackageManager(BasePackageManager): # pylint: disable=too-many-an
|
|||||||
project_targets=None,
|
project_targets=None,
|
||||||
):
|
):
|
||||||
already_installed = self.get_package(spec)
|
already_installed = self.get_package(spec)
|
||||||
pkg = super(PlatformPackageManager, self).install(
|
pkg = super().install(spec, force=force, skip_dependencies=True)
|
||||||
spec, force=force, skip_dependencies=True
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
p = PlatformFactory.new(pkg)
|
p = PlatformFactory.new(pkg)
|
||||||
# set logging level for underlying tool manager
|
# set logging level for underlying tool manager
|
||||||
p.pm.set_log_level(self.log.getEffectiveLevel())
|
p.pm.set_log_level(self.log.getEffectiveLevel())
|
||||||
p.ensure_engine_compatible()
|
p.ensure_engine_compatible()
|
||||||
except IncompatiblePlatform as e:
|
except IncompatiblePlatform as e:
|
||||||
super(PlatformPackageManager, self).uninstall(pkg, skip_dependencies=True)
|
super().uninstall(pkg, skip_dependencies=True)
|
||||||
raise e
|
raise e
|
||||||
if project_env:
|
if project_env:
|
||||||
p.configure_project_packages(project_env, project_targets)
|
p.configure_project_packages(project_env, project_targets)
|
||||||
@ -79,9 +77,7 @@ class PlatformPackageManager(BasePackageManager): # pylint: disable=too-many-an
|
|||||||
p.configure_project_packages(project_env)
|
p.configure_project_packages(project_env)
|
||||||
if not skip_dependencies:
|
if not skip_dependencies:
|
||||||
p.uninstall_packages()
|
p.uninstall_packages()
|
||||||
assert super(PlatformPackageManager, self).uninstall(
|
assert super().uninstall(pkg, skip_dependencies=True)
|
||||||
pkg, skip_dependencies=True
|
|
||||||
)
|
|
||||||
p.on_uninstalled()
|
p.on_uninstalled()
|
||||||
return pkg
|
return pkg
|
||||||
|
|
||||||
@ -95,7 +91,7 @@ class PlatformPackageManager(BasePackageManager): # pylint: disable=too-many-an
|
|||||||
pkg = self.get_package(from_spec)
|
pkg = self.get_package(from_spec)
|
||||||
if not pkg or not pkg.metadata:
|
if not pkg or not pkg.metadata:
|
||||||
raise UnknownPackageError(from_spec)
|
raise UnknownPackageError(from_spec)
|
||||||
pkg = super(PlatformPackageManager, self).update(
|
pkg = super().update(
|
||||||
from_spec,
|
from_spec,
|
||||||
to_spec,
|
to_spec,
|
||||||
)
|
)
|
||||||
|
@ -19,9 +19,11 @@ from platformio.project.config import ProjectConfig
|
|||||||
|
|
||||||
class ToolPackageManager(BasePackageManager): # pylint: disable=too-many-ancestors
|
class ToolPackageManager(BasePackageManager): # pylint: disable=too-many-ancestors
|
||||||
def __init__(self, package_dir=None):
|
def __init__(self, package_dir=None):
|
||||||
if not package_dir:
|
super().__init__(
|
||||||
package_dir = ProjectConfig.get_instance().get("platformio", "packages_dir")
|
PackageType.TOOL,
|
||||||
super(ToolPackageManager, self).__init__(PackageType.TOOL, package_dir)
|
package_dir
|
||||||
|
or ProjectConfig.get_instance().get("platformio", "packages_dir"),
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def manifest_names(self):
|
def manifest_names(self):
|
||||||
|
@ -59,9 +59,7 @@ class StrictListField(fields.List):
|
|||||||
self, value, attr, data, **kwargs
|
self, value, attr, data, **kwargs
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
return super(StrictListField, self)._deserialize(
|
return super()._deserialize(value, attr, data, **kwargs)
|
||||||
value, attr, data, **kwargs
|
|
||||||
)
|
|
||||||
except ValidationError as exc:
|
except ValidationError as exc:
|
||||||
if exc.data:
|
if exc.data:
|
||||||
exc.data = [item for item in exc.data if item is not None]
|
exc.data = [item for item in exc.data if item is not None]
|
||||||
|
@ -91,7 +91,7 @@ class PackageOutdatedResult(object):
|
|||||||
and not isinstance(value, semantic_version.Version)
|
and not isinstance(value, semantic_version.Version)
|
||||||
):
|
):
|
||||||
value = cast_version_to_semver(str(value))
|
value = cast_version_to_semver(str(value))
|
||||||
return super(PackageOutdatedResult, self).__setattr__(name, value)
|
return super().__setattr__(name, value)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def update_increment_type(self):
|
def update_increment_type(self):
|
||||||
|
@ -57,9 +57,7 @@ class BaseArchiver(object):
|
|||||||
|
|
||||||
class TARArchiver(BaseArchiver):
|
class TARArchiver(BaseArchiver):
|
||||||
def __init__(self, archpath):
|
def __init__(self, archpath):
|
||||||
super(TARArchiver, self).__init__(
|
super().__init__(tarfile_open(archpath)) # pylint: disable=consider-using-with
|
||||||
tarfile_open(archpath) # pylint: disable=consider-using-with
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_items(self):
|
def get_items(self):
|
||||||
return self._afo.getmembers()
|
return self._afo.getmembers()
|
||||||
@ -90,7 +88,7 @@ class TARArchiver(BaseArchiver):
|
|||||||
self.is_link(item) and self.is_bad_link(item, dest_dir),
|
self.is_link(item) and self.is_bad_link(item, dest_dir),
|
||||||
]
|
]
|
||||||
if not any(bad_conds):
|
if not any(bad_conds):
|
||||||
super(TARArchiver, self).extract_item(item, dest_dir)
|
super().extract_item(item, dest_dir)
|
||||||
else:
|
else:
|
||||||
click.secho(
|
click.secho(
|
||||||
"Blocked insecure item `%s` from TAR archive" % item.name,
|
"Blocked insecure item `%s` from TAR archive" % item.name,
|
||||||
@ -101,9 +99,7 @@ class TARArchiver(BaseArchiver):
|
|||||||
|
|
||||||
class ZIPArchiver(BaseArchiver):
|
class ZIPArchiver(BaseArchiver):
|
||||||
def __init__(self, archpath):
|
def __init__(self, archpath):
|
||||||
super(ZIPArchiver, self).__init__(
|
super().__init__(ZipFile(archpath)) # pylint: disable=consider-using-with
|
||||||
ZipFile(archpath) # pylint: disable=consider-using-with
|
|
||||||
)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def preserve_permissions(item, dest_dir):
|
def preserve_permissions(item, dest_dir):
|
||||||
|
@ -131,7 +131,7 @@ class GitClient(VCSClientBase):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.configure()
|
self.configure()
|
||||||
super(GitClient, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def configure(cls):
|
def configure(cls):
|
||||||
|
@ -62,7 +62,7 @@ class BuildAsyncPipe(AsyncPipeBase):
|
|||||||
def __init__(self, line_callback, data_callback):
|
def __init__(self, line_callback, data_callback):
|
||||||
self.line_callback = line_callback
|
self.line_callback = line_callback
|
||||||
self.data_callback = data_callback
|
self.data_callback = data_callback
|
||||||
super(BuildAsyncPipe, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
def do_reading(self):
|
def do_reading(self):
|
||||||
line = ""
|
line = ""
|
||||||
@ -95,7 +95,7 @@ class BuildAsyncPipe(AsyncPipeBase):
|
|||||||
class LineBufferedAsyncPipe(AsyncPipeBase):
|
class LineBufferedAsyncPipe(AsyncPipeBase):
|
||||||
def __init__(self, line_callback):
|
def __init__(self, line_callback):
|
||||||
self.line_callback = line_callback
|
self.line_callback = line_callback
|
||||||
super(LineBufferedAsyncPipe, self).__init__()
|
super().__init__()
|
||||||
|
|
||||||
def do_reading(self):
|
def do_reading(self):
|
||||||
for line in iter(self._pipe_reader.readline, ""):
|
for line in iter(self._pipe_reader.readline, ""):
|
||||||
|
@ -64,7 +64,7 @@ class MeasurementProtocol(TelemetryBase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(MeasurementProtocol, self).__init__()
|
super().__init__()
|
||||||
self["v"] = 1
|
self["v"] = 1
|
||||||
self["tid"] = self.TID
|
self["tid"] = self.TID
|
||||||
self["cid"] = app.get_cid()
|
self["cid"] = app.get_cid()
|
||||||
@ -82,12 +82,12 @@ class MeasurementProtocol(TelemetryBase):
|
|||||||
def __getitem__(self, name):
|
def __getitem__(self, name):
|
||||||
if name in self.PARAMS_MAP:
|
if name in self.PARAMS_MAP:
|
||||||
name = self.PARAMS_MAP[name]
|
name = self.PARAMS_MAP[name]
|
||||||
return super(MeasurementProtocol, self).__getitem__(name)
|
return super().__getitem__(name)
|
||||||
|
|
||||||
def __setitem__(self, name, value):
|
def __setitem__(self, name, value):
|
||||||
if name in self.PARAMS_MAP:
|
if name in self.PARAMS_MAP:
|
||||||
name = self.PARAMS_MAP[name]
|
name = self.PARAMS_MAP[name]
|
||||||
super(MeasurementProtocol, self).__setitem__(name, value)
|
super().__setitem__(name, value)
|
||||||
|
|
||||||
def _prefill_appinfo(self):
|
def _prefill_appinfo(self):
|
||||||
self["av"] = __version__
|
self["av"] = __version__
|
||||||
|
Reference in New Issue
Block a user