mpflash 1.24.1__py3-none-any.whl → 1.24.2__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 +27 -7
- mpflash/common.py +2 -5
- mpflash/mpboard_id/__init__.py +9 -4
- mpflash/mpboard_id/board_id.py +10 -6
- mpflash/mpboard_id/board_info.zip +0 -0
- mpflash/versions.py +3 -3
- {mpflash-1.24.1.dist-info → mpflash-1.24.2.dist-info}/METADATA +1 -1
- {mpflash-1.24.1.dist-info → mpflash-1.24.2.dist-info}/RECORD +11 -11
- {mpflash-1.24.1.dist-info → mpflash-1.24.2.dist-info}/LICENSE +0 -0
- {mpflash-1.24.1.dist-info → mpflash-1.24.2.dist-info}/WHEEL +0 -0
- {mpflash-1.24.1.dist-info → mpflash-1.24.2.dist-info}/entry_points.txt +0 -0
mpflash/basicgit.py
CHANGED
@@ -10,7 +10,7 @@ from pathlib import Path
|
|
10
10
|
from typing import List, Optional, Union
|
11
11
|
|
12
12
|
import cachetools.func
|
13
|
-
from github import Auth, Github
|
13
|
+
from github import Auth, BadCredentialsException, Github
|
14
14
|
from loguru import logger as log
|
15
15
|
from packaging.version import parse
|
16
16
|
|
@@ -18,7 +18,11 @@ from packaging.version import parse
|
|
18
18
|
|
19
19
|
# Token with no permissions to avoid throttling
|
20
20
|
# 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
|
21
|
-
PAT_NO_ACCESS =
|
21
|
+
PAT_NO_ACCESS = (
|
22
|
+
"github_pat_"
|
23
|
+
+ "11AAHPVFQ0G4NTaQ73Bw5J"
|
24
|
+
+ "_fAp7K9sZ1qL8VFnI9g78eUlCdmOXHB3WzSdj2jtEYb4XF3N7PDJBl32qIxq"
|
25
|
+
)
|
22
26
|
PAT = os.environ.get("GITHUB_TOKEN") or PAT_NO_ACCESS
|
23
27
|
GH_CLIENT = Github(auth=Auth.Token(PAT))
|
24
28
|
|
@@ -35,9 +39,17 @@ def _run_local_git(
|
|
35
39
|
if repo:
|
36
40
|
if isinstance(repo, str):
|
37
41
|
repo = Path(repo)
|
38
|
-
result = subprocess.run(
|
42
|
+
result = subprocess.run(
|
43
|
+
cmd,
|
44
|
+
capture_output=capture_output,
|
45
|
+
check=True,
|
46
|
+
cwd=repo.absolute().as_posix(),
|
47
|
+
encoding="utf-8",
|
48
|
+
)
|
39
49
|
else:
|
40
|
-
result = subprocess.run(
|
50
|
+
result = subprocess.run(
|
51
|
+
cmd, capture_output=capture_output, check=True, encoding="utf-8"
|
52
|
+
)
|
41
53
|
except (NotADirectoryError, FileNotFoundError) as e: # pragma: no cover
|
42
54
|
return None
|
43
55
|
except subprocess.CalledProcessError as e: # pragma: no cover
|
@@ -76,7 +88,9 @@ def clone(remote_repo: str, path: Path, shallow: bool = False, tag: Optional[str
|
|
76
88
|
return False
|
77
89
|
|
78
90
|
|
79
|
-
def get_local_tag(
|
91
|
+
def get_local_tag(
|
92
|
+
repo: Optional[Union[str, Path]] = None, abbreviate: bool = True
|
93
|
+
) -> Union[str, None]:
|
80
94
|
"""
|
81
95
|
get the most recent git version tag of a local repo
|
82
96
|
repo Path should be in the form of : repo = "./repo/micropython"
|
@@ -125,12 +139,16 @@ def get_local_tags(repo: Optional[Path] = None, minver: Optional[str] = None) ->
|
|
125
139
|
@cachetools.func.ttl_cache(maxsize=16, ttl=60) # 60 seconds
|
126
140
|
def get_tags(repo: str, minver: Optional[str] = None) -> List[str]:
|
127
141
|
"""
|
128
|
-
Get list of tag of a repote github repo
|
142
|
+
Get list of tag of a repote github repo.
|
143
|
+
only the last -preview tag is kept
|
129
144
|
"""
|
130
145
|
if not repo or not isinstance(repo, str) or "/" not in repo: # type: ignore
|
131
146
|
return []
|
132
147
|
try:
|
133
148
|
gh_repo = GH_CLIENT.get_repo(repo)
|
149
|
+
except BadCredentialsException as e:
|
150
|
+
log.error(f"Github authentication error - {e}")
|
151
|
+
return []
|
134
152
|
except ConnectionError as e:
|
135
153
|
# TODO: unable to capture the exeption
|
136
154
|
log.warning(f"Unable to get tags - {e}")
|
@@ -138,7 +156,9 @@ def get_tags(repo: str, minver: Optional[str] = None) -> List[str]:
|
|
138
156
|
tags = [tag.name for tag in gh_repo.get_tags()]
|
139
157
|
if minver:
|
140
158
|
tags = [tag for tag in tags if parse(tag) >= parse(minver)]
|
141
|
-
|
159
|
+
# remove all but the last preview
|
160
|
+
tags = [t for t in sorted(tags[:-1]) if "-preview" not in t] + sorted(tags)[-1:]
|
161
|
+
return tags
|
142
162
|
|
143
163
|
|
144
164
|
def checkout_tag(tag: str, repo: Optional[Union[str, Path]] = None) -> bool:
|
mpflash/common.py
CHANGED
@@ -30,11 +30,8 @@ PORT_FWTYPES = {
|
|
30
30
|
|
31
31
|
# Token with no permissions to avoid throttling
|
32
32
|
# 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 =
|
34
|
-
|
35
|
-
+ "_11AAHPVFQ0K6OKbI9xPFWG"
|
36
|
-
+ "_3KossOkuuxRJ6MZrP5o2vMsAW2i3QFZx2BECNjL4o30S2XQBWF77JgQbJda"
|
37
|
-
)
|
33
|
+
PAT_NO_ACCESS = "github_pat_"+"11AAHPVFQ0G4NTaQ73Bw5J"+"_fAp7K9sZ1qL8VFnI9g78eUlCdmOXHB3WzSdj2jtEYb4XF3N7PDJBl32qIxq"
|
34
|
+
|
38
35
|
PAT = os.environ.get("GITHUB_TOKEN") or PAT_NO_ACCESS
|
39
36
|
GH_CLIENT = Github(auth=Auth.Token(PAT))
|
40
37
|
|
mpflash/mpboard_id/__init__.py
CHANGED
@@ -24,7 +24,9 @@ def get_known_ports() -> List[str]:
|
|
24
24
|
return sorted(list(ports))
|
25
25
|
|
26
26
|
|
27
|
-
def get_known_boards_for_port(
|
27
|
+
def get_known_boards_for_port(
|
28
|
+
port: Optional[str] = "", versions: Optional[List[str]] = None
|
29
|
+
) -> List[Board]:
|
28
30
|
"""
|
29
31
|
Returns a list of boards for the given port and version(s)
|
30
32
|
|
@@ -77,13 +79,16 @@ def known_stored_boards(port: str, versions: Optional[List[str]] = None) -> List
|
|
77
79
|
@lru_cache(maxsize=20)
|
78
80
|
def find_known_board(board_id: str) -> Board:
|
79
81
|
"""Find the board for the given BOARD_ID or 'board description' and return the board info as a Board object"""
|
80
|
-
#
|
82
|
+
# Some functional overlap with:
|
81
83
|
# mpboard_id\board_id.py _find_board_id_by_description
|
82
84
|
info = read_known_boardinfo()
|
83
85
|
for board_info in info:
|
84
|
-
if board_id in (
|
86
|
+
if board_id in (
|
87
|
+
board_info.board_id,
|
88
|
+
board_info.description,
|
89
|
+
) or board_info.description.startswith(board_id):
|
85
90
|
if not board_info.cpu:
|
86
|
-
#
|
91
|
+
# failsafe for older board_info.json files
|
87
92
|
print(f"Board {board_id} has no CPU info, using port as CPU")
|
88
93
|
if " with " in board_info.description:
|
89
94
|
board_info.cpu = board_info.description.split(" with ")[-1]
|
mpflash/mpboard_id/board_id.py
CHANGED
@@ -56,14 +56,12 @@ def _find_board_id_by_description(
|
|
56
56
|
Path to the board_info.json file (optional)
|
57
57
|
|
58
58
|
"""
|
59
|
-
#
|
59
|
+
# Some functional overlap with
|
60
60
|
# src\mpflash\mpflash\mpboard_id\__init__.py find_known_board
|
61
61
|
|
62
|
+
candidate_boards = read_known_boardinfo(board_info)
|
62
63
|
if not short_descr and " with " in descr:
|
63
64
|
short_descr = descr.split(" with ")[0]
|
64
|
-
|
65
|
-
candidate_boards = read_known_boardinfo(board_info)
|
66
|
-
|
67
65
|
if version:
|
68
66
|
# filter for matching version
|
69
67
|
if version in ("preview", "stable"):
|
@@ -71,16 +69,22 @@ def _find_board_id_by_description(
|
|
71
69
|
version = get_stable_mp_version()
|
72
70
|
known_versions = sorted({b.version for b in candidate_boards})
|
73
71
|
if version not in known_versions:
|
74
|
-
# FIXME if latest stable is newer than the last version in the boardlist this will fail
|
75
72
|
log.trace(f"Version {version} not found in board info, using latest known version {known_versions[-1]}")
|
76
|
-
version = known_versions[-1]
|
73
|
+
version = '.'.join(known_versions[-1].split('.')[:2]) # take only major.minor
|
77
74
|
if version_matches := [b for b in candidate_boards if b.version.startswith(version)]:
|
78
75
|
candidate_boards = version_matches
|
79
76
|
else:
|
80
77
|
raise MPFlashError(f"No board info found for version {version}")
|
78
|
+
# First try full match on description, then partial match
|
81
79
|
matches = [b for b in candidate_boards if b.description == descr]
|
82
80
|
if not matches and short_descr:
|
83
81
|
matches = [b for b in candidate_boards if b.description == short_descr]
|
82
|
+
if not matches:
|
83
|
+
# partial match (for added VARIANT)
|
84
|
+
matches = [b for b in candidate_boards if b.description.startswith(descr)]
|
85
|
+
if not matches and short_descr:
|
86
|
+
matches = [b for b in candidate_boards if b.description.startswith(short_descr)]
|
84
87
|
if not matches:
|
85
88
|
raise MPFlashError(f"No board info found for description '{descr}' or '{short_descr}'")
|
86
89
|
return sorted(matches, key=lambda x: x.version)
|
90
|
+
|
Binary file
|
mpflash/versions.py
CHANGED
@@ -72,16 +72,16 @@ def clean_version(
|
|
72
72
|
|
73
73
|
|
74
74
|
@cache_to_disk(n_days_to_cache=1)
|
75
|
-
def micropython_versions(minver: str = "v1.20", reverse: bool = False
|
75
|
+
def micropython_versions(minver: str = "v1.20", reverse: bool = False):
|
76
76
|
"""Get the list of micropython versions from github tags"""
|
77
|
-
|
77
|
+
cache_it = True
|
78
78
|
try:
|
79
79
|
gh_client = GH_CLIENT
|
80
80
|
repo = gh_client.get_repo("micropython/micropython")
|
81
81
|
versions = [tag.name for tag in repo.get_tags() if parse(tag.name) >= parse(minver)]
|
82
82
|
# Only keep the last preview
|
83
83
|
versions = [v for v in versions if not v.endswith(V_PREVIEW) or v == versions[-1]]
|
84
|
-
except Exception
|
84
|
+
except Exception:
|
85
85
|
versions = [
|
86
86
|
"v9.99.9-preview",
|
87
87
|
"v1.22.2",
|
@@ -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=dyVpCUzBnL1GLbTDHND-C9w6oMmj3fl2oW_cO3zXn3Q,7376
|
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
|
@@ -32,11 +32,11 @@ mpflash/flash/uf2/windows.py,sha256=v89eXA3QwZxilCazi3Z--yY8UNtZ94trNEJ6U7XUuXA,
|
|
32
32
|
mpflash/flash/worklist.py,sha256=owS3xJbWC-SzbK9z6jQER0Kat3OIV09IxnV-f-tjGlY,5998
|
33
33
|
mpflash/list.py,sha256=lP_S5xbC0Men9HsXcIxOsP0bFRlCYh5CynMLFJx8cEE,3607
|
34
34
|
mpflash/logger.py,sha256=dI_H_a7EOdQJyvoeRHQuYeZuTKYVUS3DUPTLhE9rkdM,1098
|
35
|
-
mpflash/mpboard_id/__init__.py,sha256=
|
35
|
+
mpflash/mpboard_id/__init__.py,sha256=b9PJiKFqmfyYgfi0-pbWGp2mrljdgvO6DNy0ABS8izU,3898
|
36
36
|
mpflash/mpboard_id/add_boards.py,sha256=47TtN98FVc6PvuOr-3-g3LacYW8JvXpM5Gr_jhdUGEU,9630
|
37
37
|
mpflash/mpboard_id/board.py,sha256=CwtBux8y7GDUe7CADVxL8YefGRl9Fg8OAJBUhgaBYCI,1151
|
38
|
-
mpflash/mpboard_id/board_id.py,sha256=
|
39
|
-
mpflash/mpboard_id/board_info.zip,sha256=
|
38
|
+
mpflash/mpboard_id/board_id.py,sha256=MnDWPqp0OqCkWD3E1Mhg-g20qASgPVHdROOCdr5TpOU,3249
|
39
|
+
mpflash/mpboard_id/board_info.zip,sha256=F6YowS96DAqjten4ySe4MXgZwPtE-saZOUfY5OQkqKk,19759
|
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=EZtIe2RdBobhZaRIN7I-zZVNJ38CD_H8s3W8gXX9-IY,4627
|
49
|
+
mpflash-1.24.2.dist-info/entry_points.txt,sha256=Jk_visOhYOsZIcSP2Ms9hKqfKy1iorR-6dYltSoWCpY,52
|
50
|
+
mpflash-1.24.2.dist-info/LICENSE,sha256=mWpNhsIxWzetYNnTpr4eb3HtgsxGIC8KcYWxXEcxQvE,1077
|
51
|
+
mpflash-1.24.2.dist-info/METADATA,sha256=Pqh18RSGn8Klw7DgG1JGA34WSEB3QXzJs5vZqrhzBmU,17650
|
52
|
+
mpflash-1.24.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
53
|
+
mpflash-1.24.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|