mpflash 0.8.0__py3-none-any.whl → 0.8.1b1__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/download.py CHANGED
@@ -290,5 +290,10 @@ def download(
290
290
  except (PermissionError, FileNotFoundError) as e:
291
291
  log.critical(f"Could not create folder {destination}")
292
292
  raise MPFlashError(f"Could not create folder {destination}") from e
293
+ try:
294
+ result = download_firmwares(destination, ports, boards, versions, force=force, clean=clean)
295
+ except requests.exceptions.RequestException as e:
296
+ log.exception(e)
297
+ raise MPFlashError("Could not connect to micropython.org") from e
293
298
 
294
- return download_firmwares(destination, ports, boards, versions, force=force, clean=clean)
299
+ return result
mpflash/flash_uf2.py CHANGED
@@ -14,7 +14,7 @@ from rich.progress import track
14
14
  from mpflash.mpremoteboard import MPRemoteBoard
15
15
 
16
16
  from .common import PORT_FWTYPES
17
- from .config import config
17
+ from .flash_uf2_boardid import get_board_id
18
18
  from .flash_uf2_linux import dismount_uf2_linux, wait_for_UF2_linux
19
19
  from .flash_uf2_macos import wait_for_UF2_macos
20
20
  from .flash_uf2_windows import wait_for_UF2_windows
@@ -45,11 +45,7 @@ def flash_uf2(mcu: MPRemoteBoard, fw_file: Path, erase: bool) -> Optional[MPRemo
45
45
  destination = wait_for_UF2_windows()
46
46
  elif sys.platform == "darwin":
47
47
  log.warning(f"OS {sys.platform} not tested/supported")
48
- # TODO: test which of the options is best
49
- if "macos_uf2" in config.tests:
50
- destination = wait_for_UF2_macos()
51
- else:
52
- destination = wait_for_UF2_linux()
48
+ destination = wait_for_UF2_macos()
53
49
  else:
54
50
  log.warning(f"OS {sys.platform} not tested/supported")
55
51
  return None
@@ -59,6 +55,8 @@ def flash_uf2(mcu: MPRemoteBoard, fw_file: Path, erase: bool) -> Optional[MPRemo
59
55
  return None
60
56
 
61
57
  log.info("Board is in bootloader mode")
58
+ board_id = get_board_id(destination) # type: ignore
59
+ log.info(f"Board ID: {board_id}")
62
60
  log.info(f"Copying {fw_file} to {destination}.")
63
61
  shutil.copy(fw_file, destination)
64
62
  log.success("Done copying, resetting the board and wait for it to restart")
@@ -6,73 +6,32 @@ from __future__ import annotations
6
6
  import sys
7
7
  import time
8
8
  from pathlib import Path
9
+ from typing import Optional
9
10
 
10
11
  from loguru import logger as log
11
12
  from rich.progress import track
12
13
 
13
14
  from .flash_uf2_boardid import get_board_id
14
- from .uf2disk import UF2Disk
15
15
 
16
16
 
17
- def get_uf2_drives():
18
- """
19
- Get a list of all the (un)mounted UF2 drives
20
- """
21
- if sys.platform != "linux":
22
- log.error("pumount only works on Linux")
23
- return
24
- # import blkinfo only on linux
25
- from blkinfo import BlkDiskInfo
26
-
27
- myblkd = BlkDiskInfo()
28
- filters = {
29
- "tran": "usb",
30
- }
31
- usb_disks = myblkd.get_disks(filters)
32
- for disk in usb_disks:
33
- if disk["fstype"] == "vfat":
34
- uf2_part = disk
35
- # unpartioned usb disk or partition (e.g. /dev/sdb )
36
- # SEEED WIO Terminal is unpartioned
37
- # print( json.dumps(uf2_part, indent=4))
38
- uf2 = UF2Disk()
39
- uf2.device_path = "/dev/" + uf2_part["name"]
40
- uf2.label = uf2_part["label"]
41
- uf2.mountpoint = uf2_part["mountpoint"]
42
- yield uf2
43
- elif disk["type"] == "disk" and disk.get("children") and len(disk.get("children")) > 0:
44
- if disk.get("children")[0]["type"] == "part" and disk.get("children")[0]["fstype"] == "vfat":
45
- uf2_part = disk.get("children")[0]
46
- # print( json.dumps(uf2_part, indent=4))
47
- uf2 = UF2Disk()
48
- uf2.device_path = "/dev/" + uf2_part["name"]
49
- uf2.label = uf2_part["label"]
50
- uf2.mountpoint = uf2_part["mountpoint"]
51
- yield uf2
52
-
53
-
54
- def wait_for_UF2_macos(s_max: int = 10):
55
- destination = ""
56
- wait = 10
57
- uf2_drives = []
58
- # while not destination and wait > 0:
17
+ def wait_for_UF2_macos(s_max: int = 10) -> Optional[Path]:
18
+ """Wait for the MCU to mount as a drive"""
19
+ if s_max < 1:
20
+ s_max = 10
21
+ destination = None
59
22
  for _ in track(
60
23
  range(s_max), description="Waiting for mcu to mount as a drive", transient=True, refresh_per_second=2
61
24
  ):
62
- # log.info(f"Waiting for mcu to mount as a drive : {wait} seconds left")
63
- uf2_drives += list(get_uf2_drives())
64
- for drive in get_uf2_drives():
65
- time.sleep(1)
25
+ # log.info(f"Waiting for mcu to mount as a drive : {n} seconds left")
26
+ vol_mounts = Path("/Volumes").iterdir()
27
+ for vol in vol_mounts:
66
28
  try:
67
- if Path(drive.mountpoint, "INFO_UF2.TXT").exists():
68
- board_id = get_board_id(Path(drive.mountpoint)) # type: ignore
69
- destination = Path(drive.mountpoint)
29
+ if Path(vol, "INFO_UF2.TXT").exists():
30
+ destination = Path(vol)
70
31
  break
71
- except PermissionError:
72
- log.debug(f"Permission error on {drive.mountpoint}")
73
- continue
32
+ except OSError:
33
+ pass
74
34
  if destination:
75
35
  break
76
36
  time.sleep(1)
77
- wait -= 1
78
37
  return destination
@@ -5,25 +5,25 @@ from __future__ import annotations
5
5
 
6
6
  import time
7
7
  from pathlib import Path
8
+ from typing import Optional
8
9
 
9
10
  import psutil
10
11
  from rich.progress import track
11
12
 
12
- from .flash_uf2_boardid import get_board_id
13
13
 
14
14
 
15
- def wait_for_UF2_windows(s_max: int = 10):
15
+
16
+ def wait_for_UF2_windows(s_max: int = 10) -> Optional[Path]:
16
17
  """Wait for the MCU to mount as a drive"""
17
18
  if s_max < 1:
18
19
  s_max = 10
19
- destination = ""
20
+ destination = None
20
21
  for _ in track(range(s_max), description="Waiting for mcu to mount as a drive", transient=True,refresh_per_second=2):
21
22
  # log.info(f"Waiting for mcu to mount as a drive : {n} seconds left")
22
23
  drives = [drive.device for drive in psutil.disk_partitions()]
23
24
  for drive in drives:
24
25
  try:
25
26
  if Path(drive, "INFO_UF2.TXT").exists():
26
- board_id = get_board_id(Path(drive)) # type: ignore
27
27
  destination = Path(drive)
28
28
  break
29
29
  except OSError:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mpflash
3
- Version: 0.8.0
3
+ Version: 0.8.1b1
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
@@ -9,7 +9,7 @@ mpflash/cli_main.py,sha256=yABFFf45TpPMcC1qEVARAWe4EI9zui2pUXjoPms0mq8,1030
9
9
  mpflash/common.py,sha256=kanbO22SQDWb4ASQG8vLF0Z83ahujKPbrsCw3llN5T4,5594
10
10
  mpflash/config.py,sha256=hBc1Hf4XQ0YIoeiPBbannnqDg0C7226Y7Vu8o4jUkBQ,495
11
11
  mpflash/connected.py,sha256=CBG_DJ33OPWAPbX-ICQpL1LcFOhNYpLUSB0Q5v7gi9s,3029
12
- mpflash/download.py,sha256=axAs30i7VZ0jQXY9MVOQB49JH6OCFxy5_zERfysF33I,11421
12
+ mpflash/download.py,sha256=nz7iE-t_3wxyht0iQbMcc6rx8JOnHjbK3D3lQ13bLnU,11612
13
13
  mpflash/downloaded.py,sha256=IYMyx_67paKFSKOg3whgwsWf8IlHaLgpmSlukMT7V9Q,3804
14
14
  mpflash/errors.py,sha256=Q5LR12Wo8iUCg5n_qq4GjdBdBflbvCOdKsRJ5InYRfI,96
15
15
  mpflash/flash.py,sha256=JoskuwaHVYqeG4YW8kgbv26vPFnqDmkTz1VRs-pTRiY,2468
@@ -17,11 +17,11 @@ mpflash/flash_esp.py,sha256=dEc_B7-f1BMUGBMrwIm83ulcCqaS5MlrPAp3FCNgNfk,2311
17
17
  mpflash/flash_stm32.py,sha256=d4BoQl3a9Tchnvn2ZTuq2MpYBB4MTaRukwtEncI95k0,823
18
18
  mpflash/flash_stm32_cube.py,sha256=w7aGWjReeWUKl0Q3ZjXH8BRqNO1Tk9AO7gtRNUg1c9Y,3970
19
19
  mpflash/flash_stm32_dfu.py,sha256=G70EZodWb-aRi507Jxbys-VEwbBGU1oZacow3_nq-d4,2972
20
- mpflash/flash_uf2.py,sha256=FFO2zpKFPdpEDi4aK1-JFsvPi8KEKLXXuOt_lXtI9tk,2508
20
+ mpflash/flash_uf2.py,sha256=2IKgEOnlsB9bILJWHILMKbGo9b39NKazBWp1-T_eKKs,2463
21
21
  mpflash/flash_uf2_boardid.py,sha256=WZKucGu_hJ8ymb236uuZbiR6pD6AA_l4LA-7LwtQhq8,414
22
22
  mpflash/flash_uf2_linux.py,sha256=Oy9V4g7JSuks2hHFeO_OHdBKSGktbqZOtsivuxfl-xg,4055
23
- mpflash/flash_uf2_macos.py,sha256=JButLjccuKlVyArwNkHDGjNMB_9ezyTKlbCWNia-R5Y,2696
24
- mpflash/flash_uf2_windows.py,sha256=94YoO2UIzfyJs4CPJ9sjG_WY26SX8aUPl9mf9R9W5xk,1093
23
+ mpflash/flash_uf2_macos.py,sha256=HGUg2HSw4qalfSP7npLYgos2WlVRxtOVTDcAnBL7qPY,1078
24
+ mpflash/flash_uf2_windows.py,sha256=a-iIGPkwIoUXA7atCz0_uZp-kipSL24P-IE5ka1B1Mk,1025
25
25
  mpflash/list.py,sha256=0TawTkwhjKPPj7nTHoDn8nQ54WOkGRurP1BJVeg956g,2963
26
26
  mpflash/logger.py,sha256=dI_H_a7EOdQJyvoeRHQuYeZuTKYVUS3DUPTLhE9rkdM,1098
27
27
  mpflash/mpboard_id/__init__.py,sha256=QRLVUpeiXeiY3P-im2Bv8zX8xGS_MIqiH-3svuVoWyY,3576
@@ -40,8 +40,8 @@ mpflash/vendor/pydfu.py,sha256=_MdBRo1EeNeKDqFPSTB5tNL1jGSBJgsVeVjE5e7Pb8s,20542
40
40
  mpflash/vendor/readme.md,sha256=iIIZxuLUIGHQ0KODzYVtMezsztvyxCXcNJp_AzwTIPk,86
41
41
  mpflash/vendor/versions.py,sha256=thk1a5wEEhXIQoL0zZ7oooeFyQeSoI00CIUbZF0b3rI,3783
42
42
  mpflash/worklist.py,sha256=MKHDynttVP3lsHSfb7DEqeQ2mRV0da96lD4lIcS_zQY,5962
43
- mpflash-0.8.0.dist-info/entry_points.txt,sha256=Jk_visOhYOsZIcSP2Ms9hKqfKy1iorR-6dYltSoWCpY,52
44
- mpflash-0.8.0.dist-info/LICENSE,sha256=mWpNhsIxWzetYNnTpr4eb3HtgsxGIC8KcYWxXEcxQvE,1077
45
- mpflash-0.8.0.dist-info/METADATA,sha256=soEShJBcun6aKy8U_eGxulIqTWlbPR9mWu6oahyaL1M,15224
46
- mpflash-0.8.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
47
- mpflash-0.8.0.dist-info/RECORD,,
43
+ mpflash-0.8.1b1.dist-info/entry_points.txt,sha256=Jk_visOhYOsZIcSP2Ms9hKqfKy1iorR-6dYltSoWCpY,52
44
+ mpflash-0.8.1b1.dist-info/LICENSE,sha256=mWpNhsIxWzetYNnTpr4eb3HtgsxGIC8KcYWxXEcxQvE,1077
45
+ mpflash-0.8.1b1.dist-info/METADATA,sha256=TT5lfBjX96EPaD70_I__rVhxVhHprFaQszEbpHn5OYA,15226
46
+ mpflash-0.8.1b1.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
47
+ mpflash-0.8.1b1.dist-info/RECORD,,