mpflash 0.8.0__tar.gz → 0.8.1b1__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 (47) hide show
  1. {mpflash-0.8.0 → mpflash-0.8.1b1}/PKG-INFO +1 -1
  2. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/download.py +6 -1
  3. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/flash_uf2.py +4 -6
  4. mpflash-0.8.1b1/mpflash/flash_uf2_macos.py +37 -0
  5. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/flash_uf2_windows.py +4 -4
  6. {mpflash-0.8.0 → mpflash-0.8.1b1}/pyproject.toml +1 -1
  7. mpflash-0.8.0/mpflash/flash_uf2_macos.py +0 -78
  8. {mpflash-0.8.0 → mpflash-0.8.1b1}/LICENSE +0 -0
  9. {mpflash-0.8.0 → mpflash-0.8.1b1}/README.md +0 -0
  10. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/__init__.py +0 -0
  11. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/add_firmware.py +0 -0
  12. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/ask_input.py +0 -0
  13. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/cli_download.py +0 -0
  14. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/cli_flash.py +0 -0
  15. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/cli_group.py +0 -0
  16. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/cli_list.py +0 -0
  17. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/cli_main.py +0 -0
  18. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/common.py +0 -0
  19. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/config.py +0 -0
  20. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/connected.py +0 -0
  21. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/downloaded.py +0 -0
  22. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/errors.py +0 -0
  23. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/flash.py +0 -0
  24. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/flash_esp.py +0 -0
  25. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/flash_stm32.py +0 -0
  26. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/flash_stm32_cube.py +0 -0
  27. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/flash_stm32_dfu.py +0 -0
  28. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/flash_uf2_boardid.py +0 -0
  29. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/flash_uf2_linux.py +0 -0
  30. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/list.py +0 -0
  31. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/logger.py +0 -0
  32. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/mpboard_id/__init__.py +0 -0
  33. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/mpboard_id/add_boards.py +0 -0
  34. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/mpboard_id/board.py +0 -0
  35. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/mpboard_id/board_id.py +0 -0
  36. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/mpboard_id/board_info.zip +0 -0
  37. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/mpboard_id/store.py +0 -0
  38. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/mpremoteboard/__init__.py +0 -0
  39. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/mpremoteboard/mpy_fw_info.py +0 -0
  40. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/mpremoteboard/runner.py +0 -0
  41. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/uf2disk.py +0 -0
  42. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/vendor/basicgit.py +0 -0
  43. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/vendor/dfu.py +0 -0
  44. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/vendor/pydfu.py +0 -0
  45. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/vendor/readme.md +0 -0
  46. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/vendor/versions.py +0 -0
  47. {mpflash-0.8.0 → mpflash-0.8.1b1}/mpflash/worklist.py +0 -0
@@ -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
@@ -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
@@ -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")
@@ -0,0 +1,37 @@
1
+ """ Flashing UF2 based MCU on macos"""
2
+
3
+ # sourcery skip: snake-case-functions
4
+ from __future__ import annotations
5
+
6
+ import sys
7
+ import time
8
+ from pathlib import Path
9
+ from typing import Optional
10
+
11
+ from loguru import logger as log
12
+ from rich.progress import track
13
+
14
+ from .flash_uf2_boardid import get_board_id
15
+
16
+
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
22
+ for _ in track(
23
+ range(s_max), description="Waiting for mcu to mount as a drive", transient=True, refresh_per_second=2
24
+ ):
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:
28
+ try:
29
+ if Path(vol, "INFO_UF2.TXT").exists():
30
+ destination = Path(vol)
31
+ break
32
+ except OSError:
33
+ pass
34
+ if destination:
35
+ break
36
+ time.sleep(1)
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
  [tool.poetry]
2
2
  name = "mpflash"
3
- version = "0.8.0"
3
+ version = "0.8.1b1"
4
4
  description = "Flash and download tool for MicroPython firmwares"
5
5
  authors = ["Jos Verlinde <jos_verlinde@hotmail.com>"]
6
6
  license = "MIT"
@@ -1,78 +0,0 @@
1
- """ Flashing UF2 based MCU on macos"""
2
-
3
- # sourcery skip: snake-case-functions
4
- from __future__ import annotations
5
-
6
- import sys
7
- import time
8
- from pathlib import Path
9
-
10
- from loguru import logger as log
11
- from rich.progress import track
12
-
13
- from .flash_uf2_boardid import get_board_id
14
- from .uf2disk import UF2Disk
15
-
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:
59
- for _ in track(
60
- range(s_max), description="Waiting for mcu to mount as a drive", transient=True, refresh_per_second=2
61
- ):
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)
66
- 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)
70
- break
71
- except PermissionError:
72
- log.debug(f"Permission error on {drive.mountpoint}")
73
- continue
74
- if destination:
75
- break
76
- time.sleep(1)
77
- wait -= 1
78
- return destination
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