mpflash 1.24.2__py3-none-any.whl → 1.24.4__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/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 = "github_pat_"+"11AAHPVFQ0G4NTaQ73Bw5J"+"_fAp7K9sZ1qL8VFnI9g78eUlCdmOXHB3WzSdj2jtEYb4XF3N7PDJBl32qIxq"
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 sys.platform == "darwin":
186
+ if platform.system() == "Darwin":
169
187
  comports = [p for p in comports if ".Bluetooth" not in p.device]
170
- log.trace(f"no Bluetooth: {[p.device for p in comports]}")
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 sys.platform == "win32":
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 os.name == "nt":
206
+ if platform.system() == "Windows":
188
207
  return None
189
208
  # List all available serial ports
190
209
  available_ports = list_ports.comports()
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, cache_it=True):
76
76
  """Get the list of micropython versions from github tags"""
77
- cache_it = True
77
+
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 as e:
85
85
  versions = [
86
86
  "v9.99.9-preview",
87
87
  "v1.22.2",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mpflash
3
- Version: 1.24.2
3
+ Version: 1.24.4
4
4
  Summary: Flash and download tool for MicroPython firmwares
5
5
  Home-page: https://github.com/Josverl/micropython-stubber/blob/main/src/mpflash/README.md
6
6
  License: MIT
@@ -51,7 +51,7 @@ Description-Content-Type: text/markdown
51
51
  This tool was initially created to be used in a CI/CD pipeline to automate the process of downloading and flashing MicroPython firmware to multiple boards, but it has been extend with a TUI to be used for manual downloadig, flashing and development.
52
52
 
53
53
  `mpflash` has been tested on:
54
- - OS: Windows x64, Linux X64, but not (yet) macOS.
54
+ - OS: Windows x64, Linux X64, and macOS.
55
55
  - Micropython (hardware) ports:
56
56
  - `rp2`, using `.uf2`, using filecopy
57
57
  - `samd`, using ` .uf2`, using filecopy
@@ -59,7 +59,7 @@ This tool was initially created to be used in a CI/CD pipeline to automate the p
59
59
  - `esp8266`, using `.bin`, using esptool
60
60
  - `stm32`, using ` .dfu`, using pydfu
61
61
 
62
- Not yet implemented: `nrf`, `cc3200`, `mimxrt`
62
+ Not yet implemented: `nrf`, `cc3200`, `mimxrt`, `renesas`
63
63
 
64
64
  ## Features
65
65
  1. List the connected boards including their firmware details, in a tabular or json format
@@ -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=dyVpCUzBnL1GLbTDHND-C9w6oMmj3fl2oW_cO3zXn3Q,7376
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
@@ -36,7 +36,7 @@ mpflash/mpboard_id/__init__.py,sha256=b9PJiKFqmfyYgfi0-pbWGp2mrljdgvO6DNy0ABS8iz
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
38
  mpflash/mpboard_id/board_id.py,sha256=MnDWPqp0OqCkWD3E1Mhg-g20qASgPVHdROOCdr5TpOU,3249
39
- mpflash/mpboard_id/board_info.zip,sha256=F6YowS96DAqjten4ySe4MXgZwPtE-saZOUfY5OQkqKk,19759
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=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,,
48
+ mpflash/versions.py,sha256=5XhbR5Ef2291zBaDTcrfDjCl8iAIiuJKVfV6oNpPofY,4628
49
+ mpflash-1.24.4.dist-info/entry_points.txt,sha256=Jk_visOhYOsZIcSP2Ms9hKqfKy1iorR-6dYltSoWCpY,52
50
+ mpflash-1.24.4.dist-info/LICENSE,sha256=mWpNhsIxWzetYNnTpr4eb3HtgsxGIC8KcYWxXEcxQvE,1077
51
+ mpflash-1.24.4.dist-info/METADATA,sha256=eaCZR_hPWzmClWI-rMSs0CMKf3MT39oRlKIgaHyr8zY,17651
52
+ mpflash-1.24.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
53
+ mpflash-1.24.4.dist-info/RECORD,,