mpflash 0.8.0__py3-none-any.whl → 0.8.1__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/download.py +37 -11
- {mpflash-0.8.0.dist-info → mpflash-0.8.1.dist-info}/METADATA +1 -1
- {mpflash-0.8.0.dist-info → mpflash-0.8.1.dist-info}/RECORD +6 -6
- {mpflash-0.8.0.dist-info → mpflash-0.8.1.dist-info}/LICENSE +0 -0
- {mpflash-0.8.0.dist-info → mpflash-0.8.1.dist-info}/WHEEL +0 -0
- {mpflash-0.8.0.dist-info → mpflash-0.8.1.dist-info}/entry_points.txt +0 -0
mpflash/download.py
CHANGED
@@ -32,8 +32,18 @@ MICROPYTHON_ORG_URL = "https://micropython.org/"
|
|
32
32
|
# Regexes to remove dates and hashes in the filename that just get in the way
|
33
33
|
RE_DATE = r"(-\d{8}-)"
|
34
34
|
RE_HASH = r"(.g[0-9a-f]+\.)"
|
35
|
-
# regex to extract the version from the firmware filename
|
36
|
-
|
35
|
+
# regex to extract the version and the build from the firmware filename
|
36
|
+
# group 1 is the version, group 2 is the build
|
37
|
+
RE_VERSION_PREVIEW = r"v([\d\.]+)-?(?:preview\.)?(\d+)?\."
|
38
|
+
# 'RPI_PICO_W-v1.23.uf2'
|
39
|
+
# 'RPI_PICO_W-v1.23.0.uf2'
|
40
|
+
# 'RPI_PICO_W-v1.23.0-406.uf2'
|
41
|
+
# 'RPI_PICO_W-v1.23.0-preview.406.uf2'
|
42
|
+
# 'RPI_PICO_W-v1.23.0-preview.4.uf2'
|
43
|
+
# 'RPI_PICO_W-v1.23.0.uf2'
|
44
|
+
# 'https://micropython.org/resources/firmware/RPI_PICO_W-20240531-v1.24.0-preview.10.gc1a6b95bf.uf2'
|
45
|
+
# 'https://micropython.org/resources/firmware/RPI_PICO_W-20240531-v1.24.0-preview.10.uf2'
|
46
|
+
# 'RPI_PICO_W-v1.24.0-preview.10.gc1a6b95bf.uf2'
|
37
47
|
|
38
48
|
|
39
49
|
# use functools.lru_cache to avoid needing to download pages multiple times
|
@@ -98,6 +108,7 @@ def board_firmware_urls(board_url: str, base_url: str, ext: str) -> List[str]:
|
|
98
108
|
# The first run takes ~60 seconds to run for 4 ports , all boards
|
99
109
|
# so it makes sense to cache the results and skip boards as soon as possible
|
100
110
|
def get_boards(ports: List[str], boards: List[str], clean: bool) -> List[FWInfo]:
|
111
|
+
# sourcery skip: use-getitem-for-re-match-groups
|
101
112
|
"""
|
102
113
|
Retrieves a list of firmware information for the specified ports and boards.
|
103
114
|
|
@@ -146,13 +157,15 @@ def get_boards(ports: List[str], boards: List[str], clean: bool) -> List[FWInfo]
|
|
146
157
|
# board["firmware"] = _url
|
147
158
|
# board["preview"] = "preview" in _url # type: ignore
|
148
159
|
if ver_match := re.search(RE_VERSION_PREVIEW, _url):
|
149
|
-
fw_info.version = ver_match
|
160
|
+
fw_info.version = ver_match.group(1)
|
161
|
+
fw_info.build = ver_match.group(2) or "0"
|
162
|
+
fw_info.preview = fw_info.build != "0"
|
163
|
+
# # else:
|
164
|
+
# # board.$1= ""
|
165
|
+
# if "preview." in fw_info.version:
|
166
|
+
# fw_info.build = fw_info.version.split("preview.")[-1]
|
150
167
|
# else:
|
151
|
-
#
|
152
|
-
if "preview." in fw_info.version:
|
153
|
-
fw_info.build = fw_info.version.split("preview.")[-1]
|
154
|
-
else:
|
155
|
-
fw_info.build = "0"
|
168
|
+
# fw_info.build = "0"
|
156
169
|
|
157
170
|
fw_info.ext = Path(fw_info.firmware).suffix
|
158
171
|
fw_info.variant = fw_info.filename.split("-v")[0] if "-v" in fw_info.filename else ""
|
@@ -191,6 +204,11 @@ def download_firmwares(
|
|
191
204
|
# relevant
|
192
205
|
|
193
206
|
log.info(f"Found {len(unique_boards)} relevant unique firmwares")
|
207
|
+
if not unique_boards:
|
208
|
+
log.error("No relevant firmwares could be found on https://micropython.org/download")
|
209
|
+
log.info(f"{versions=} {ports=} {boards=}")
|
210
|
+
log.info("Please check the website for the latest firmware files or try the preview version.")
|
211
|
+
return 0
|
194
212
|
|
195
213
|
firmware_folder.mkdir(exist_ok=True)
|
196
214
|
|
@@ -238,12 +256,15 @@ def get_firmware_list(ports: List[str], boards: List[str], versions: List[str],
|
|
238
256
|
board_urls = sorted(get_boards(ports, boards, clean), key=key_fw_ver_pre_ext_bld)
|
239
257
|
|
240
258
|
log.debug(f"Total {len(board_urls)} firmwares")
|
259
|
+
|
241
260
|
relevant = [
|
242
261
|
board
|
243
262
|
for board in board_urls
|
244
|
-
if board.
|
245
|
-
# and b["port"] in ["esp32", "rp2"]
|
263
|
+
if board.version in versions and board.build == "0" and board.board in boards and not board.preview
|
246
264
|
]
|
265
|
+
|
266
|
+
if preview:
|
267
|
+
relevant.extend([board for board in board_urls if board.board in boards and board.preview])
|
247
268
|
log.debug(f"Matching firmwares: {len(relevant)}")
|
248
269
|
# select the unique boards
|
249
270
|
unique_boards: List[FWInfo] = []
|
@@ -290,5 +311,10 @@ def download(
|
|
290
311
|
except (PermissionError, FileNotFoundError) as e:
|
291
312
|
log.critical(f"Could not create folder {destination}")
|
292
313
|
raise MPFlashError(f"Could not create folder {destination}") from e
|
314
|
+
try:
|
315
|
+
result = download_firmwares(destination, ports, boards, versions, force=force, clean=clean)
|
316
|
+
except requests.exceptions.RequestException as e:
|
317
|
+
log.exception(e)
|
318
|
+
raise MPFlashError("Could not connect to micropython.org") from e
|
293
319
|
|
294
|
-
return
|
320
|
+
return result
|
@@ -9,7 +9,7 @@ mpflash/cli_main.py,sha256=yABFFf45TpPMcC1qEVARAWe4EI9zui2pUXjoPms0mq8,1030
|
|
9
9
|
mpflash/common.py,sha256=kanbO22SQDWb4ASQG8vLF0Z83ahujKPbrsCw3llN5T4,5594
|
10
10
|
mpflash/config.py,sha256=hBc1Hf4XQ0YIoeiPBbannnqDg0C7226Y7Vu8o4jUkBQ,495
|
11
11
|
mpflash/connected.py,sha256=CBG_DJ33OPWAPbX-ICQpL1LcFOhNYpLUSB0Q5v7gi9s,3029
|
12
|
-
mpflash/download.py,sha256=
|
12
|
+
mpflash/download.py,sha256=YChMbPNUYD8r7VojVMx2P7Qjf4o5f1Bbu240qR-z934,12693
|
13
13
|
mpflash/downloaded.py,sha256=IYMyx_67paKFSKOg3whgwsWf8IlHaLgpmSlukMT7V9Q,3804
|
14
14
|
mpflash/errors.py,sha256=Q5LR12Wo8iUCg5n_qq4GjdBdBflbvCOdKsRJ5InYRfI,96
|
15
15
|
mpflash/flash.py,sha256=JoskuwaHVYqeG4YW8kgbv26vPFnqDmkTz1VRs-pTRiY,2468
|
@@ -40,8 +40,8 @@ mpflash/vendor/pydfu.py,sha256=_MdBRo1EeNeKDqFPSTB5tNL1jGSBJgsVeVjE5e7Pb8s,20542
|
|
40
40
|
mpflash/vendor/readme.md,sha256=iIIZxuLUIGHQ0KODzYVtMezsztvyxCXcNJp_AzwTIPk,86
|
41
41
|
mpflash/vendor/versions.py,sha256=thk1a5wEEhXIQoL0zZ7oooeFyQeSoI00CIUbZF0b3rI,3783
|
42
42
|
mpflash/worklist.py,sha256=MKHDynttVP3lsHSfb7DEqeQ2mRV0da96lD4lIcS_zQY,5962
|
43
|
-
mpflash-0.8.
|
44
|
-
mpflash-0.8.
|
45
|
-
mpflash-0.8.
|
46
|
-
mpflash-0.8.
|
47
|
-
mpflash-0.8.
|
43
|
+
mpflash-0.8.1.dist-info/entry_points.txt,sha256=Jk_visOhYOsZIcSP2Ms9hKqfKy1iorR-6dYltSoWCpY,52
|
44
|
+
mpflash-0.8.1.dist-info/LICENSE,sha256=mWpNhsIxWzetYNnTpr4eb3HtgsxGIC8KcYWxXEcxQvE,1077
|
45
|
+
mpflash-0.8.1.dist-info/METADATA,sha256=T5fzthDNNXRngdgaxn_PMkoo4-y-e4j8b1zXZP0pG4o,15224
|
46
|
+
mpflash-0.8.1.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
47
|
+
mpflash-0.8.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|