mpflash 1.24.3__py3-none-any.whl → 1.24.5__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.
- mpflash/basicgit.py +1 -1
- mpflash/common.py +25 -6
- mpflash/mpboard_id/add_boards.py +5 -18
- mpflash/mpboard_id/board.py +2 -2
- mpflash/mpboard_id/board_info.zip +0 -0
- mpflash/versions.py +10 -8
- {mpflash-1.24.3.dist-info → mpflash-1.24.5.dist-info}/METADATA +1 -1
- {mpflash-1.24.3.dist-info → mpflash-1.24.5.dist-info}/RECORD +11 -11
- {mpflash-1.24.3.dist-info → mpflash-1.24.5.dist-info}/LICENSE +0 -0
- {mpflash-1.24.3.dist-info → mpflash-1.24.5.dist-info}/WHEEL +0 -0
- {mpflash-1.24.3.dist-info → mpflash-1.24.5.dist-info}/entry_points.txt +0 -0
mpflash/basicgit.py
CHANGED
@@ -242,7 +242,7 @@ def switch_branch(branch: str, repo: Optional[Union[Path, str]] = None) -> bool:
|
|
242
242
|
|
243
243
|
def fetch(repo: Union[Path, str]) -> bool:
|
244
244
|
"""
|
245
|
-
fetches a repo
|
245
|
+
fetches a repo
|
246
246
|
repo should be in the form of : path/.git
|
247
247
|
repo = '../micropython/.git'
|
248
248
|
returns True on success
|
mpflash/common.py
CHANGED
@@ -2,7 +2,6 @@ import fnmatch
|
|
2
2
|
import glob
|
3
3
|
import os
|
4
4
|
import platform
|
5
|
-
import sys
|
6
5
|
from dataclasses import dataclass, field
|
7
6
|
from enum import Enum
|
8
7
|
from pathlib import Path
|
@@ -30,7 +29,11 @@ PORT_FWTYPES = {
|
|
30
29
|
|
31
30
|
# Token with no permissions to avoid throttling
|
32
31
|
# https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#getting-a-higher-rate-limit
|
33
|
-
PAT_NO_ACCESS =
|
32
|
+
PAT_NO_ACCESS = (
|
33
|
+
"github_pat_"
|
34
|
+
+ "11AAHPVFQ0G4NTaQ73Bw5J"
|
35
|
+
+ "_fAp7K9sZ1qL8VFnI9g78eUlCdmOXHB3WzSdj2jtEYb4XF3N7PDJBl32qIxq"
|
36
|
+
)
|
34
37
|
|
35
38
|
PAT = os.environ.get("GITHUB_TOKEN") or PAT_NO_ACCESS
|
36
39
|
GH_CLIENT = Github(auth=Auth.Token(PAT))
|
@@ -135,12 +138,23 @@ def filtered_comports(
|
|
135
138
|
elif not isinstance(include, list): # type: ignore
|
136
139
|
include = list(include)
|
137
140
|
|
141
|
+
if ignore == [] and platform.system() == "Darwin":
|
142
|
+
# By default ignore some of the irrelevant ports on macOS
|
143
|
+
ignore = [
|
144
|
+
"/dev/*.debug-console",
|
145
|
+
]
|
146
|
+
|
138
147
|
# remove ports that are to be ignored
|
139
148
|
log.trace(f"{include=}, {ignore=}, {bluetooth=}")
|
140
149
|
|
141
150
|
comports = [
|
142
151
|
p for p in list_ports.comports() if not any(fnmatch.fnmatch(p.device, i) for i in ignore)
|
143
152
|
]
|
153
|
+
|
154
|
+
if False:
|
155
|
+
import jsons
|
156
|
+
print(jsons.dumps(comports).replace('{"description":', '\n{"description":'))
|
157
|
+
|
144
158
|
if platform.system() == "Linux":
|
145
159
|
# use p.location to filter out the bogus ports on newer Linux kernels
|
146
160
|
# filter out the bogus ports on newer Linux kernels
|
@@ -161,16 +175,21 @@ def filtered_comports(
|
|
161
175
|
else:
|
162
176
|
# if there are ports to ignore, add the explicit list to the filtered list
|
163
177
|
comports = list(set(explicit) | set(comports))
|
178
|
+
if platform.system() == "Darwin":
|
179
|
+
# Failsafe: filter out debug-console ports
|
180
|
+
comports = [p for p in comports if not p.description.endswith(".debug-console")]
|
181
|
+
|
164
182
|
if not bluetooth:
|
165
183
|
# filter out bluetooth ports
|
166
184
|
comports = [p for p in comports if "bluetooth" not in p.description.lower()]
|
167
185
|
comports = [p for p in comports if "BTHENUM" not in p.hwid]
|
168
|
-
if
|
186
|
+
if platform.system() == "Darwin":
|
169
187
|
comports = [p for p in comports if ".Bluetooth" not in p.device]
|
170
|
-
|
188
|
+
# filter out ports with no hwid
|
189
|
+
comports = [p for p in comports if p.hwid != "n/a"]
|
171
190
|
log.debug(f"filtered_comports: {[p.device for p in comports]}")
|
172
191
|
# sort
|
173
|
-
if
|
192
|
+
if platform.system() == "Windows":
|
174
193
|
# Windows sort of comports by number - but fallback to device name
|
175
194
|
return sorted(
|
176
195
|
comports,
|
@@ -184,7 +203,7 @@ def find_serial_by_path(target_port: str):
|
|
184
203
|
"""Find the symbolic link path of a serial port by its device path."""
|
185
204
|
# sourcery skip: use-next
|
186
205
|
|
187
|
-
if
|
206
|
+
if platform.system() == "Windows":
|
188
207
|
return None
|
189
208
|
# List all available serial ports
|
190
209
|
available_ports = list_ports.comports()
|
mpflash/mpboard_id/add_boards.py
CHANGED
@@ -25,9 +25,7 @@ RE_H_MICROPY_HW_BOARD_NAME = re.compile(r"#define\s+MICROPY_HW_BOARD_NAME\s+\"(.
|
|
25
25
|
RE_H_MICROPY_HW_MCU_NAME = re.compile(r"#define\s+MICROPY_HW_MCU_NAME\s+\"(.+)\"")
|
26
26
|
# find in the mpconfigboard.cmake files
|
27
27
|
|
28
|
-
RE_CMAKE_MICROPY_HW_BOARD_NAME = re.compile(
|
29
|
-
r"MICROPY_HW_BOARD_NAME\s?=\s?\"(?P<variant>[\w\s\S]*)\""
|
30
|
-
)
|
28
|
+
RE_CMAKE_MICROPY_HW_BOARD_NAME = re.compile(r"MICROPY_HW_BOARD_NAME\s?=\s?\"(?P<variant>[\w\s\S]*)\"")
|
31
29
|
RE_CMAKE_MICROPY_HW_MCU_NAME = re.compile(r"MICROPY_HW_MCU_NAME\s?=\s?\"(?P<variant>[\w\s\S]*)\"")
|
32
30
|
# TODO: normal make files
|
33
31
|
|
@@ -120,9 +118,7 @@ def boards_from_headers(mpy_path: Path, version: str, family: str):
|
|
120
118
|
mcu_name = match[1]
|
121
119
|
found += 1
|
122
120
|
if found == 2:
|
123
|
-
description =
|
124
|
-
f"{board_name} with {mcu_name}" if mcu_name != "-" else board_name
|
125
|
-
)
|
121
|
+
description = f"{board_name} with {mcu_name}" if mcu_name != "-" else board_name
|
126
122
|
board_list.append(
|
127
123
|
Board(
|
128
124
|
board_id=board,
|
@@ -164,8 +160,6 @@ def boards_for_versions(versions: List[str], mpy_path: Path):
|
|
164
160
|
List[Board]: The list of Board objects.
|
165
161
|
"""
|
166
162
|
board_list: List[Board] = []
|
167
|
-
# first fetch all tags from the repository
|
168
|
-
git.fetch(mpy_path)
|
169
163
|
for version in track(versions, description="Searching MicroPython versions"):
|
170
164
|
if git.checkout_tag(tag=version, repo=mpy_path):
|
171
165
|
new_ones = boards_from_repo(mpy_path, version, family="micropython")
|
@@ -203,10 +197,9 @@ def make_table(board_list: List[Board]) -> rich.table.Table:
|
|
203
197
|
is_wide = True
|
204
198
|
|
205
199
|
table = rich.table.Table(title="MicroPython Board Information")
|
206
|
-
table.add_column("Port", justify="left", style="magenta")
|
207
200
|
table.add_column("BOARD_ID", justify="left", style="green")
|
208
|
-
table.add_column("Variant(s)", justify="left", style="blue")
|
209
201
|
table.add_column("Description", justify="left", style="cyan")
|
202
|
+
table.add_column("Port", justify="left", style="magenta")
|
210
203
|
table.add_column("Board Name", justify="left", style="blue")
|
211
204
|
if is_wide:
|
212
205
|
table.add_column("MCU Name", justify="left", style="blue")
|
@@ -216,7 +209,7 @@ def make_table(board_list: List[Board]) -> rich.table.Table:
|
|
216
209
|
table.add_column("Family", justify="left", style="blue")
|
217
210
|
|
218
211
|
for board in board_list:
|
219
|
-
row = [board.
|
212
|
+
row = [board.board_id, board.description, *(board.port, board.board_name)]
|
220
213
|
if is_wide:
|
221
214
|
row.append(board.mcu_name)
|
222
215
|
row.extend((str(Path(board.path).suffix), board.version))
|
@@ -229,13 +222,7 @@ def make_table(board_list: List[Board]) -> rich.table.Table:
|
|
229
222
|
|
230
223
|
def ask_mpy_path():
|
231
224
|
"""Ask the user for the path to the MicroPython repository."""
|
232
|
-
questions = [
|
233
|
-
inquirer.Text(
|
234
|
-
"mpy_path",
|
235
|
-
message="Enter the path to the MicroPython repository",
|
236
|
-
default=".\\repos\\micropython",
|
237
|
-
)
|
238
|
-
]
|
225
|
+
questions = [inquirer.Text("mpy_path", message="Enter the path to the MicroPython repository", default=".\\repos\\micropython")]
|
239
226
|
if answers := inquirer.prompt(questions):
|
240
227
|
return Path(answers["mpy_path"])
|
241
228
|
else:
|
mpflash/mpboard_id/board.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from dataclasses import dataclass, field
|
2
2
|
from pathlib import Path
|
3
|
-
from typing import
|
3
|
+
from typing import Union
|
4
4
|
|
5
5
|
|
6
6
|
# - source : get_boardnames.py
|
@@ -20,7 +20,7 @@ class Board:
|
|
20
20
|
family: str = field(default="micropython")
|
21
21
|
mcu_name: str = field(default="")
|
22
22
|
cpu: str = field(default="")
|
23
|
-
|
23
|
+
# TODO: add variant
|
24
24
|
|
25
25
|
def __post_init__(self):
|
26
26
|
if not self.cpu:
|
Binary file
|
mpflash/versions.py
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
"""
|
2
|
-
|
3
|
-
# Version handling copied from stubber/utils/versions.py
|
4
|
-
#############################################################
|
2
|
+
Version handling for mpflash and micropython-stubber
|
5
3
|
"""
|
6
4
|
|
7
5
|
from pathlib import Path
|
8
6
|
|
9
7
|
from cache_to_disk import NoCacheCondition, cache_to_disk
|
10
8
|
from loguru import logger as log
|
11
|
-
from packaging.version import parse
|
9
|
+
from packaging.version import Version, parse
|
12
10
|
|
13
11
|
import mpflash.basicgit as git
|
14
12
|
from mpflash.common import GH_CLIENT
|
@@ -71,6 +69,11 @@ def clean_version(
|
|
71
69
|
return version
|
72
70
|
|
73
71
|
|
72
|
+
def is_version(version: str):
|
73
|
+
"""Check if the version is a valid version string"""
|
74
|
+
return Version._regex.search(version) is not None
|
75
|
+
|
76
|
+
|
74
77
|
@cache_to_disk(n_days_to_cache=1)
|
75
78
|
def micropython_versions(minver: str = "v1.20", reverse: bool = False, cache_it=True):
|
76
79
|
"""Get the list of micropython versions from github tags"""
|
@@ -105,10 +108,9 @@ def micropython_versions(minver: str = "v1.20", reverse: bool = False, cache_it=
|
|
105
108
|
cache_it = False
|
106
109
|
versions = [v for v in versions if parse(v) >= parse(minver)]
|
107
110
|
# remove all but the most recent (preview) version
|
108
|
-
versions = [v for v in versions if "preview" in v]
|
109
|
-
|
110
|
-
|
111
|
-
versions = sorted(versions, reverse=reverse)
|
111
|
+
versions = versions[:1] + [v for v in versions if "preview" not in v]
|
112
|
+
# remove any duplicates and sort
|
113
|
+
versions = sorted(list(set(versions)), reverse=reverse, key=lambda s: (not is_version(s), s))
|
112
114
|
if cache_it:
|
113
115
|
return versions
|
114
116
|
# returns - but does not cache
|
@@ -1,7 +1,7 @@
|
|
1
1
|
mpflash/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
mpflash/add_firmware.py,sha256=1h0HsA-EVi3HXLmoEvzwY_a-GuWYzPwulTYHHBB8THg,3428
|
3
3
|
mpflash/ask_input.py,sha256=RJHGGrhYniSu-bdoKnKptE3DtpiCREJGRTZmFazvG-E,8946
|
4
|
-
mpflash/basicgit.py,sha256=
|
4
|
+
mpflash/basicgit.py,sha256=6dKexwx844R55q6X39ZDCF4HDB3t94OHyDJuuicZvjw,9959
|
5
5
|
mpflash/bootloader/__init__.py,sha256=Qy3E6tETPnzMga9LgD5UgOvJ0zZIBEqhtEVb4v8CTWQ,107
|
6
6
|
mpflash/bootloader/activate.py,sha256=FlO4XQlKyoOuvmDdj_0u_mjNPhjGwB_K17jQ-8nSXRA,2361
|
7
7
|
mpflash/bootloader/detect.py,sha256=fBrILi7-ICRaregqms3PYqwiQVAJC0rXVhpyzDkoPQI,2690
|
@@ -13,7 +13,7 @@ mpflash/cli_flash.py,sha256=pVqEsDocDT3KmIMTpXdym-ZlzThLSIp6oVtYib65dys,7595
|
|
13
13
|
mpflash/cli_group.py,sha256=VWwYHiPVV19sQEr5lL8LlcPyZ-A6Gs79eMDJy8LLt90,2615
|
14
14
|
mpflash/cli_list.py,sha256=ja21AZ4yghGTtOHkEtV1EOmT6EYxOiU2gzJc-mZaDto,2427
|
15
15
|
mpflash/cli_main.py,sha256=5EkvzsqOUDXvNaW814oSUcPWeNhnwh78Sg0MteDv_fk,1133
|
16
|
-
mpflash/common.py,sha256=
|
16
|
+
mpflash/common.py,sha256=uNd9dUbPQE4KT-p3Y-od8jVE51b3IcHxDWHpY5vi6Yo,7964
|
17
17
|
mpflash/config.py,sha256=tdpvAvAlpco1GfeG2evn5tAKYluLEanqwrrvkir7QcQ,1073
|
18
18
|
mpflash/connected.py,sha256=woYhuXoWpfzRMDUpBLVQZbVTGtMsKWNd5z1rsR1ELXA,3578
|
19
19
|
mpflash/download.py,sha256=wE4uBSFFMAKOBH4jwHweL0wVYh4vi74t1673ku_IeoA,14305
|
@@ -33,10 +33,10 @@ mpflash/flash/worklist.py,sha256=owS3xJbWC-SzbK9z6jQER0Kat3OIV09IxnV-f-tjGlY,599
|
|
33
33
|
mpflash/list.py,sha256=lP_S5xbC0Men9HsXcIxOsP0bFRlCYh5CynMLFJx8cEE,3607
|
34
34
|
mpflash/logger.py,sha256=dI_H_a7EOdQJyvoeRHQuYeZuTKYVUS3DUPTLhE9rkdM,1098
|
35
35
|
mpflash/mpboard_id/__init__.py,sha256=b9PJiKFqmfyYgfi0-pbWGp2mrljdgvO6DNy0ABS8izU,3898
|
36
|
-
mpflash/mpboard_id/add_boards.py,sha256=
|
37
|
-
mpflash/mpboard_id/board.py,sha256=
|
36
|
+
mpflash/mpboard_id/add_boards.py,sha256=47TtN98FVc6PvuOr-3-g3LacYW8JvXpM5Gr_jhdUGEU,9630
|
37
|
+
mpflash/mpboard_id/board.py,sha256=CwtBux8y7GDUe7CADVxL8YefGRl9Fg8OAJBUhgaBYCI,1151
|
38
38
|
mpflash/mpboard_id/board_id.py,sha256=MnDWPqp0OqCkWD3E1Mhg-g20qASgPVHdROOCdr5TpOU,3249
|
39
|
-
mpflash/mpboard_id/board_info.zip,sha256=
|
39
|
+
mpflash/mpboard_id/board_info.zip,sha256=XkIk35v6LotRMClCU-zEvo1zQiKXZAqkHfwLP4JhfaM,20102
|
40
40
|
mpflash/mpboard_id/store.py,sha256=n85vnUAxGKv1C23wkm22ZFAFGK6AZZiCFvc1lGJJjis,1703
|
41
41
|
mpflash/mpremoteboard/__init__.py,sha256=3F6vZHM1znUOnAo0ne-FalApM6vwbTNYg4kJwkS1gNI,9521
|
42
42
|
mpflash/mpremoteboard/mpy_fw_info.py,sha256=eRjhqN7MpmYE9TiS4iukquZZs3QE_lD5zv_vOPSjNrk,4821
|
@@ -45,9 +45,9 @@ mpflash/vendor/click_aliases.py,sha256=c853EHSlkE2DvFqeFvFpwXKuJj3_jsXDP7iotVOKa
|
|
45
45
|
mpflash/vendor/dfu.py,sha256=ZXMcE6aH4-43Wh4tbQT4U-q-BU3RUiL3JAxmP_QAK2s,5755
|
46
46
|
mpflash/vendor/pydfu.py,sha256=_MdBRo1EeNeKDqFPSTB5tNL1jGSBJgsVeVjE5e7Pb8s,20542
|
47
47
|
mpflash/vendor/readme.md,sha256=iIIZxuLUIGHQ0KODzYVtMezsztvyxCXcNJp_AzwTIPk,86
|
48
|
-
mpflash/versions.py,sha256=
|
49
|
-
mpflash-1.24.
|
50
|
-
mpflash-1.24.
|
51
|
-
mpflash-1.24.
|
52
|
-
mpflash-1.24.
|
53
|
-
mpflash-1.24.
|
48
|
+
mpflash/versions.py,sha256=pKl-4GPHTs3_p73xywxSvsouZ3L4R2ljXSCkWj9U8HE,4742
|
49
|
+
mpflash-1.24.5.dist-info/entry_points.txt,sha256=Jk_visOhYOsZIcSP2Ms9hKqfKy1iorR-6dYltSoWCpY,52
|
50
|
+
mpflash-1.24.5.dist-info/LICENSE,sha256=mWpNhsIxWzetYNnTpr4eb3HtgsxGIC8KcYWxXEcxQvE,1077
|
51
|
+
mpflash-1.24.5.dist-info/METADATA,sha256=mJfXKJ0R5EkBVnMLyRoixlpC2DmgbTj3ehYAdoTTzw4,17651
|
52
|
+
mpflash-1.24.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
53
|
+
mpflash-1.24.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|