micropython-stubber 1.20.5__py3-none-any.whl → 1.23.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {micropython_stubber-1.20.5.dist-info → micropython_stubber-1.23.0.dist-info}/LICENSE +30 -30
- {micropython_stubber-1.20.5.dist-info → micropython_stubber-1.23.0.dist-info}/METADATA +1 -1
- micropython_stubber-1.23.0.dist-info/RECORD +159 -0
- mpflash/README.md +184 -184
- mpflash/libusb_flash.ipynb +203 -203
- mpflash/mpflash/add_firmware.py +98 -98
- mpflash/mpflash/ask_input.py +236 -236
- mpflash/mpflash/bootloader/__init__.py +37 -36
- mpflash/mpflash/bootloader/manual.py +102 -102
- mpflash/mpflash/bootloader/micropython.py +10 -10
- mpflash/mpflash/bootloader/touch1200.py +45 -45
- mpflash/mpflash/cli_download.py +129 -129
- mpflash/mpflash/cli_flash.py +219 -219
- mpflash/mpflash/cli_group.py +98 -98
- mpflash/mpflash/cli_list.py +81 -81
- mpflash/mpflash/cli_main.py +41 -41
- mpflash/mpflash/common.py +164 -164
- mpflash/mpflash/config.py +43 -47
- mpflash/mpflash/connected.py +74 -74
- mpflash/mpflash/download.py +360 -360
- mpflash/mpflash/downloaded.py +130 -129
- mpflash/mpflash/errors.py +9 -9
- mpflash/mpflash/flash.py +55 -52
- mpflash/mpflash/flash_esp.py +59 -59
- mpflash/mpflash/flash_stm32.py +18 -24
- mpflash/mpflash/flash_stm32_cube.py +111 -111
- mpflash/mpflash/flash_stm32_dfu.py +104 -101
- mpflash/mpflash/flash_uf2.py +89 -67
- mpflash/mpflash/flash_uf2_boardid.py +15 -15
- mpflash/mpflash/flash_uf2_linux.py +129 -123
- mpflash/mpflash/flash_uf2_macos.py +37 -34
- mpflash/mpflash/flash_uf2_windows.py +38 -34
- mpflash/mpflash/list.py +89 -89
- mpflash/mpflash/logger.py +41 -41
- mpflash/mpflash/mpboard_id/__init__.py +93 -93
- mpflash/mpflash/mpboard_id/add_boards.py +255 -255
- mpflash/mpflash/mpboard_id/board.py +37 -37
- mpflash/mpflash/mpboard_id/board_id.py +86 -86
- mpflash/mpflash/mpboard_id/store.py +43 -43
- mpflash/mpflash/mpremoteboard/__init__.py +226 -221
- mpflash/mpflash/mpremoteboard/mpy_fw_info.py +141 -141
- mpflash/mpflash/mpremoteboard/runner.py +140 -140
- mpflash/mpflash/uf2disk.py +12 -12
- mpflash/mpflash/vendor/basicgit.py +288 -288
- mpflash/mpflash/vendor/click_aliases.py +91 -91
- mpflash/mpflash/vendor/dfu.py +165 -165
- mpflash/mpflash/vendor/pydfu.py +605 -605
- mpflash/mpflash/vendor/readme.md +2 -2
- mpflash/mpflash/vendor/versions.py +119 -117
- mpflash/mpflash/worklist.py +171 -170
- mpflash/poetry.lock +1588 -1588
- mpflash/pyproject.toml +64 -60
- mpflash/stm32_udev_rules.md +62 -62
- stubber/__init__.py +3 -3
- stubber/basicgit.py +294 -288
- stubber/board/board_info.csv +193 -193
- stubber/board/boot.py +34 -34
- stubber/board/createstubs.py +986 -986
- stubber/board/createstubs_db.py +825 -825
- stubber/board/createstubs_db_min.py +331 -331
- stubber/board/createstubs_db_mpy.mpy +0 -0
- stubber/board/createstubs_lvgl.py +741 -741
- stubber/board/createstubs_lvgl_min.py +741 -741
- stubber/board/createstubs_mem.py +766 -766
- stubber/board/createstubs_mem_min.py +306 -306
- stubber/board/createstubs_mem_mpy.mpy +0 -0
- stubber/board/createstubs_min.py +294 -294
- stubber/board/createstubs_mpy.mpy +0 -0
- stubber/board/fw_info.py +141 -141
- stubber/board/info.py +183 -183
- stubber/board/main.py +19 -19
- stubber/board/modulelist.txt +247 -247
- stubber/board/pyrightconfig.json +34 -34
- stubber/bulk/mcu_stubber.py +454 -454
- stubber/codemod/_partials/__init__.py +48 -48
- stubber/codemod/_partials/db_main.py +147 -147
- stubber/codemod/_partials/lvgl_main.py +77 -77
- stubber/codemod/_partials/modules_reader.py +80 -80
- stubber/codemod/add_comment.py +53 -53
- stubber/codemod/add_method.py +65 -65
- stubber/codemod/board.py +317 -317
- stubber/codemod/enrich.py +145 -145
- stubber/codemod/merge_docstub.py +284 -284
- stubber/codemod/modify_list.py +54 -54
- stubber/codemod/utils.py +57 -57
- stubber/commands/build_cmd.py +94 -94
- stubber/commands/cli.py +55 -51
- stubber/commands/clone_cmd.py +77 -66
- stubber/commands/config_cmd.py +29 -29
- stubber/commands/enrich_folder_cmd.py +71 -70
- stubber/commands/get_core_cmd.py +71 -69
- stubber/commands/get_docstubs_cmd.py +89 -87
- stubber/commands/get_frozen_cmd.py +114 -112
- stubber/commands/get_mcu_cmd.py +61 -56
- stubber/commands/merge_cmd.py +67 -66
- stubber/commands/publish_cmd.py +119 -119
- stubber/commands/stub_cmd.py +31 -30
- stubber/commands/switch_cmd.py +62 -54
- stubber/commands/variants_cmd.py +49 -48
- stubber/cst_transformer.py +178 -178
- stubber/data/board_info.csv +193 -193
- stubber/data/board_info.json +1729 -1729
- stubber/data/micropython_tags.csv +15 -15
- stubber/data/requirements-core-micropython.txt +38 -38
- stubber/data/requirements-core-pycopy.txt +39 -39
- stubber/downloader.py +36 -36
- stubber/freeze/common.py +68 -68
- stubber/freeze/freeze_folder.py +69 -69
- stubber/freeze/freeze_manifest_2.py +113 -113
- stubber/freeze/get_frozen.py +127 -127
- stubber/get_cpython.py +101 -101
- stubber/get_lobo.py +59 -59
- stubber/minify.py +418 -418
- stubber/publish/bump.py +86 -86
- stubber/publish/candidates.py +262 -262
- stubber/publish/database.py +18 -18
- stubber/publish/defaults.py +45 -45
- stubber/publish/enums.py +24 -24
- stubber/publish/helpers.py +29 -29
- stubber/publish/merge_docstubs.py +130 -130
- stubber/publish/missing_class_methods.py +49 -49
- stubber/publish/package.py +146 -146
- stubber/publish/pathnames.py +51 -51
- stubber/publish/publish.py +120 -120
- stubber/publish/pypi.py +38 -38
- stubber/publish/stubpackage.py +1029 -1029
- stubber/rst/__init__.py +9 -9
- stubber/rst/classsort.py +77 -77
- stubber/rst/lookup.py +530 -530
- stubber/rst/output_dict.py +401 -401
- stubber/rst/reader.py +822 -822
- stubber/rst/report_return.py +69 -69
- stubber/rst/rst_utils.py +540 -540
- stubber/stubber.py +38 -38
- stubber/stubs_from_docs.py +90 -90
- stubber/tools/manifestfile.py +655 -610
- stubber/tools/readme.md +7 -6
- stubber/update_fallback.py +117 -117
- stubber/update_module_list.py +123 -123
- stubber/utils/__init__.py +5 -5
- stubber/utils/config.py +127 -127
- stubber/utils/makeversionhdr.py +54 -54
- stubber/utils/manifest.py +92 -92
- stubber/utils/post.py +79 -79
- stubber/utils/repos.py +157 -154
- stubber/utils/stubmaker.py +139 -139
- stubber/utils/typed_config_toml.py +77 -77
- stubber/utils/versions.py +128 -120
- stubber/variants.py +106 -106
- micropython_stubber-1.20.5.dist-info/RECORD +0 -159
- {micropython_stubber-1.20.5.dist-info → micropython_stubber-1.23.0.dist-info}/WHEEL +0 -0
- {micropython_stubber-1.20.5.dist-info → micropython_stubber-1.23.0.dist-info}/entry_points.txt +0 -0
@@ -1,221 +1,226 @@
|
|
1
|
-
"""
|
2
|
-
Module to run mpremote commands, and retry on failure or timeout
|
3
|
-
"""
|
4
|
-
|
5
|
-
import sys
|
6
|
-
import time
|
7
|
-
from pathlib import Path
|
8
|
-
from typing import List, Optional, Union
|
9
|
-
|
10
|
-
import serial.tools.list_ports
|
11
|
-
from loguru import logger as log
|
12
|
-
from rich.progress import track
|
13
|
-
from tenacity import retry, stop_after_attempt, wait_fixed
|
14
|
-
|
15
|
-
from mpflash.errors import MPFlashError
|
16
|
-
from mpflash.mpboard_id.board_id import find_board_id_by_description
|
17
|
-
from mpflash.mpremoteboard.runner import run
|
18
|
-
|
19
|
-
###############################################################################################
|
20
|
-
# TODO : make this a bit nicer
|
21
|
-
HERE = Path(__file__).parent
|
22
|
-
|
23
|
-
OK = 0
|
24
|
-
ERROR = -1
|
25
|
-
RETRIES = 3
|
26
|
-
###############################################################################################
|
27
|
-
|
28
|
-
|
29
|
-
class MPRemoteBoard:
|
30
|
-
"""Class to run mpremote commands"""
|
31
|
-
|
32
|
-
def __init__(self, serialport: str = "", update: bool = False):
|
33
|
-
"""
|
34
|
-
Initialize MPRemoteBoard object.
|
35
|
-
|
36
|
-
Parameters:
|
37
|
-
- serialport (str): The serial port to connect to. Default is an empty string.
|
38
|
-
- update (bool): Whether to update the MCU information. Default is False.
|
39
|
-
"""
|
40
|
-
self.serialport = serialport
|
41
|
-
self.firmware = {}
|
42
|
-
|
43
|
-
self.connected = False
|
44
|
-
self.path: Optional[Path] = None
|
45
|
-
self.family = "unknown"
|
46
|
-
self.description = ""
|
47
|
-
self.version = ""
|
48
|
-
self.port = ""
|
49
|
-
self.board = ""
|
50
|
-
self.cpu = ""
|
51
|
-
self.arch = ""
|
52
|
-
self.mpy = ""
|
53
|
-
self.build = ""
|
54
|
-
if update:
|
55
|
-
self.get_mcu_info()
|
56
|
-
|
57
|
-
def __str__(self):
|
58
|
-
"""
|
59
|
-
Return a string representation of the MPRemoteBoard object.
|
60
|
-
|
61
|
-
Returns:
|
62
|
-
- str: The string representation of the object.
|
63
|
-
"""
|
64
|
-
return f"MPRemoteBoard({self.serialport}, {self.family} {self.port}, {self.board}, {self.version})"
|
65
|
-
|
66
|
-
@staticmethod
|
67
|
-
def connected_boards(bluetooth: bool = False, description: bool = False) -> List[str]:
|
68
|
-
# TODO: rename to connected_comports
|
69
|
-
"""
|
70
|
-
Get a list of connected comports.
|
71
|
-
|
72
|
-
Parameters:
|
73
|
-
- bluetooth (bool): Whether to include Bluetooth ports. Default is False.
|
74
|
-
|
75
|
-
Returns:
|
76
|
-
- List[str]: A list of connected board ports.
|
77
|
-
"""
|
78
|
-
comports = serial.tools.list_ports.comports()
|
79
|
-
|
80
|
-
if not bluetooth:
|
81
|
-
# filter out bluetooth ports
|
82
|
-
comports = [p for p in comports if "bluetooth" not in p.description.lower()]
|
83
|
-
comports = [p for p in comports if "BTHENUM" not in p.hwid]
|
84
|
-
if description:
|
85
|
-
output = [
|
86
|
-
f"{p.device} {(p.manufacturer + ' ') if p.manufacturer and not p.description.startswith(p.manufacturer) else ''}{p.description}"
|
87
|
-
for p in comports
|
88
|
-
]
|
89
|
-
else:
|
90
|
-
output = [p.device for p in comports]
|
91
|
-
|
92
|
-
if sys.platform == "win32":
|
93
|
-
# Windows sort of comports by number - but fallback to device name
|
94
|
-
return sorted(
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
self.
|
123
|
-
self.
|
124
|
-
self.
|
125
|
-
self.
|
126
|
-
self.
|
127
|
-
self.
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
self.
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
if
|
145
|
-
|
146
|
-
|
147
|
-
return
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
- bool:
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
time.
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
1
|
+
"""
|
2
|
+
Module to run mpremote commands, and retry on failure or timeout
|
3
|
+
"""
|
4
|
+
|
5
|
+
import sys
|
6
|
+
import time
|
7
|
+
from pathlib import Path
|
8
|
+
from typing import List, Optional, Union
|
9
|
+
|
10
|
+
import serial.tools.list_ports
|
11
|
+
from loguru import logger as log
|
12
|
+
from rich.progress import track
|
13
|
+
from tenacity import retry, stop_after_attempt, wait_fixed
|
14
|
+
|
15
|
+
from mpflash.errors import MPFlashError
|
16
|
+
from mpflash.mpboard_id.board_id import find_board_id_by_description
|
17
|
+
from mpflash.mpremoteboard.runner import run
|
18
|
+
|
19
|
+
###############################################################################################
|
20
|
+
# TODO : make this a bit nicer
|
21
|
+
HERE = Path(__file__).parent
|
22
|
+
|
23
|
+
OK = 0
|
24
|
+
ERROR = -1
|
25
|
+
RETRIES = 3
|
26
|
+
###############################################################################################
|
27
|
+
|
28
|
+
|
29
|
+
class MPRemoteBoard:
|
30
|
+
"""Class to run mpremote commands"""
|
31
|
+
|
32
|
+
def __init__(self, serialport: str = "", update: bool = False):
|
33
|
+
"""
|
34
|
+
Initialize MPRemoteBoard object.
|
35
|
+
|
36
|
+
Parameters:
|
37
|
+
- serialport (str): The serial port to connect to. Default is an empty string.
|
38
|
+
- update (bool): Whether to update the MCU information. Default is False.
|
39
|
+
"""
|
40
|
+
self.serialport = serialport
|
41
|
+
self.firmware = {}
|
42
|
+
|
43
|
+
self.connected = False
|
44
|
+
self.path: Optional[Path] = None
|
45
|
+
self.family = "unknown"
|
46
|
+
self.description = ""
|
47
|
+
self.version = ""
|
48
|
+
self.port = ""
|
49
|
+
self.board = ""
|
50
|
+
self.cpu = ""
|
51
|
+
self.arch = ""
|
52
|
+
self.mpy = ""
|
53
|
+
self.build = ""
|
54
|
+
if update:
|
55
|
+
self.get_mcu_info()
|
56
|
+
|
57
|
+
def __str__(self):
|
58
|
+
"""
|
59
|
+
Return a string representation of the MPRemoteBoard object.
|
60
|
+
|
61
|
+
Returns:
|
62
|
+
- str: The string representation of the object.
|
63
|
+
"""
|
64
|
+
return f"MPRemoteBoard({self.serialport}, {self.family} {self.port}, {self.board}, {self.version})"
|
65
|
+
|
66
|
+
@staticmethod
|
67
|
+
def connected_boards(bluetooth: bool = False, description: bool = False) -> List[str]:
|
68
|
+
# TODO: rename to connected_comports
|
69
|
+
"""
|
70
|
+
Get a list of connected comports.
|
71
|
+
|
72
|
+
Parameters:
|
73
|
+
- bluetooth (bool): Whether to include Bluetooth ports. Default is False.
|
74
|
+
|
75
|
+
Returns:
|
76
|
+
- List[str]: A list of connected board ports.
|
77
|
+
"""
|
78
|
+
comports = serial.tools.list_ports.comports()
|
79
|
+
|
80
|
+
if not bluetooth:
|
81
|
+
# filter out bluetooth ports
|
82
|
+
comports = [p for p in comports if "bluetooth" not in p.description.lower()]
|
83
|
+
comports = [p for p in comports if "BTHENUM" not in p.hwid]
|
84
|
+
if description:
|
85
|
+
output = [
|
86
|
+
f"{p.device} {(p.manufacturer + ' ') if p.manufacturer and not p.description.startswith(p.manufacturer) else ''}{p.description}"
|
87
|
+
for p in comports
|
88
|
+
]
|
89
|
+
else:
|
90
|
+
output = [p.device for p in comports]
|
91
|
+
|
92
|
+
if sys.platform == "win32":
|
93
|
+
# Windows sort of comports by number - but fallback to device name
|
94
|
+
return sorted(
|
95
|
+
output, key=lambda x: int(x.split()[0][3:]) if x.split()[0][3:].isdigit() else x
|
96
|
+
)
|
97
|
+
# sort by device name
|
98
|
+
return sorted(output)
|
99
|
+
|
100
|
+
@retry(stop=stop_after_attempt(RETRIES), wait=wait_fixed(1), reraise=True) # type: ignore ## retry_error_cls=ConnectionError,
|
101
|
+
def get_mcu_info(self, timeout: int = 2):
|
102
|
+
"""
|
103
|
+
Get MCU information from the connected board.
|
104
|
+
|
105
|
+
Parameters:
|
106
|
+
- timeout (int): The timeout value in seconds. Default is 2.
|
107
|
+
|
108
|
+
Raises:
|
109
|
+
- ConnectionError: If failed to get mcu_info for the serial port.
|
110
|
+
"""
|
111
|
+
rc, result = self.run_command(
|
112
|
+
["run", str(HERE / "mpy_fw_info.py")],
|
113
|
+
no_info=True,
|
114
|
+
timeout=timeout,
|
115
|
+
)
|
116
|
+
if rc != OK:
|
117
|
+
raise ConnectionError(f"Failed to get mcu_info for {self.serialport}")
|
118
|
+
# Ok we have the info, now parse it
|
119
|
+
s = result[0].strip()
|
120
|
+
if s.startswith("{") and s.endswith("}"):
|
121
|
+
info = eval(s)
|
122
|
+
self.family = info["family"]
|
123
|
+
self.version = info["version"]
|
124
|
+
self.build = info["build"]
|
125
|
+
self.port = info["port"]
|
126
|
+
self.cpu = info["cpu"]
|
127
|
+
self.arch = info["arch"]
|
128
|
+
self.mpy = info["mpy"]
|
129
|
+
self.description = descr = info["board"]
|
130
|
+
pos = descr.rfind(" with")
|
131
|
+
short_descr = descr[:pos].strip() if pos != -1 else ""
|
132
|
+
if board_name := find_board_id_by_description(
|
133
|
+
descr, short_descr, version=self.version
|
134
|
+
):
|
135
|
+
self.board = board_name
|
136
|
+
else:
|
137
|
+
self.board = "UNKNOWN_BOARD"
|
138
|
+
|
139
|
+
def disconnect(self) -> bool:
|
140
|
+
"""
|
141
|
+
Disconnect from a board.
|
142
|
+
|
143
|
+
Returns:
|
144
|
+
- bool: True if successfully disconnected, False otherwise.
|
145
|
+
"""
|
146
|
+
if not self.connected:
|
147
|
+
return True
|
148
|
+
if not self.serialport:
|
149
|
+
log.error("No port connected")
|
150
|
+
self.connected = False
|
151
|
+
return False
|
152
|
+
log.info(f"Disconnecting from {self.serialport}")
|
153
|
+
result = self.run_command(["disconnect"])[0] == OK
|
154
|
+
self.connected = False
|
155
|
+
return result
|
156
|
+
|
157
|
+
@retry(stop=stop_after_attempt(RETRIES), wait=wait_fixed(2), reraise=True)
|
158
|
+
def run_command(
|
159
|
+
self,
|
160
|
+
cmd: Union[str, List[str]],
|
161
|
+
*,
|
162
|
+
log_errors: bool = True,
|
163
|
+
no_info: bool = False,
|
164
|
+
timeout: int = 60,
|
165
|
+
**kwargs,
|
166
|
+
):
|
167
|
+
"""
|
168
|
+
Run mpremote with the given command.
|
169
|
+
|
170
|
+
Parameters:
|
171
|
+
- cmd (Union[str, List[str]]): The command to run, either a string or a list of strings.
|
172
|
+
- log_errors (bool): Whether to log errors. Default is True.
|
173
|
+
- no_info (bool): Whether to skip printing info. Default is False.
|
174
|
+
- timeout (int): The timeout value in seconds. Default is 60.
|
175
|
+
|
176
|
+
Returns:
|
177
|
+
- bool: True if the command succeeded, False otherwise.
|
178
|
+
"""
|
179
|
+
if isinstance(cmd, str):
|
180
|
+
cmd = cmd.split(" ")
|
181
|
+
prefix = [sys.executable, "-m", "mpremote"]
|
182
|
+
if self.serialport:
|
183
|
+
prefix += ["connect", self.serialport]
|
184
|
+
# if connected add resume to keep state between commands
|
185
|
+
if self.connected:
|
186
|
+
prefix += ["resume"]
|
187
|
+
cmd = prefix + cmd
|
188
|
+
log.debug(" ".join(cmd))
|
189
|
+
result = run(cmd, timeout, log_errors, no_info, **kwargs)
|
190
|
+
self.connected = result[0] == OK
|
191
|
+
return result
|
192
|
+
|
193
|
+
@retry(stop=stop_after_attempt(RETRIES), wait=wait_fixed(1))
|
194
|
+
def mip_install(self, name: str) -> bool:
|
195
|
+
"""
|
196
|
+
Install a micropython package.
|
197
|
+
|
198
|
+
Parameters:
|
199
|
+
- name (str): The name of the package to install.
|
200
|
+
|
201
|
+
Returns:
|
202
|
+
- bool: True if the installation succeeded, False otherwise.
|
203
|
+
"""
|
204
|
+
# install createstubs to the board
|
205
|
+
cmd = ["mip", "install", name]
|
206
|
+
result = self.run_command(cmd)[0] == OK
|
207
|
+
self.connected = True
|
208
|
+
return result
|
209
|
+
|
210
|
+
def wait_for_restart(self, timeout: int = 10):
|
211
|
+
"""wait for the board to restart"""
|
212
|
+
for _ in track(
|
213
|
+
range(timeout),
|
214
|
+
description="Waiting for the board to restart",
|
215
|
+
transient=True,
|
216
|
+
get_time=lambda: time.time(),
|
217
|
+
show_speed=False,
|
218
|
+
refresh_per_second=2,
|
219
|
+
total=timeout,
|
220
|
+
):
|
221
|
+
time.sleep(1)
|
222
|
+
try:
|
223
|
+
self.get_mcu_info()
|
224
|
+
break
|
225
|
+
except (ConnectionError, MPFlashError):
|
226
|
+
pass
|