mpflash 1.0.2__py3-none-any.whl → 1.0.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
@@ -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
- "github_pat"
35
- + "_11AAHPVFQ0qAkDnSUaMKSp"
36
- + "_ZkDl5NRRwBsUN6EYg9ahp1Dvj4FDDONnXVgimxC2EtpY7Q7BUKBoQ0Jq72X"
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/connected.py CHANGED
@@ -7,15 +7,7 @@ from rich.table import Column
7
7
  from mpflash.common import filtered_comports
8
8
  from mpflash.mpremoteboard import MPRemoteBoard
9
9
 
10
- import os
11
-
12
- if os.name == "linux":
13
- from mpflash.common import find_serial_by_path # type: ignore
14
- else:
15
-
16
- def find_serial_by_path(path: str) -> str:
17
- # log.warning(f"find_serial_by_path not implemented for {os.name}")
18
- return path
10
+ from mpflash.common import find_serial_by_path
19
11
 
20
12
 
21
13
  def connected_ports_boards(
@@ -71,7 +63,7 @@ def list_mcus(
71
63
  connected_mcus = [
72
64
  MPRemoteBoard(
73
65
  c.device,
74
- location=find_serial_by_path(c.device) or c.location or "?",
66
+ location=find_serial_by_path(c.device) or c.location or c.hwid or "?",
75
67
  )
76
68
  for c in comports
77
69
  ]
@@ -1,18 +1,18 @@
1
1
  import functools
2
2
  import zipfile
3
3
  from pathlib import Path
4
- from typing import List, Optional
4
+ from typing import Final, List, Optional
5
5
 
6
6
  import jsons
7
7
 
8
8
  from mpflash.mpboard_id.board import Board
9
9
 
10
10
  ###############################################################################################
11
- HERE = Path(__file__).parent
11
+ HERE: Final = Path(__file__).parent
12
12
  ###############################################################################################
13
13
 
14
14
 
15
- def write_boardinfo_json(board_list: List[Board], *, folder: Path):
15
+ def write_boardinfo_json(board_list: List[Board], *, folder: Optional[Path] = None):
16
16
  """Writes the board information to a JSON file.
17
17
 
18
18
  Args:
@@ -21,6 +21,8 @@ def write_boardinfo_json(board_list: List[Board], *, folder: Path):
21
21
  """
22
22
  import zipfile
23
23
 
24
+ if not folder:
25
+ folder = HERE
24
26
  # create a zip file with the json file
25
27
  with zipfile.ZipFile(folder / "board_info.zip", "w", compression=zipfile.ZIP_DEFLATED) as zipf:
26
28
  # write the list to json file inside the zip
@@ -30,6 +32,9 @@ def write_boardinfo_json(board_list: List[Board], *, folder: Path):
30
32
 
31
33
  @functools.lru_cache(maxsize=20)
32
34
  def read_known_boardinfo(board_info: Optional[Path] = None) -> List[Board]:
35
+ """Reads the board information from a JSON file in a zip file."""
36
+
37
+ import zipfile
33
38
 
34
39
  if not board_info:
35
40
  board_info = HERE / "board_info.zip"
@@ -36,7 +36,9 @@ def _info(): # type:() -> dict[str, str]
36
36
  "version": "",
37
37
  "build": "",
38
38
  "ver": "",
39
- "port": "stm32" if sys.platform.startswith("pyb") else sys.platform, # port: esp32 / win32 / linux / stm32
39
+ "port": (
40
+ "stm32" if sys.platform.startswith("pyb") else sys.platform
41
+ ), # port: esp32 / win32 / linux / stm32
40
42
  "board": "GENERIC",
41
43
  "cpu": "",
42
44
  "mpy": "",
@@ -48,7 +50,11 @@ def _info(): # type:() -> dict[str, str]
48
50
  except AttributeError:
49
51
  pass
50
52
  try:
51
- machine = sys.implementation._machine if "_machine" in dir(sys.implementation) else os.uname().machine
53
+ machine = (
54
+ sys.implementation._machine
55
+ if "_machine" in dir(sys.implementation)
56
+ else os.uname().machine
57
+ )
52
58
  info["board"] = machine.strip()
53
59
  info["cpu"] = machine.split("with")[-1].strip() if "with" in machine else ""
54
60
  info["mpy"] = (
@@ -100,7 +106,8 @@ def _info(): # type:() -> dict[str, str]
100
106
  if (
101
107
  info["version"]
102
108
  and info["version"].endswith(".0")
103
- and info["version"] >= "1.10.0" # versions from 1.10.0 to 1.20.0 do not have a micro .0
109
+ and info["version"]
110
+ >= "1.10.0" # versions from 1.10.0 to 1.20.0 do not have a micro .0
104
111
  and info["version"] <= "1.19.9"
105
112
  ):
106
113
  # drop the .0 for newer releases
@@ -110,19 +117,23 @@ def _info(): # type:() -> dict[str, str]
110
117
  if "mpy" in info and info["mpy"]: # mpy on some v1.11+ builds
111
118
  sys_mpy = int(info["mpy"])
112
119
  # .mpy architecture
113
- arch = [
114
- None,
115
- "x86",
116
- "x64",
117
- "armv6",
118
- "armv6m",
119
- "armv7m",
120
- "armv7em",
121
- "armv7emsp",
122
- "armv7emdp",
123
- "xtensa",
124
- "xtensawin",
125
- ][sys_mpy >> 10]
120
+ try:
121
+ arch = [
122
+ None,
123
+ "x86",
124
+ "x64",
125
+ "armv6",
126
+ "armv6m",
127
+ "armv7m",
128
+ "armv7em",
129
+ "armv7emsp",
130
+ "armv7emdp",
131
+ "xtensa",
132
+ "xtensawin",
133
+ "hazard3riscv", # assumed
134
+ ][sys_mpy >> 10]
135
+ except IndexError:
136
+ arch = "unknown"
126
137
  if arch:
127
138
  info["arch"] = arch
128
139
  # .mpy version.minor
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mpflash
3
- Version: 1.0.2
3
+ Version: 1.0.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
@@ -13,9 +13,9 @@ 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=f7yOivJCXiIs5aywbPMrMjz4T4036njEp8wXvdyHTnI,7398
16
+ mpflash/common.py,sha256=dyVpCUzBnL1GLbTDHND-C9w6oMmj3fl2oW_cO3zXn3Q,7376
17
17
  mpflash/config.py,sha256=tdpvAvAlpco1GfeG2evn5tAKYluLEanqwrrvkir7QcQ,1073
18
- mpflash/connected.py,sha256=CIgd5o2wVbQMJHRBgvbqBtKeXNNQisrspApJBqZ1A-g,3779
18
+ mpflash/connected.py,sha256=woYhuXoWpfzRMDUpBLVQZbVTGtMsKWNd5z1rsR1ELXA,3578
19
19
  mpflash/download.py,sha256=wE4uBSFFMAKOBH4jwHweL0wVYh4vi74t1673ku_IeoA,14305
20
20
  mpflash/downloaded.py,sha256=5qrf-V1fNTTGeueXaZUAnEqa-Yqru2jLyztx0wdyeuc,4938
21
21
  mpflash/errors.py,sha256=IAidY3qkZsXy6Pm1rdmVFmGyg81ywHhse3itaPctA2w,247
@@ -37,17 +37,17 @@ mpflash/mpboard_id/add_boards.py,sha256=47TtN98FVc6PvuOr-3-g3LacYW8JvXpM5Gr_jhdU
37
37
  mpflash/mpboard_id/board.py,sha256=CwtBux8y7GDUe7CADVxL8YefGRl9Fg8OAJBUhgaBYCI,1151
38
38
  mpflash/mpboard_id/board_id.py,sha256=3Qeo9cQOfn6EQ0gr5MHsl0Nk7is_piYrz0mMbV2LC-Q,2957
39
39
  mpflash/mpboard_id/board_info.zip,sha256=F6YowS96DAqjten4ySe4MXgZwPtE-saZOUfY5OQkqKk,19759
40
- mpflash/mpboard_id/store.py,sha256=4lLEff6a30lIOb4fOYYzanE4G4qfgikfprmpV1eUf2U,1536
40
+ mpflash/mpboard_id/store.py,sha256=n85vnUAxGKv1C23wkm22ZFAFGK6AZZiCFvc1lGJJjis,1703
41
41
  mpflash/mpremoteboard/__init__.py,sha256=3F6vZHM1znUOnAo0ne-FalApM6vwbTNYg4kJwkS1gNI,9521
42
- mpflash/mpremoteboard/mpy_fw_info.py,sha256=6AQbN3jtQgllqWQYl4e-63KeEtV08EXk8_JnM6XBkvo,4554
42
+ mpflash/mpremoteboard/mpy_fw_info.py,sha256=eRjhqN7MpmYE9TiS4iukquZZs3QE_lD5zv_vOPSjNrk,4821
43
43
  mpflash/mpremoteboard/runner.py,sha256=-PgzAeBGbyXaAUlwyiw4mcINsP2U1XRRjP1_QdBrxpg,4786
44
44
  mpflash/vendor/click_aliases.py,sha256=c853EHSlkE2DvFqeFvFpwXKuJj3_jsXDP7iotVOKaAw,3156
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
48
  mpflash/versions.py,sha256=EZtIe2RdBobhZaRIN7I-zZVNJ38CD_H8s3W8gXX9-IY,4627
49
- mpflash-1.0.2.dist-info/entry_points.txt,sha256=Jk_visOhYOsZIcSP2Ms9hKqfKy1iorR-6dYltSoWCpY,52
50
- mpflash-1.0.2.dist-info/LICENSE,sha256=mWpNhsIxWzetYNnTpr4eb3HtgsxGIC8KcYWxXEcxQvE,1077
51
- mpflash-1.0.2.dist-info/METADATA,sha256=pKVd8rSiRhIsCfMRLoptT0PGsb_4tsQokBBbC4yefGs,17649
52
- mpflash-1.0.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
53
- mpflash-1.0.2.dist-info/RECORD,,
49
+ mpflash-1.0.4.dist-info/entry_points.txt,sha256=Jk_visOhYOsZIcSP2Ms9hKqfKy1iorR-6dYltSoWCpY,52
50
+ mpflash-1.0.4.dist-info/LICENSE,sha256=mWpNhsIxWzetYNnTpr4eb3HtgsxGIC8KcYWxXEcxQvE,1077
51
+ mpflash-1.0.4.dist-info/METADATA,sha256=7JEA79qpIU9WJGoWw-sWiDMcOxXYXRTZKgJ6FymOff0,17649
52
+ mpflash-1.0.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
53
+ mpflash-1.0.4.dist-info/RECORD,,