mpflash 1.0.0__py3-none-any.whl → 1.0.2__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/add_firmware.py +98 -98
- mpflash/ask_input.py +236 -236
- mpflash/basicgit.py +284 -284
- mpflash/bootloader/__init__.py +2 -2
- mpflash/bootloader/activate.py +60 -60
- mpflash/bootloader/detect.py +82 -82
- mpflash/bootloader/manual.py +101 -101
- mpflash/bootloader/micropython.py +12 -12
- mpflash/bootloader/touch1200.py +36 -36
- mpflash/cli_download.py +129 -129
- mpflash/cli_flash.py +224 -216
- mpflash/cli_group.py +111 -111
- mpflash/cli_list.py +87 -87
- mpflash/cli_main.py +39 -39
- mpflash/common.py +210 -166
- mpflash/config.py +44 -44
- mpflash/connected.py +104 -77
- mpflash/download.py +364 -364
- mpflash/downloaded.py +130 -130
- mpflash/errors.py +9 -9
- mpflash/flash/__init__.py +55 -55
- mpflash/flash/esp.py +59 -59
- mpflash/flash/stm32.py +19 -19
- mpflash/flash/stm32_dfu.py +104 -104
- mpflash/flash/uf2/__init__.py +88 -88
- mpflash/flash/uf2/boardid.py +15 -15
- mpflash/flash/uf2/linux.py +136 -130
- mpflash/flash/uf2/macos.py +42 -42
- mpflash/flash/uf2/uf2disk.py +12 -12
- mpflash/flash/uf2/windows.py +43 -43
- mpflash/flash/worklist.py +170 -170
- mpflash/list.py +106 -106
- mpflash/logger.py +41 -41
- mpflash/mpboard_id/__init__.py +93 -93
- mpflash/mpboard_id/add_boards.py +251 -251
- mpflash/mpboard_id/board.py +37 -37
- mpflash/mpboard_id/board_id.py +86 -86
- mpflash/mpboard_id/store.py +43 -43
- mpflash/mpremoteboard/__init__.py +266 -266
- mpflash/mpremoteboard/mpy_fw_info.py +141 -141
- mpflash/mpremoteboard/runner.py +140 -140
- mpflash/vendor/click_aliases.py +91 -91
- mpflash/vendor/dfu.py +165 -165
- mpflash/vendor/pydfu.py +605 -605
- mpflash/vendor/readme.md +2 -2
- mpflash/versions.py +135 -135
- {mpflash-1.0.0.dist-info → mpflash-1.0.2.dist-info}/LICENSE +20 -20
- {mpflash-1.0.0.dist-info → mpflash-1.0.2.dist-info}/METADATA +1 -1
- mpflash-1.0.2.dist-info/RECORD +53 -0
- mpflash-1.0.0.dist-info/RECORD +0 -53
- {mpflash-1.0.0.dist-info → mpflash-1.0.2.dist-info}/WHEEL +0 -0
- {mpflash-1.0.0.dist-info → mpflash-1.0.2.dist-info}/entry_points.txt +0 -0
mpflash/mpboard_id/__init__.py
CHANGED
@@ -1,93 +1,93 @@
|
|
1
|
-
"""
|
2
|
-
Access to the micropython port and board information that is stored in the board_info.json file
|
3
|
-
that is included in the module.
|
4
|
-
|
5
|
-
"""
|
6
|
-
|
7
|
-
from functools import lru_cache
|
8
|
-
from typing import List, Optional, Tuple
|
9
|
-
|
10
|
-
from mpflash.errors import MPFlashError
|
11
|
-
from mpflash.mpboard_id.board import Board
|
12
|
-
from mpflash.mpboard_id.store import read_known_boardinfo
|
13
|
-
from mpflash.versions import clean_version
|
14
|
-
|
15
|
-
# KNOWN ports and boards are sourced from the micropython repo,
|
16
|
-
# this info is stored in the board_info.json file
|
17
|
-
|
18
|
-
|
19
|
-
def get_known_ports() -> List[str]:
|
20
|
-
# TODO: Filter for Version
|
21
|
-
mp_boards = read_known_boardinfo()
|
22
|
-
# select the unique ports from info
|
23
|
-
ports = set({board.port for board in mp_boards if board.port})
|
24
|
-
return sorted(list(ports))
|
25
|
-
|
26
|
-
|
27
|
-
def get_known_boards_for_port(port: Optional[str] = "", versions: Optional[List[str]] = None) -> List[Board]:
|
28
|
-
"""
|
29
|
-
Returns a list of boards for the given port and version(s)
|
30
|
-
|
31
|
-
port: The Micropython port to filter for
|
32
|
-
versions: Optional, The Micropython versions to filter for (actual versions required)
|
33
|
-
"""
|
34
|
-
mp_boards = read_known_boardinfo()
|
35
|
-
if versions:
|
36
|
-
preview_or_stable = "preview" in versions or "stable" in versions
|
37
|
-
else:
|
38
|
-
preview_or_stable = False
|
39
|
-
|
40
|
-
# filter for 'preview' as they are not in the board_info.json
|
41
|
-
# instead use stable version
|
42
|
-
versions = versions or []
|
43
|
-
if "preview" in versions:
|
44
|
-
versions.remove("preview")
|
45
|
-
versions.append("stable")
|
46
|
-
if versions:
|
47
|
-
# make sure of the v prefix
|
48
|
-
versions = [clean_version(v) for v in versions]
|
49
|
-
# filter for the version(s)
|
50
|
-
mp_boards = [board for board in mp_boards if board.version in versions]
|
51
|
-
if not mp_boards and preview_or_stable:
|
52
|
-
# nothing found - perhaps there is a newer version for which we do not have the board info yet
|
53
|
-
# use the latest known version from the board info
|
54
|
-
mp_boards = read_known_boardinfo()
|
55
|
-
last_known_version = sorted({b.version for b in mp_boards})[-1]
|
56
|
-
mp_boards = [board for board in mp_boards if board.version == last_known_version]
|
57
|
-
|
58
|
-
# filter for the port
|
59
|
-
if port:
|
60
|
-
mp_boards = [board for board in mp_boards if board.port == port]
|
61
|
-
return mp_boards
|
62
|
-
|
63
|
-
|
64
|
-
def known_stored_boards(port: str, versions: Optional[List[str]] = None) -> List[Tuple[str, str]]:
|
65
|
-
"""
|
66
|
-
Returns a list of tuples with the description and board name for the given port and version
|
67
|
-
|
68
|
-
port : str : The Micropython port to filter for
|
69
|
-
versions : List[str] : The Micropython versions to filter for (actual versions required)
|
70
|
-
"""
|
71
|
-
mp_boards = get_known_boards_for_port(port, versions)
|
72
|
-
|
73
|
-
boards = set({(f"{board.version} {board.description}", board.board_id) for board in mp_boards})
|
74
|
-
return sorted(list(boards))
|
75
|
-
|
76
|
-
|
77
|
-
@lru_cache(maxsize=20)
|
78
|
-
def find_known_board(board_id: str) -> Board:
|
79
|
-
"""Find the board for the given BOARD_ID or 'board description' and return the board info as a Board object"""
|
80
|
-
# FIXME : functional overlap with:
|
81
|
-
# mpboard_id\board_id.py _find_board_id_by_description
|
82
|
-
info = read_known_boardinfo()
|
83
|
-
for board_info in info:
|
84
|
-
if board_id in (board_info.board_id, board_info.description):
|
85
|
-
if not board_info.cpu:
|
86
|
-
# safeguard for older board_info.json files
|
87
|
-
print(f"Board {board_id} has no CPU info, using port as CPU")
|
88
|
-
if " with " in board_info.description:
|
89
|
-
board_info.cpu = board_info.description.split(" with ")[-1]
|
90
|
-
else:
|
91
|
-
board_info.cpu = board_info.port
|
92
|
-
return board_info
|
93
|
-
raise MPFlashError(f"Board {board_id} not found")
|
1
|
+
"""
|
2
|
+
Access to the micropython port and board information that is stored in the board_info.json file
|
3
|
+
that is included in the module.
|
4
|
+
|
5
|
+
"""
|
6
|
+
|
7
|
+
from functools import lru_cache
|
8
|
+
from typing import List, Optional, Tuple
|
9
|
+
|
10
|
+
from mpflash.errors import MPFlashError
|
11
|
+
from mpflash.mpboard_id.board import Board
|
12
|
+
from mpflash.mpboard_id.store import read_known_boardinfo
|
13
|
+
from mpflash.versions import clean_version
|
14
|
+
|
15
|
+
# KNOWN ports and boards are sourced from the micropython repo,
|
16
|
+
# this info is stored in the board_info.json file
|
17
|
+
|
18
|
+
|
19
|
+
def get_known_ports() -> List[str]:
|
20
|
+
# TODO: Filter for Version
|
21
|
+
mp_boards = read_known_boardinfo()
|
22
|
+
# select the unique ports from info
|
23
|
+
ports = set({board.port for board in mp_boards if board.port})
|
24
|
+
return sorted(list(ports))
|
25
|
+
|
26
|
+
|
27
|
+
def get_known_boards_for_port(port: Optional[str] = "", versions: Optional[List[str]] = None) -> List[Board]:
|
28
|
+
"""
|
29
|
+
Returns a list of boards for the given port and version(s)
|
30
|
+
|
31
|
+
port: The Micropython port to filter for
|
32
|
+
versions: Optional, The Micropython versions to filter for (actual versions required)
|
33
|
+
"""
|
34
|
+
mp_boards = read_known_boardinfo()
|
35
|
+
if versions:
|
36
|
+
preview_or_stable = "preview" in versions or "stable" in versions
|
37
|
+
else:
|
38
|
+
preview_or_stable = False
|
39
|
+
|
40
|
+
# filter for 'preview' as they are not in the board_info.json
|
41
|
+
# instead use stable version
|
42
|
+
versions = versions or []
|
43
|
+
if "preview" in versions:
|
44
|
+
versions.remove("preview")
|
45
|
+
versions.append("stable")
|
46
|
+
if versions:
|
47
|
+
# make sure of the v prefix
|
48
|
+
versions = [clean_version(v) for v in versions]
|
49
|
+
# filter for the version(s)
|
50
|
+
mp_boards = [board for board in mp_boards if board.version in versions]
|
51
|
+
if not mp_boards and preview_or_stable:
|
52
|
+
# nothing found - perhaps there is a newer version for which we do not have the board info yet
|
53
|
+
# use the latest known version from the board info
|
54
|
+
mp_boards = read_known_boardinfo()
|
55
|
+
last_known_version = sorted({b.version for b in mp_boards})[-1]
|
56
|
+
mp_boards = [board for board in mp_boards if board.version == last_known_version]
|
57
|
+
|
58
|
+
# filter for the port
|
59
|
+
if port:
|
60
|
+
mp_boards = [board for board in mp_boards if board.port == port]
|
61
|
+
return mp_boards
|
62
|
+
|
63
|
+
|
64
|
+
def known_stored_boards(port: str, versions: Optional[List[str]] = None) -> List[Tuple[str, str]]:
|
65
|
+
"""
|
66
|
+
Returns a list of tuples with the description and board name for the given port and version
|
67
|
+
|
68
|
+
port : str : The Micropython port to filter for
|
69
|
+
versions : List[str] : The Micropython versions to filter for (actual versions required)
|
70
|
+
"""
|
71
|
+
mp_boards = get_known_boards_for_port(port, versions)
|
72
|
+
|
73
|
+
boards = set({(f"{board.version} {board.description}", board.board_id) for board in mp_boards})
|
74
|
+
return sorted(list(boards))
|
75
|
+
|
76
|
+
|
77
|
+
@lru_cache(maxsize=20)
|
78
|
+
def find_known_board(board_id: str) -> Board:
|
79
|
+
"""Find the board for the given BOARD_ID or 'board description' and return the board info as a Board object"""
|
80
|
+
# FIXME : functional overlap with:
|
81
|
+
# mpboard_id\board_id.py _find_board_id_by_description
|
82
|
+
info = read_known_boardinfo()
|
83
|
+
for board_info in info:
|
84
|
+
if board_id in (board_info.board_id, board_info.description):
|
85
|
+
if not board_info.cpu:
|
86
|
+
# safeguard for older board_info.json files
|
87
|
+
print(f"Board {board_id} has no CPU info, using port as CPU")
|
88
|
+
if " with " in board_info.description:
|
89
|
+
board_info.cpu = board_info.description.split(" with ")[-1]
|
90
|
+
else:
|
91
|
+
board_info.cpu = board_info.port
|
92
|
+
return board_info
|
93
|
+
raise MPFlashError(f"Board {board_id} not found")
|