micropython-stubber 1.20.1__py3-none-any.whl → 1.20.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.
Files changed (60) hide show
  1. {micropython_stubber-1.20.1.dist-info → micropython_stubber-1.20.4.dist-info}/METADATA +4 -3
  2. {micropython_stubber-1.20.1.dist-info → micropython_stubber-1.20.4.dist-info}/RECORD +58 -51
  3. {micropython_stubber-1.20.1.dist-info → micropython_stubber-1.20.4.dist-info}/WHEEL +1 -1
  4. mpflash/README.md +16 -5
  5. mpflash/mpflash/add_firmware.py +98 -0
  6. mpflash/mpflash/ask_input.py +97 -120
  7. mpflash/mpflash/cli_download.py +42 -25
  8. mpflash/mpflash/cli_flash.py +70 -32
  9. mpflash/mpflash/cli_group.py +17 -14
  10. mpflash/mpflash/cli_list.py +39 -3
  11. mpflash/mpflash/cli_main.py +17 -6
  12. mpflash/mpflash/common.py +125 -12
  13. mpflash/mpflash/config.py +12 -0
  14. mpflash/mpflash/connected.py +74 -0
  15. mpflash/mpflash/download.py +132 -51
  16. mpflash/mpflash/downloaded.py +36 -15
  17. mpflash/mpflash/flash.py +2 -2
  18. mpflash/mpflash/flash_esp.py +2 -2
  19. mpflash/mpflash/flash_uf2.py +14 -8
  20. mpflash/mpflash/flash_uf2_boardid.py +2 -1
  21. mpflash/mpflash/flash_uf2_linux.py +5 -16
  22. mpflash/mpflash/flash_uf2_macos.py +37 -0
  23. mpflash/mpflash/flash_uf2_windows.py +5 -5
  24. mpflash/mpflash/list.py +57 -57
  25. mpflash/mpflash/mpboard_id/__init__.py +41 -44
  26. mpflash/mpflash/mpboard_id/add_boards.py +255 -0
  27. mpflash/mpflash/mpboard_id/board.py +37 -0
  28. mpflash/mpflash/mpboard_id/board_id.py +54 -34
  29. mpflash/mpflash/mpboard_id/board_info.zip +0 -0
  30. mpflash/mpflash/mpboard_id/store.py +43 -0
  31. mpflash/mpflash/mpremoteboard/__init__.py +18 -6
  32. mpflash/mpflash/uf2disk.py +12 -0
  33. mpflash/mpflash/vendor/basicgit.py +288 -0
  34. mpflash/mpflash/vendor/dfu.py +1 -0
  35. mpflash/mpflash/vendor/versions.py +7 -3
  36. mpflash/mpflash/worklist.py +71 -48
  37. mpflash/poetry.lock +164 -138
  38. mpflash/pyproject.toml +18 -15
  39. stubber/__init__.py +1 -1
  40. stubber/board/createstubs.py +13 -3
  41. stubber/board/createstubs_db.py +5 -7
  42. stubber/board/createstubs_db_min.py +329 -825
  43. stubber/board/createstubs_db_mpy.mpy +0 -0
  44. stubber/board/createstubs_mem.py +6 -7
  45. stubber/board/createstubs_mem_min.py +304 -765
  46. stubber/board/createstubs_mem_mpy.mpy +0 -0
  47. stubber/board/createstubs_min.py +293 -975
  48. stubber/board/createstubs_mpy.mpy +0 -0
  49. stubber/board/modulelist.txt +10 -0
  50. stubber/commands/get_core_cmd.py +7 -6
  51. stubber/commands/get_docstubs_cmd.py +8 -3
  52. stubber/commands/get_frozen_cmd.py +5 -2
  53. stubber/publish/publish.py +18 -7
  54. stubber/update_module_list.py +2 -24
  55. stubber/utils/makeversionhdr.py +3 -2
  56. stubber/utils/versions.py +2 -1
  57. mpflash/mpflash/mpboard_id/board_info.csv +0 -2213
  58. mpflash/mpflash/mpboard_id/board_info.json +0 -19910
  59. {micropython_stubber-1.20.1.dist-info → micropython_stubber-1.20.4.dist-info}/LICENSE +0 -0
  60. {micropython_stubber-1.20.1.dist-info → micropython_stubber-1.20.4.dist-info}/entry_points.txt +0 -0
@@ -3,13 +3,12 @@ from typing import Dict, List, Optional, Tuple
3
3
 
4
4
  from loguru import logger as log
5
5
 
6
- from mpflash.common import FWInfo
6
+ from mpflash.common import FWInfo, filtered_comports
7
7
  from mpflash.errors import MPFlashError
8
8
 
9
- from .config import config
10
9
  from .downloaded import find_downloaded_firmware
11
10
  from .list import show_mcus
12
- from .mpboard_id import find_stored_board
11
+ from .mpboard_id import find_known_board
13
12
  from .mpremoteboard import MPRemoteBoard
14
13
 
15
14
  # #########################################################################################################
@@ -60,14 +59,53 @@ def auto_update(
60
59
 
61
60
  # just use the last firmware
62
61
  fw_info = board_firmwares[-1]
63
- log.info(f"Found {target_version} firmware {fw_info['filename']} for {mcu.board} on {mcu.serialport}.")
62
+ log.info(f"Found {target_version} firmware {fw_info.filename} for {mcu.board} on {mcu.serialport}.")
64
63
  wl.append((mcu, fw_info))
65
64
  return wl
66
65
 
67
66
 
67
+ def manual_worklist(
68
+ serial: str,
69
+ *,
70
+ board_id: str,
71
+ version: str,
72
+ fw_folder: Path,
73
+ ) -> WorkList:
74
+ """Create a worklist for a single board specified manually.
75
+
76
+ Args:
77
+ serial (str): Serial port of the board
78
+ board (str): Board_ID
79
+ version (str): Firmware version
80
+ fw_folder (Path): Path to the firmware folder
81
+
82
+ Returns:
83
+ WorkList: List of boards and firmware information to update
84
+ """
85
+ log.trace(f"Manual updating {serial} to {board_id} {version}")
86
+ mcu = MPRemoteBoard(serial)
87
+ # Lookup the matching port and cpu in board_info based in the board name
88
+ try:
89
+ info = find_known_board(board_id)
90
+ mcu.port = info.port
91
+ # need the CPU type for the esptool
92
+ mcu.cpu = info.cpu
93
+ except (LookupError, MPFlashError) as e:
94
+ log.error(f"Board {board_id} not found in board_info.zip")
95
+ log.exception(e)
96
+ return []
97
+ mcu.board = board_id
98
+ firmwares = find_downloaded_firmware(fw_folder=fw_folder, board_id=board_id, version=version, port=mcu.port)
99
+ if not firmwares:
100
+ log.error(f"No firmware found for {mcu.port} {board_id} version {version}")
101
+ return []
102
+ # use the most recent matching firmware
103
+ return [(mcu, firmwares[-1])] # type: ignore
104
+
105
+
68
106
  def single_auto_worklist(
107
+ serial: str,
69
108
  *,
70
- serial_port: str,
71
109
  version: str,
72
110
  fw_folder: Path,
73
111
  ) -> WorkList:
@@ -81,13 +119,16 @@ def single_auto_worklist(
81
119
  Returns:
82
120
  WorkList: List of boards and firmware information to update
83
121
  """
84
- conn_boards = [MPRemoteBoard(serial_port)]
122
+ log.trace(f"Auto updating {serial} to {version}")
123
+ conn_boards = [MPRemoteBoard(serial)]
85
124
  todo = auto_update(conn_boards, version, fw_folder) # type: ignore # List / list
86
125
  show_mcus(conn_boards) # type: ignore
87
126
  return todo
88
127
 
89
128
 
90
- def full_auto_worklist(*, version: str, fw_folder: Path) -> WorkList:
129
+ def full_auto_worklist(
130
+ all_boards: List[MPRemoteBoard], *, include: List[str], ignore: List[str], version: str, fw_folder: Path
131
+ ) -> WorkList:
91
132
  """
92
133
  Create a worklist for all connected micropython boards based on the information retrieved from the board.
93
134
  This allows the firmware version of one or moae boards to be changed without needing to specify the port or board_id manually.
@@ -99,49 +140,31 @@ def full_auto_worklist(*, version: str, fw_folder: Path) -> WorkList:
99
140
  Returns:
100
141
  WorkList: List of boards and firmware information to update
101
142
  """
102
- try:
103
- conn_boards = [
104
- MPRemoteBoard(sp, update=True) for sp in MPRemoteBoard.connected_boards() if sp not in config.ignore_ports
105
- ]
106
- except ConnectionError as e:
107
- log.error(f"Error connecting to boards: {e}")
143
+ log.trace(f"Auto updating all boards to {version}")
144
+ if selected_boards := filter_boards(all_boards, include=include, ignore=ignore):
145
+ return auto_update(selected_boards, version, fw_folder)
146
+ else:
108
147
  return []
109
- return auto_update(conn_boards, version, fw_folder) # type: ignore
110
-
111
-
112
- def manual_worklist(
113
- version: str,
114
- fw_folder: Path,
115
- serial_port: str,
116
- board: str,
117
- # port: str,
118
- ) -> WorkList:
119
- """Create a worklist for a single board specified manually.
120
148
 
121
- Args:
122
- version (str): Firmware version
123
- fw_folder (Path): Path to the firmware folder
124
- serial_port (str): Serial port of the board
125
- board (str): Board name
126
149
 
127
- Returns:
128
- WorkList: List of boards and firmware information to update
129
- """
130
- mcu = MPRemoteBoard(serial_port)
131
- # TODO : Find a way to avoid needing to specify the port
132
- # Lookup the matching port and cpu in board_info based in the board name
150
+ def filter_boards(
151
+ all_boards: List[MPRemoteBoard],
152
+ *,
153
+ include: List[str],
154
+ ignore: List[str],
155
+ ):
133
156
  try:
134
- info = find_stored_board(board)
135
- mcu.port = info["port"]
136
- # need the CPU type for the esptool
137
- mcu.cpu = info["cpu"]
138
- except (LookupError, MPFlashError) as e:
139
- log.error(f"Board {board} not found in board_info.json")
140
- return []
141
- mcu.board = board
142
- firmwares = find_downloaded_firmware(fw_folder=fw_folder, board_id=board, version=version, port=mcu.port)
143
- if not firmwares:
144
- log.error(f"No firmware found for {mcu.port} {board} version {version}")
157
+ comports = [
158
+ p.device
159
+ for p in filtered_comports(
160
+ ignore=ignore,
161
+ include=include,
162
+ bluetooth=False,
163
+ )
164
+ ]
165
+ selected_boards = [b for b in all_boards if b.serialport in comports]
166
+ # [MPRemoteBoard(port.device, update=True) for port in comports]
167
+ except ConnectionError as e:
168
+ log.error(f"Error connecting to boards: {e}")
145
169
  return []
146
- # use the most recent matching firmware
147
- return [(mcu, firmwares[-1])] # type: ignore
170
+ return selected_boards # type: ignore