Configure a custom pattern to determine when debugging server is started with a new debug_server_ready_pattern option

This commit is contained in:
Ivan Kravets
2021-03-19 12:30:16 +02:00
parent a78db17784
commit b0c3e22a52
6 changed files with 23 additions and 5 deletions

View File

@@ -15,6 +15,7 @@ PlatformIO Core 5
- Boosted `PlatformIO Debugging <https://docs.platformio.org/page/plus/debugging.html>`__ performance thanks to migrating the codebase to the pure Python 3 Asynchronous I/O stack - Boosted `PlatformIO Debugging <https://docs.platformio.org/page/plus/debugging.html>`__ performance thanks to migrating the codebase to the pure Python 3 Asynchronous I/O stack
- Support debugging on Windows using Windows CMD/CLI (`pio debug <https://docs.platformio.org/page/core/userguide/cmd_debug.html>`__) (`issue #3793 <https://github.com/platformio/platformio-core/issues/3793>`_) - Support debugging on Windows using Windows CMD/CLI (`pio debug <https://docs.platformio.org/page/core/userguide/cmd_debug.html>`__) (`issue #3793 <https://github.com/platformio/platformio-core/issues/3793>`_)
- Configure a custom pattern to determine when debugging server is started with a new `debug_server_ready_pattern <https://docs.platformio.org/page/projectconf/section_env_debug.html#debug-server-ready-pattern>`__ option
5.1.1 (2021-03-17) 5.1.1 (2021-03-17)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

2
docs

Submodule docs updated: 0487c24f93...b76e3d53bb

View File

@@ -22,7 +22,7 @@ import click
from platformio import __version__, exception from platformio import __version__, exception
from platformio.commands import PlatformioCLI from platformio.commands import PlatformioCLI
from platformio.compat import IS_CYGWIN, PY2, ensure_python3 from platformio.compat import IS_CYGWIN, ensure_python3
try: try:
import click_completion # pylint: disable=import-error import click_completion # pylint: disable=import-error
@@ -118,7 +118,7 @@ def main(argv=None):
exit_code = int(e.code) exit_code = int(e.code)
except Exception as e: # pylint: disable=broad-except except Exception as e: # pylint: disable=broad-except
if not isinstance(e, exception.ReturnErrorCode): if not isinstance(e, exception.ReturnErrorCode):
if not PY2: if sys.version_info.major != 2:
from platformio import maintenance from platformio import maintenance
maintenance.on_platformio_exception(e) maintenance.on_platformio_exception(e)

View File

@@ -130,7 +130,9 @@ class DebugConfigBase: # pylint: disable=too-many-instance-attributes
@property @property
def server_ready_pattern(self): def server_ready_pattern(self):
return (self.server or {}).get("ready_pattern") return self.env_options.get(
"debug_server_ready_pattern", (self.server or {}).get("ready_pattern")
)
def _load_build_data(self): def _load_build_data(self):
data = load_project_ide_data(self.project_config.path, self.env_name) data = load_project_ide_data(self.project_config.path, self.env_name)

View File

@@ -14,6 +14,7 @@
import asyncio import asyncio
import os import os
import re
import time import time
from platformio import fs from platformio import fs
@@ -120,7 +121,13 @@ class DebugServerProcess(DebugBaseProcess):
return self._ready return self._ready
ready_pattern = self.debug_config.server_ready_pattern ready_pattern = self.debug_config.server_ready_pattern
if ready_pattern: if ready_pattern:
self._ready = ready_pattern.encode() in data if ready_pattern.startswith("^"):
self._ready = re.match(
ready_pattern,
data.decode("utf-8", "ignore"),
)
else:
self._ready = ready_pattern.encode() in data
return self._ready return self._ready
def stdout_data_received(self, data): def stdout_data_received(self, data):

View File

@@ -695,6 +695,14 @@ ProjectOptions = OrderedDict(
), ),
type=click.Path(exists=True, file_okay=True, dir_okay=False), type=click.Path(exists=True, file_okay=True, dir_okay=False),
), ),
ConfigEnvOption(
group="debug",
name="debug_server_ready_pattern",
description=(
"A pattern to determine when debugging server is ready "
"for an incoming connection"
),
),
# Advanced # Advanced
ConfigEnvOption( ConfigEnvOption(
group="advanced", group="advanced",