mpflash 0.6.0__py3-none-any.whl → 0.7.0__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/cli_flash.py CHANGED
@@ -13,7 +13,7 @@ from .cli_group import cli
13
13
  from .cli_list import show_mcus
14
14
  from .config import config
15
15
  from .flash import flash_list
16
- from .worklist import WorkList, full_auto_worklist, manual_worklist, single_auto_worklist
16
+ from .worklist import MPRemoteBoard, WorkList, full_auto_worklist, manual_worklist, single_auto_worklist
17
17
 
18
18
  # #########################################################################################################
19
19
  # CLI
@@ -104,6 +104,11 @@ def cli_flash_board(**kwargs):
104
104
  if not params.boards or params.boards == []:
105
105
  # nothing specified - detect connected boards
106
106
  params.ports, params.boards = connected_ports_boards()
107
+ if params.boards == []:
108
+ # No MicroPython boards detected, but it could be unflashed or not in bootloader mode
109
+ # Ask for serial port and board_id to flash
110
+ params.serial = "?"
111
+ params.boards = ["?"]
107
112
  else:
108
113
  for board_id in params.boards:
109
114
  if board_id == "":
@@ -130,9 +135,9 @@ def cli_flash_board(**kwargs):
130
135
  if len(params.versions) > 1:
131
136
  log.error(f"Only one version can be flashed at a time, not {params.versions}")
132
137
  raise MPFlashError("Only one version can be flashed at a time")
133
- if len(params.boards) > 1:
134
- log.error(f"Only one board can be flashed at a time, not {params.boards}")
135
- raise MPFlashError("Only one board can be flashed at a time")
138
+ # if len(params.boards) > 1:
139
+ # log.error(f"Only one board can be flashed at a time, not {params.boards}")
140
+ # raise MPFlashError("Only one board can be flashed at a time")
136
141
 
137
142
  params.versions = [clean_version(v) for v in params.versions]
138
143
  worklist: WorkList = []
mpflash/cli_group.py CHANGED
@@ -11,7 +11,7 @@ from .logger import make_quiet, set_loglevel
11
11
 
12
12
  def cb_verbose(ctx, param, value):
13
13
  """Callback to set the log level to DEBUG if verbose is set"""
14
- if value:
14
+ if value and not config.quiet:
15
15
  set_loglevel("DEBUG")
16
16
  config.verbose = True
17
17
  else:
mpflash/flash_uf2.py CHANGED
@@ -56,6 +56,6 @@ def flash_uf2(mcu: MPRemoteBoard, fw_file: Path, erase: bool) -> Optional[MPRemo
56
56
  log.success("Done copying, resetting the board and wait for it to restart")
57
57
  if sys.platform in ["linux", "darwin"]:
58
58
  dismount_uf2()
59
- for _ in track(range(5 + 2)):
59
+ for _ in track(range(5 + 2), description="Waiting for the board to restart", transient=True):
60
60
  time.sleep(1) # 5 secs to short on linux
61
61
  return mcu
mpflash/list.py CHANGED
@@ -1,14 +1,18 @@
1
1
  from typing import List
2
2
 
3
3
  from rich import print
4
- from rich.progress import track
5
- from rich.table import Table
4
+ from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn, TimeElapsedColumn, track
5
+ from rich.table import Column, Table
6
6
 
7
7
  from mpflash.mpremoteboard import MPRemoteBoard
8
8
 
9
9
  from .config import config
10
10
  from .logger import console
11
11
 
12
+ rp_spinner = SpinnerColumn(finished_text="✅")
13
+ rp_text = TextColumn("{task.description} {task.fields[device]}", table_column=Column())
14
+ rp_bar = BarColumn(bar_width=None, table_column=Column())
15
+
12
16
 
13
17
  def list_mcus(bluetooth: bool = False):
14
18
  """
@@ -21,12 +25,24 @@ def list_mcus(bluetooth: bool = False):
21
25
  """
22
26
  conn_mcus = [MPRemoteBoard(sp) for sp in MPRemoteBoard.connected_boards(bluetooth) if sp not in config.ignore_ports]
23
27
 
24
- for mcu in track(conn_mcus, description="Getting board info", transient=True, update_period=0.1):
28
+ # a lot of boilerplate to show a progress bar with the comport currenlty scanned
29
+ with Progress(rp_spinner, rp_text, rp_bar, TimeElapsedColumn()) as progress:
30
+ tsk_scan = progress.add_task("[green]Scanning", visible=False, total=None)
31
+ progress.tasks[tsk_scan].fields["device"] = "..."
32
+ progress.tasks[tsk_scan].visible = True
33
+ progress.start_task(tsk_scan)
25
34
  try:
26
- mcu.get_mcu_info()
27
- except ConnectionError as e:
28
- print(f"Error: {e}")
29
- continue
35
+ for mcu in conn_mcus:
36
+ progress.update(tsk_scan, device=mcu.serialport.replace("/dev/", ""))
37
+ try:
38
+ mcu.get_mcu_info()
39
+ except ConnectionError as e:
40
+ print(f"Error: {e}")
41
+ continue
42
+ finally:
43
+ # transient
44
+ progress.stop_task(tsk_scan)
45
+ progress.tasks[tsk_scan].visible = False
30
46
  return conn_mcus
31
47
 
32
48
 
@@ -38,11 +54,10 @@ def show_mcus(
38
54
  """Show the list of connected boards in a nice table"""
39
55
  table = Table(
40
56
  title=title,
41
- title_style="bold",
42
- header_style="bold blue",
57
+ title_style="magenta",
58
+ header_style="bold magenta",
43
59
  collapse_padding=True,
44
60
  width=110,
45
- row_styles=["blue", "yellow"],
46
61
  )
47
62
  table.add_column("Serial", overflow="fold")
48
63
  table.add_column("Family")
@@ -59,11 +74,12 @@ def show_mcus(
59
74
  mcu.get_mcu_info()
60
75
  except ConnectionError:
61
76
  continue
77
+ description = f"[italic bright_cyan]{mcu.description}" if mcu.description else ""
62
78
  table.add_row(
63
79
  mcu.serialport.replace("/dev/", ""),
64
80
  mcu.family,
65
81
  mcu.port,
66
- f"{mcu.board}\n{mcu.description}".strip(),
82
+ f"{mcu.board}\n{description}".strip(),
67
83
  # mcu.variant,
68
84
  mcu.cpu,
69
85
  mcu.version,
@@ -65,8 +65,9 @@ class MPRemoteBoard:
65
65
 
66
66
  @staticmethod
67
67
  def connected_boards(bluetooth: bool = False) -> List[str]:
68
+ # TODO: rename to connected_comports
68
69
  """
69
- Get a list of connected boards.
70
+ Get a list of connected comports.
70
71
 
71
72
  Parameters:
72
73
  - bluetooth (bool): Whether to include Bluetooth ports. Default is False.
@@ -74,14 +75,14 @@ class MPRemoteBoard:
74
75
  Returns:
75
76
  - List[str]: A list of connected board ports.
76
77
  """
77
- ports = serial.tools.list_ports.comports()
78
+ comports = serial.tools.list_ports.comports()
78
79
 
79
80
  if not bluetooth:
80
81
  # filter out bluetooth ports
81
- ports = [p for p in ports if "bluetooth" not in p.description.lower()]
82
- ports = [p for p in ports if "BTHENUM" not in p.hwid]
82
+ comports = [p for p in comports if "bluetooth" not in p.description.lower()]
83
+ comports = [p for p in comports if "BTHENUM" not in p.hwid]
83
84
 
84
- return sorted([p.device for p in ports])
85
+ return sorted([p.device for p in comports])
85
86
 
86
87
  @retry(stop=stop_after_attempt(RETRIES), wait=wait_fixed(1), reraise=True) # type: ignore ## retry_error_cls=ConnectionError,
87
88
  def get_mcu_info(self, timeout: int = 2):
mpflash/worklist.py CHANGED
@@ -24,7 +24,7 @@ def auto_update(
24
24
  *,
25
25
  selector: Optional[Dict[str, str]] = None,
26
26
  ) -> WorkList:
27
- """Builds a list of boards to update based on the connected boards and the firmware available
27
+ """Builds a list of boards to update based on the connected boards and the firmwares available locally in the firmware folder.
28
28
 
29
29
  Args:
30
30
  conn_boards (List[MPRemoteBoard]): List of connected boards
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mpflash
3
- Version: 0.6.0
3
+ Version: 0.7.0
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
@@ -1,8 +1,8 @@
1
1
  mpflash/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  mpflash/ask_input.py,sha256=NGjCcOx49gW8xuDZK1BQXNOMPy7fUQ5pQamasez1wHI,7793
3
3
  mpflash/cli_download.py,sha256=9Rxwo-j7h9_rwMeAgITmfkdiNVi-Wunr1vpx2VjjUNM,3090
4
- mpflash/cli_flash.py,sha256=bp2AXHYqusVQbIOt12gqkbC4OoVMVV2gsY1fI-Js63M,5482
5
- mpflash/cli_group.py,sha256=hdyFrxkA_ye5r5bAsOnPr99KV2pfzgDoNXGPjTvEpW0,1946
4
+ mpflash/cli_flash.py,sha256=Hld8SGNTJWKB0CTjfG8wGZh8RaC7CtVxhw4--LKTkig,5760
5
+ mpflash/cli_group.py,sha256=nL3H06PHm_XUDlMuRyjgmTYeLnkrLa9mKDdahYw-KRo,1967
6
6
  mpflash/cli_list.py,sha256=uxTRPdjFWv5ev4E_pz1JYv8DSFLOtZvTKmVmCiRpEC4,1005
7
7
  mpflash/cli_main.py,sha256=VxIpmvk3-2Sr1uB1AMT5bRa0TlrbY28ZaYd6NGZnEe0,632
8
8
  mpflash/common.py,sha256=lucFGMLl03qz-5Ic2XVv4g5XVt6hloUU6N5v0tSaUYE,1049
@@ -15,26 +15,26 @@ mpflash/flash_esp.py,sha256=TjBOk2y1eLrcE8T3iYGypsiskPX7BFNfxYmCuUo_3v4,2316
15
15
  mpflash/flash_stm32.py,sha256=d4BoQl3a9Tchnvn2ZTuq2MpYBB4MTaRukwtEncI95k0,823
16
16
  mpflash/flash_stm32_cube.py,sha256=w7aGWjReeWUKl0Q3ZjXH8BRqNO1Tk9AO7gtRNUg1c9Y,3970
17
17
  mpflash/flash_stm32_dfu.py,sha256=G70EZodWb-aRi507Jxbys-VEwbBGU1oZacow3_nq-d4,2972
18
- mpflash/flash_uf2.py,sha256=nTbp8MbSZeNVPWPPsQxN1ppTtBGESXMfwZ_qL4Bwkv0,2029
18
+ mpflash/flash_uf2.py,sha256=KvNPk1zDwQexJfPI5MlIoR7zTD0u-pQQwSHuFQjuMXg,2093
19
19
  mpflash/flash_uf2_boardid.py,sha256=WZKucGu_hJ8ymb236uuZbiR6pD6AA_l4LA-7LwtQhq8,414
20
20
  mpflash/flash_uf2_linux.py,sha256=LAGkzTImVq-wKo7LGUNlwkUHv1L4rGO7igR5dwxY07o,4298
21
21
  mpflash/flash_uf2_windows.py,sha256=dcmA-koavH7duOuNwI0n2aDDbhF1_5ZZ-mXFAXgj8z4,1072
22
- mpflash/list.py,sha256=7-yW_J-TDGMvRrRfz7clJseiMy4uEgcwyhOaiw5fj1w,2248
22
+ mpflash/list.py,sha256=G35Pjc8Aw3qqY4dCi-0QtRRZEiJF5EPwyuU7Jx5S63Q,3186
23
23
  mpflash/logger.py,sha256=dI_H_a7EOdQJyvoeRHQuYeZuTKYVUS3DUPTLhE9rkdM,1098
24
24
  mpflash/mpboard_id/__init__.py,sha256=JYGe7VwpBV4ig2M9a6vJUQrMtgdNjZKHt_Z5N13Ycrs,3509
25
25
  mpflash/mpboard_id/board_id.py,sha256=NjKkIUv3sw6X60qy--mieQWrle3WNKw5NwAepMenTHI,2230
26
26
  mpflash/mpboard_id/board_info.csv,sha256=KPWDo-zHWfrPGQn9oInsDH-5IdCzhBCs6K_YAmqqSpQ,96983
27
27
  mpflash/mpboard_id/board_info.json,sha256=JtVyOMIO1O7vLKzJ0hyXQ4JSxXiQBJyay2hjdNLnZM0,674442
28
- mpflash/mpremoteboard/__init__.py,sha256=NSp71Qynz3hYqLLy0foVqdkURbNxfjUjiQBmaxKFF64,6951
28
+ mpflash/mpremoteboard/__init__.py,sha256=DxlO_7LiyWDz5hNRI77fzp3sI3fZQ9Sd23dnGLx4Zl0,7017
29
29
  mpflash/mpremoteboard/mpy_fw_info.py,sha256=6AQbN3jtQgllqWQYl4e-63KeEtV08EXk8_JnM6XBkvo,4554
30
30
  mpflash/mpremoteboard/runner.py,sha256=H3W_xGJvjz7TLtlkDQrCLibgegRWGfsaBOABNbAfP_U,4783
31
31
  mpflash/vendor/dfu.py,sha256=oK_MRSOyDJrUuS6D24IMIsfL7oLcrvUq0yp_h4WIY2U,5739
32
32
  mpflash/vendor/pydfu.py,sha256=_MdBRo1EeNeKDqFPSTB5tNL1jGSBJgsVeVjE5e7Pb8s,20542
33
33
  mpflash/vendor/readme.md,sha256=iIIZxuLUIGHQ0KODzYVtMezsztvyxCXcNJp_AzwTIPk,86
34
34
  mpflash/vendor/versions.py,sha256=ooRZjeeYepQHwp12hMu2m0p8nZXQ5s942w5mGkKmgeI,3629
35
- mpflash/worklist.py,sha256=TGVFugEyWn83WKr0wahBBimcfsHMWGo8_QTu4g3ao-0,5266
36
- mpflash-0.6.0.dist-info/entry_points.txt,sha256=Jk_visOhYOsZIcSP2Ms9hKqfKy1iorR-6dYltSoWCpY,52
37
- mpflash-0.6.0.dist-info/LICENSE,sha256=mWpNhsIxWzetYNnTpr4eb3HtgsxGIC8KcYWxXEcxQvE,1077
38
- mpflash-0.6.0.dist-info/METADATA,sha256=wlr-kNnhL5NmvIbM9LIquNRymrf_sPsLcv7MQYx0-Ic,13778
39
- mpflash-0.6.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
40
- mpflash-0.6.0.dist-info/RECORD,,
35
+ mpflash/worklist.py,sha256=qZsqF3Lf5Bl7QQ31ZLVHewP6WC8fmwQPMbyNgbG7LB4,5299
36
+ mpflash-0.7.0.dist-info/entry_points.txt,sha256=Jk_visOhYOsZIcSP2Ms9hKqfKy1iorR-6dYltSoWCpY,52
37
+ mpflash-0.7.0.dist-info/LICENSE,sha256=mWpNhsIxWzetYNnTpr4eb3HtgsxGIC8KcYWxXEcxQvE,1077
38
+ mpflash-0.7.0.dist-info/METADATA,sha256=7U3zE54LqRhVIqVljefb5h-WjgjnTvLtm-EY6mTizTY,13778
39
+ mpflash-0.7.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
40
+ mpflash-0.7.0.dist-info/RECORD,,