mpflash 0.7.2__tar.gz → 0.7.3__tar.gz

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.
Files changed (39) hide show
  1. {mpflash-0.7.2 → mpflash-0.7.3}/PKG-INFO +1 -1
  2. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/list.py +35 -11
  3. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/mpboard_id/board_id.py +5 -3
  4. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/mpremoteboard/__init__.py +2 -2
  5. {mpflash-0.7.2 → mpflash-0.7.3}/pyproject.toml +2 -1
  6. {mpflash-0.7.2 → mpflash-0.7.3}/LICENSE +0 -0
  7. {mpflash-0.7.2 → mpflash-0.7.3}/README.md +0 -0
  8. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/__init__.py +0 -0
  9. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/ask_input.py +0 -0
  10. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/cli_download.py +0 -0
  11. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/cli_flash.py +0 -0
  12. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/cli_group.py +0 -0
  13. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/cli_list.py +0 -0
  14. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/cli_main.py +0 -0
  15. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/common.py +0 -0
  16. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/config.py +0 -0
  17. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/download.py +0 -0
  18. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/downloaded.py +0 -0
  19. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/errors.py +0 -0
  20. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/flash.py +0 -0
  21. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/flash_esp.py +0 -0
  22. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/flash_stm32.py +0 -0
  23. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/flash_stm32_cube.py +0 -0
  24. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/flash_stm32_dfu.py +0 -0
  25. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/flash_uf2.py +0 -0
  26. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/flash_uf2_boardid.py +0 -0
  27. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/flash_uf2_linux.py +0 -0
  28. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/flash_uf2_windows.py +0 -0
  29. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/logger.py +0 -0
  30. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/mpboard_id/__init__.py +0 -0
  31. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/mpboard_id/board_info.csv +0 -0
  32. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/mpboard_id/board_info.json +0 -0
  33. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/mpremoteboard/mpy_fw_info.py +0 -0
  34. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/mpremoteboard/runner.py +0 -0
  35. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/vendor/dfu.py +0 -0
  36. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/vendor/pydfu.py +0 -0
  37. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/vendor/readme.md +0 -0
  38. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/vendor/versions.py +0 -0
  39. {mpflash-0.7.2 → mpflash-0.7.3}/mpflash/worklist.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mpflash
3
- Version: 0.7.2
3
+ Version: 0.7.3
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,23 +51,44 @@ def show_mcus(
51
51
  conn_mcus: List[MPRemoteBoard],
52
52
  title: str = "Connected boards",
53
53
  refresh: bool = True,
54
- ): # sourcery skip: extract-duplicate-method
54
+ ):
55
+ console.print(mcu_table(conn_mcus, title, refresh))
56
+
57
+
58
+ def abbrv_family(family: str, is_narrow: bool) -> str:
59
+ ABRV = {"micropython": "upy", "circuitpython": "cpy"}
60
+ if is_narrow:
61
+ if family in ABRV:
62
+ return ABRV[family]
63
+ return family[:4]
64
+ return family
65
+
66
+
67
+ def mcu_table(
68
+ conn_mcus: List[MPRemoteBoard],
69
+ title: str = "Connected boards",
70
+ refresh: bool = True,
71
+ ):
55
72
  """Show the list of connected boards in a nice table"""
56
73
  table = Table(
57
74
  title=title,
58
75
  title_style="magenta",
59
76
  header_style="bold magenta",
60
77
  collapse_padding=True,
61
- width=110,
78
+ padding=(0, 0),
79
+ # width=80,
62
80
  )
63
- table.add_column("Serial", overflow="fold")
64
- table.add_column("Family")
81
+ needs_build = any(mcu.build for mcu in conn_mcus)
82
+ is_narrow = console.width < 100
83
+ table.add_column("Ser." if is_narrow else "Serial", overflow="fold")
84
+ table.add_column("Fam." if is_narrow else "Family", overflow="crop", max_width=4 if is_narrow else None)
65
85
  table.add_column("Port")
66
86
  table.add_column("Board", overflow="fold")
67
87
  # table.add_column("Variant") # TODO: add variant
68
88
  table.add_column("CPU")
69
- table.add_column("Version")
70
- table.add_column("build", justify="right")
89
+ table.add_column("Version", overflow="fold", max_width=8 if is_narrow else None)
90
+ if needs_build:
91
+ table.add_column("Bld" if is_narrow else "Build", justify="right")
71
92
 
72
93
  for mcu in track(conn_mcus, description="Updating board info", transient=True, update_period=0.1):
73
94
  if refresh:
@@ -76,14 +97,17 @@ def show_mcus(
76
97
  except ConnectionError:
77
98
  continue
78
99
  description = f"[italic bright_cyan]{mcu.description}" if mcu.description else ""
79
- table.add_row(
100
+ row = [
80
101
  mcu.serialport.replace("/dev/", ""),
81
- mcu.family,
102
+ abbrv_family(mcu.family, is_narrow),
82
103
  mcu.port,
83
104
  f"{mcu.board}\n{description}".strip(),
84
105
  # mcu.variant,
85
106
  mcu.cpu,
86
107
  clean_version(mcu.version),
87
- mcu.build,
88
- )
89
- console.print(table)
108
+ ]
109
+ if needs_build:
110
+ row.append(mcu.build)
111
+
112
+ table.add_row(*row)
113
+ return table
@@ -15,12 +15,12 @@ HERE = Path(__file__).parent
15
15
  ###############################################################################################
16
16
 
17
17
 
18
- def find_board_id(
18
+ def find_board_id_by_description(
19
19
  descr: str, short_descr: str, board_info: Optional[Path] = None, version: str = "stable"
20
20
  ) -> Optional[str]:
21
21
  """Find the MicroPython BOARD_ID based on the description in the firmware"""
22
22
  try:
23
- boards = find_board_id_by_description(
23
+ boards = _find_board_id_by_description(
24
24
  descr=descr,
25
25
  short_descr=short_descr,
26
26
  board_info=board_info,
@@ -32,7 +32,9 @@ def find_board_id(
32
32
 
33
33
 
34
34
  @functools.lru_cache(maxsize=20)
35
- def find_board_id_by_description(*, descr: str, short_descr: str, version="v1.21.0", board_info: Optional[Path] = None):
35
+ def _find_board_id_by_description(
36
+ *, descr: str, short_descr: str, version="v1.21.0", board_info: Optional[Path] = None
37
+ ):
36
38
  """
37
39
  Find the MicroPython BOARD_ID based on the description in the firmware
38
40
  using the pre-built board_info.json file
@@ -13,7 +13,7 @@ from rich.progress import track
13
13
  from tenacity import retry, stop_after_attempt, wait_fixed
14
14
 
15
15
  from mpflash.errors import MPFlashError
16
- from mpflash.mpboard_id.board_id import find_board_id
16
+ from mpflash.mpboard_id.board_id import find_board_id_by_description
17
17
  from mpflash.mpremoteboard.runner import run
18
18
 
19
19
  ###############################################################################################
@@ -116,7 +116,7 @@ class MPRemoteBoard:
116
116
  self.description = descr = info["board"]
117
117
  pos = descr.rfind(" with")
118
118
  short_descr = descr[:pos].strip() if pos != -1 else ""
119
- if board_name := find_board_id(descr, short_descr):
119
+ if board_name := find_board_id_by_description(descr, short_descr):
120
120
  self.board = board_name
121
121
  else:
122
122
  self.board = "UNKNOWN"
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "mpflash"
3
- version = "0.7.2"
3
+ version = "0.7.3"
4
4
  description = "Flash and download tool for MicroPython firmwares"
5
5
  authors = ["Jos Verlinde <jos_verlinde@hotmail.com>"]
6
6
  license = "MIT"
@@ -50,6 +50,7 @@ pytest-mock = "^3.10.0"
50
50
  mock = "^4.0.3"
51
51
  distro = "^1.8.0"
52
52
  fasteners = "^0.19"
53
+ jsons = "^1.6.3"
53
54
 
54
55
 
55
56
  [build-system]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes