mpflash 0.8.5__py3-none-any.whl → 0.8.7__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 (51) hide show
  1. mpflash/add_firmware.py +98 -98
  2. mpflash/ask_input.py +236 -236
  3. mpflash/bootloader/__init__.py +37 -36
  4. mpflash/bootloader/manual.py +102 -102
  5. mpflash/bootloader/micropython.py +10 -10
  6. mpflash/bootloader/touch1200.py +45 -45
  7. mpflash/cli_download.py +129 -129
  8. mpflash/cli_flash.py +219 -219
  9. mpflash/cli_group.py +98 -98
  10. mpflash/cli_list.py +81 -81
  11. mpflash/cli_main.py +41 -41
  12. mpflash/common.py +164 -164
  13. mpflash/config.py +47 -47
  14. mpflash/connected.py +74 -74
  15. mpflash/download.py +360 -360
  16. mpflash/downloaded.py +129 -129
  17. mpflash/errors.py +9 -9
  18. mpflash/flash.py +52 -52
  19. mpflash/flash_esp.py +59 -59
  20. mpflash/flash_stm32.py +24 -24
  21. mpflash/flash_stm32_cube.py +111 -111
  22. mpflash/flash_stm32_dfu.py +101 -101
  23. mpflash/flash_uf2.py +67 -67
  24. mpflash/flash_uf2_boardid.py +15 -15
  25. mpflash/flash_uf2_linux.py +123 -123
  26. mpflash/flash_uf2_macos.py +34 -34
  27. mpflash/flash_uf2_windows.py +34 -34
  28. mpflash/list.py +89 -89
  29. mpflash/logger.py +41 -41
  30. mpflash/mpboard_id/__init__.py +93 -93
  31. mpflash/mpboard_id/add_boards.py +255 -255
  32. mpflash/mpboard_id/board.py +37 -37
  33. mpflash/mpboard_id/board_id.py +86 -86
  34. mpflash/mpboard_id/store.py +43 -43
  35. mpflash/mpremoteboard/__init__.py +221 -221
  36. mpflash/mpremoteboard/mpy_fw_info.py +141 -141
  37. mpflash/mpremoteboard/runner.py +140 -140
  38. mpflash/uf2disk.py +12 -12
  39. mpflash/vendor/basicgit.py +288 -288
  40. mpflash/vendor/click_aliases.py +91 -91
  41. mpflash/vendor/dfu.py +165 -165
  42. mpflash/vendor/pydfu.py +605 -605
  43. mpflash/vendor/readme.md +2 -2
  44. mpflash/vendor/versions.py +119 -117
  45. mpflash/worklist.py +170 -170
  46. {mpflash-0.8.5.dist-info → mpflash-0.8.7.dist-info}/LICENSE +20 -20
  47. {mpflash-0.8.5.dist-info → mpflash-0.8.7.dist-info}/METADATA +1 -1
  48. mpflash-0.8.7.dist-info/RECORD +52 -0
  49. mpflash-0.8.5.dist-info/RECORD +0 -52
  50. {mpflash-0.8.5.dist-info → mpflash-0.8.7.dist-info}/WHEEL +0 -0
  51. {mpflash-0.8.5.dist-info → mpflash-0.8.7.dist-info}/entry_points.txt +0 -0
mpflash/connected.py CHANGED
@@ -1,74 +1,74 @@
1
- from typing import List, Tuple
2
-
3
- from rich import print
4
- from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn
5
- from rich.table import Column
6
-
7
- from mpflash.mpremoteboard import MPRemoteBoard
8
-
9
- from .common import filtered_comports
10
-
11
-
12
- def connected_ports_boards(
13
- *, include: List[str], ignore: List[str]
14
- ) -> Tuple[List[str], List[str], List[MPRemoteBoard]]:
15
- """
16
- Returns a tuple containing lists of unique ports and boards from the connected MCUs.
17
- Boards that are physically connected, but give no tangible response are ignored.
18
-
19
- Returns:
20
- A tuple containing three lists:
21
- - A list of unique ports where MCUs are connected.
22
- - A list of unique board names of the connected MCUs.
23
- - A list of MPRemoteBoard instances of the connected MCUs.
24
- """
25
- mpr_boards = [b for b in list_mcus(include=include, ignore=ignore) if b.connected]
26
- ports = list({b.port for b in mpr_boards})
27
- boards = list({b.board for b in mpr_boards})
28
- return (ports, boards, mpr_boards)
29
-
30
-
31
- # #########################################################################################################
32
- rp_spinner = SpinnerColumn(finished_text="✅")
33
- rp_text = TextColumn("{task.description} {task.fields[device]}", table_column=Column())
34
- rp_bar = BarColumn(bar_width=None, table_column=Column())
35
-
36
-
37
- def list_mcus(*, ignore: List[str], include: List[str], bluetooth: bool = False):
38
- """
39
- Retrieves information about connected microcontroller boards.
40
-
41
- Returns:
42
- List[MPRemoteBoard]: A list of MPRemoteBoard instances with board information.
43
- Raises:
44
- ConnectionError: If there is an error connecting to a board.
45
- """
46
- # conn_mcus = [MPRemoteBoard(sp) for sp in MPRemoteBoard.connected_boards(bluetooth) if sp not in config.ignore_ports]
47
-
48
- comports = filtered_comports(
49
- ignore=ignore,
50
- include=include,
51
- bluetooth=bluetooth,
52
- )
53
- conn_mcus = [MPRemoteBoard(c.device) for c in comports]
54
-
55
- # a lot of boilerplate to show a progress bar with the comport currently scanned
56
- # low update rate to facilitate screen readers/narration
57
- with Progress(rp_spinner, rp_text, rp_bar, TimeElapsedColumn(), refresh_per_second=2) as progress:
58
- tsk_scan = progress.add_task("[green]Scanning", visible=False, total=None)
59
- progress.tasks[tsk_scan].fields["device"] = "..."
60
- progress.tasks[tsk_scan].visible = True
61
- progress.start_task(tsk_scan)
62
- try:
63
- for mcu in conn_mcus:
64
- progress.update(tsk_scan, device=mcu.serialport.replace("/dev/", ""))
65
- try:
66
- mcu.get_mcu_info()
67
- except ConnectionError as e:
68
- print(f"Error: {e}")
69
- continue
70
- finally:
71
- # transient
72
- progress.stop_task(tsk_scan)
73
- progress.tasks[tsk_scan].visible = False
74
- return conn_mcus
1
+ from typing import List, Tuple
2
+
3
+ from rich import print
4
+ from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn
5
+ from rich.table import Column
6
+
7
+ from mpflash.mpremoteboard import MPRemoteBoard
8
+
9
+ from .common import filtered_comports
10
+
11
+
12
+ def connected_ports_boards(
13
+ *, include: List[str], ignore: List[str]
14
+ ) -> Tuple[List[str], List[str], List[MPRemoteBoard]]:
15
+ """
16
+ Returns a tuple containing lists of unique ports and boards from the connected MCUs.
17
+ Boards that are physically connected, but give no tangible response are ignored.
18
+
19
+ Returns:
20
+ A tuple containing three lists:
21
+ - A list of unique ports where MCUs are connected.
22
+ - A list of unique board names of the connected MCUs.
23
+ - A list of MPRemoteBoard instances of the connected MCUs.
24
+ """
25
+ mpr_boards = [b for b in list_mcus(include=include, ignore=ignore) if b.connected]
26
+ ports = list({b.port for b in mpr_boards})
27
+ boards = list({b.board for b in mpr_boards})
28
+ return (ports, boards, mpr_boards)
29
+
30
+
31
+ # #########################################################################################################
32
+ rp_spinner = SpinnerColumn(finished_text="✅")
33
+ rp_text = TextColumn("{task.description} {task.fields[device]}", table_column=Column())
34
+ rp_bar = BarColumn(bar_width=None, table_column=Column())
35
+
36
+
37
+ def list_mcus(*, ignore: List[str], include: List[str], bluetooth: bool = False):
38
+ """
39
+ Retrieves information about connected microcontroller boards.
40
+
41
+ Returns:
42
+ List[MPRemoteBoard]: A list of MPRemoteBoard instances with board information.
43
+ Raises:
44
+ ConnectionError: If there is an error connecting to a board.
45
+ """
46
+ # conn_mcus = [MPRemoteBoard(sp) for sp in MPRemoteBoard.connected_boards(bluetooth) if sp not in config.ignore_ports]
47
+
48
+ comports = filtered_comports(
49
+ ignore=ignore,
50
+ include=include,
51
+ bluetooth=bluetooth,
52
+ )
53
+ conn_mcus = [MPRemoteBoard(c.device) for c in comports]
54
+
55
+ # a lot of boilerplate to show a progress bar with the comport currently scanned
56
+ # low update rate to facilitate screen readers/narration
57
+ with Progress(rp_spinner, rp_text, rp_bar, TimeElapsedColumn(), refresh_per_second=2) as progress:
58
+ tsk_scan = progress.add_task("[green]Scanning", visible=False, total=None)
59
+ progress.tasks[tsk_scan].fields["device"] = "..."
60
+ progress.tasks[tsk_scan].visible = True
61
+ progress.start_task(tsk_scan)
62
+ try:
63
+ for mcu in conn_mcus:
64
+ progress.update(tsk_scan, device=mcu.serialport.replace("/dev/", ""))
65
+ try:
66
+ mcu.get_mcu_info()
67
+ except ConnectionError as e:
68
+ print(f"Error: {e}")
69
+ continue
70
+ finally:
71
+ # transient
72
+ progress.stop_task(tsk_scan)
73
+ progress.tasks[tsk_scan].visible = False
74
+ return conn_mcus