mpflash 1.24.1__tar.gz → 1.24.2__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 (53) hide show
  1. {mpflash-1.24.1 → mpflash-1.24.2}/PKG-INFO +1 -1
  2. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/basicgit.py +27 -7
  3. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/common.py +2 -5
  4. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/mpboard_id/__init__.py +9 -4
  5. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/mpboard_id/board_id.py +10 -6
  6. mpflash-1.24.2/mpflash/mpboard_id/board_info.zip +0 -0
  7. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/versions.py +3 -3
  8. {mpflash-1.24.1 → mpflash-1.24.2}/pyproject.toml +1 -1
  9. mpflash-1.24.1/mpflash/mpboard_id/board_info.zip +0 -0
  10. {mpflash-1.24.1 → mpflash-1.24.2}/LICENSE +0 -0
  11. {mpflash-1.24.1 → mpflash-1.24.2}/README.md +0 -0
  12. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/__init__.py +0 -0
  13. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/add_firmware.py +0 -0
  14. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/ask_input.py +0 -0
  15. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/bootloader/__init__.py +0 -0
  16. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/bootloader/activate.py +0 -0
  17. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/bootloader/detect.py +0 -0
  18. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/bootloader/manual.py +0 -0
  19. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/bootloader/micropython.py +0 -0
  20. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/bootloader/touch1200.py +0 -0
  21. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/cli_download.py +0 -0
  22. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/cli_flash.py +0 -0
  23. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/cli_group.py +0 -0
  24. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/cli_list.py +0 -0
  25. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/cli_main.py +0 -0
  26. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/config.py +0 -0
  27. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/connected.py +0 -0
  28. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/download.py +0 -0
  29. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/downloaded.py +0 -0
  30. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/errors.py +0 -0
  31. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/flash/__init__.py +0 -0
  32. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/flash/esp.py +0 -0
  33. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/flash/stm32.py +0 -0
  34. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/flash/stm32_dfu.py +0 -0
  35. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/flash/uf2/__init__.py +0 -0
  36. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/flash/uf2/boardid.py +0 -0
  37. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/flash/uf2/linux.py +0 -0
  38. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/flash/uf2/macos.py +0 -0
  39. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/flash/uf2/uf2disk.py +0 -0
  40. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/flash/uf2/windows.py +0 -0
  41. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/flash/worklist.py +0 -0
  42. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/list.py +0 -0
  43. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/logger.py +0 -0
  44. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/mpboard_id/add_boards.py +0 -0
  45. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/mpboard_id/board.py +0 -0
  46. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/mpboard_id/store.py +0 -0
  47. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/mpremoteboard/__init__.py +0 -0
  48. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/mpremoteboard/mpy_fw_info.py +0 -0
  49. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/mpremoteboard/runner.py +0 -0
  50. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/vendor/click_aliases.py +0 -0
  51. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/vendor/dfu.py +0 -0
  52. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/vendor/pydfu.py +0 -0
  53. {mpflash-1.24.1 → mpflash-1.24.2}/mpflash/vendor/readme.md +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mpflash
3
- Version: 1.24.1
3
+ Version: 1.24.2
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
@@ -10,7 +10,7 @@ from pathlib import Path
10
10
  from typing import List, Optional, Union
11
11
 
12
12
  import cachetools.func
13
- from github import Auth, Github
13
+ from github import Auth, BadCredentialsException, Github
14
14
  from loguru import logger as log
15
15
  from packaging.version import parse
16
16
 
@@ -18,7 +18,11 @@ from packaging.version import parse
18
18
 
19
19
  # Token with no permissions to avoid throttling
20
20
  # https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#getting-a-higher-rate-limit
21
- PAT_NO_ACCESS = "github_pat" + "_11AAHPVFQ0qAkDnSUaMKSp" + "_ZkDl5NRRwBsUN6EYg9ahp1Dvj4FDDONnXVgimxC2EtpY7Q7BUKBoQ0Jq72X"
21
+ PAT_NO_ACCESS = (
22
+ "github_pat_"
23
+ + "11AAHPVFQ0G4NTaQ73Bw5J"
24
+ + "_fAp7K9sZ1qL8VFnI9g78eUlCdmOXHB3WzSdj2jtEYb4XF3N7PDJBl32qIxq"
25
+ )
22
26
  PAT = os.environ.get("GITHUB_TOKEN") or PAT_NO_ACCESS
23
27
  GH_CLIENT = Github(auth=Auth.Token(PAT))
24
28
 
@@ -35,9 +39,17 @@ def _run_local_git(
35
39
  if repo:
36
40
  if isinstance(repo, str):
37
41
  repo = Path(repo)
38
- result = subprocess.run(cmd, capture_output=capture_output, check=True, cwd=repo.absolute().as_posix(), encoding="utf-8")
42
+ result = subprocess.run(
43
+ cmd,
44
+ capture_output=capture_output,
45
+ check=True,
46
+ cwd=repo.absolute().as_posix(),
47
+ encoding="utf-8",
48
+ )
39
49
  else:
40
- result = subprocess.run(cmd, capture_output=capture_output, check=True, encoding="utf-8")
50
+ result = subprocess.run(
51
+ cmd, capture_output=capture_output, check=True, encoding="utf-8"
52
+ )
41
53
  except (NotADirectoryError, FileNotFoundError) as e: # pragma: no cover
42
54
  return None
43
55
  except subprocess.CalledProcessError as e: # pragma: no cover
@@ -76,7 +88,9 @@ def clone(remote_repo: str, path: Path, shallow: bool = False, tag: Optional[str
76
88
  return False
77
89
 
78
90
 
79
- def get_local_tag(repo: Optional[Union[str, Path]] = None, abbreviate: bool = True) -> Union[str, None]:
91
+ def get_local_tag(
92
+ repo: Optional[Union[str, Path]] = None, abbreviate: bool = True
93
+ ) -> Union[str, None]:
80
94
  """
81
95
  get the most recent git version tag of a local repo
82
96
  repo Path should be in the form of : repo = "./repo/micropython"
@@ -125,12 +139,16 @@ def get_local_tags(repo: Optional[Path] = None, minver: Optional[str] = None) ->
125
139
  @cachetools.func.ttl_cache(maxsize=16, ttl=60) # 60 seconds
126
140
  def get_tags(repo: str, minver: Optional[str] = None) -> List[str]:
127
141
  """
128
- Get list of tag of a repote github repo
142
+ Get list of tag of a repote github repo.
143
+ only the last -preview tag is kept
129
144
  """
130
145
  if not repo or not isinstance(repo, str) or "/" not in repo: # type: ignore
131
146
  return []
132
147
  try:
133
148
  gh_repo = GH_CLIENT.get_repo(repo)
149
+ except BadCredentialsException as e:
150
+ log.error(f"Github authentication error - {e}")
151
+ return []
134
152
  except ConnectionError as e:
135
153
  # TODO: unable to capture the exeption
136
154
  log.warning(f"Unable to get tags - {e}")
@@ -138,7 +156,9 @@ def get_tags(repo: str, minver: Optional[str] = None) -> List[str]:
138
156
  tags = [tag.name for tag in gh_repo.get_tags()]
139
157
  if minver:
140
158
  tags = [tag for tag in tags if parse(tag) >= parse(minver)]
141
- return sorted(tags)
159
+ # remove all but the last preview
160
+ tags = [t for t in sorted(tags[:-1]) if "-preview" not in t] + sorted(tags)[-1:]
161
+ return tags
142
162
 
143
163
 
144
164
  def checkout_tag(tag: str, repo: Optional[Union[str, Path]] = None) -> bool:
@@ -30,11 +30,8 @@ PORT_FWTYPES = {
30
30
 
31
31
  # Token with no permissions to avoid throttling
32
32
  # https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#getting-a-higher-rate-limit
33
- PAT_NO_ACCESS = (
34
- "github_pat"
35
- + "_11AAHPVFQ0K6OKbI9xPFWG"
36
- + "_3KossOkuuxRJ6MZrP5o2vMsAW2i3QFZx2BECNjL4o30S2XQBWF77JgQbJda"
37
- )
33
+ PAT_NO_ACCESS = "github_pat_"+"11AAHPVFQ0G4NTaQ73Bw5J"+"_fAp7K9sZ1qL8VFnI9g78eUlCdmOXHB3WzSdj2jtEYb4XF3N7PDJBl32qIxq"
34
+
38
35
  PAT = os.environ.get("GITHUB_TOKEN") or PAT_NO_ACCESS
39
36
  GH_CLIENT = Github(auth=Auth.Token(PAT))
40
37
 
@@ -24,7 +24,9 @@ def get_known_ports() -> List[str]:
24
24
  return sorted(list(ports))
25
25
 
26
26
 
27
- def get_known_boards_for_port(port: Optional[str] = "", versions: Optional[List[str]] = None) -> List[Board]:
27
+ def get_known_boards_for_port(
28
+ port: Optional[str] = "", versions: Optional[List[str]] = None
29
+ ) -> List[Board]:
28
30
  """
29
31
  Returns a list of boards for the given port and version(s)
30
32
 
@@ -77,13 +79,16 @@ def known_stored_boards(port: str, versions: Optional[List[str]] = None) -> List
77
79
  @lru_cache(maxsize=20)
78
80
  def find_known_board(board_id: str) -> Board:
79
81
  """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:
82
+ # Some functional overlap with:
81
83
  # mpboard_id\board_id.py _find_board_id_by_description
82
84
  info = read_known_boardinfo()
83
85
  for board_info in info:
84
- if board_id in (board_info.board_id, board_info.description):
86
+ if board_id in (
87
+ board_info.board_id,
88
+ board_info.description,
89
+ ) or board_info.description.startswith(board_id):
85
90
  if not board_info.cpu:
86
- # safeguard for older board_info.json files
91
+ # failsafe for older board_info.json files
87
92
  print(f"Board {board_id} has no CPU info, using port as CPU")
88
93
  if " with " in board_info.description:
89
94
  board_info.cpu = board_info.description.split(" with ")[-1]
@@ -56,14 +56,12 @@ def _find_board_id_by_description(
56
56
  Path to the board_info.json file (optional)
57
57
 
58
58
  """
59
- # FIXME: functional overlap with
59
+ # Some functional overlap with
60
60
  # src\mpflash\mpflash\mpboard_id\__init__.py find_known_board
61
61
 
62
+ candidate_boards = read_known_boardinfo(board_info)
62
63
  if not short_descr and " with " in descr:
63
64
  short_descr = descr.split(" with ")[0]
64
-
65
- candidate_boards = read_known_boardinfo(board_info)
66
-
67
65
  if version:
68
66
  # filter for matching version
69
67
  if version in ("preview", "stable"):
@@ -71,16 +69,22 @@ def _find_board_id_by_description(
71
69
  version = get_stable_mp_version()
72
70
  known_versions = sorted({b.version for b in candidate_boards})
73
71
  if version not in known_versions:
74
- # FIXME if latest stable is newer than the last version in the boardlist this will fail
75
72
  log.trace(f"Version {version} not found in board info, using latest known version {known_versions[-1]}")
76
- version = known_versions[-1]
73
+ version = '.'.join(known_versions[-1].split('.')[:2]) # take only major.minor
77
74
  if version_matches := [b for b in candidate_boards if b.version.startswith(version)]:
78
75
  candidate_boards = version_matches
79
76
  else:
80
77
  raise MPFlashError(f"No board info found for version {version}")
78
+ # First try full match on description, then partial match
81
79
  matches = [b for b in candidate_boards if b.description == descr]
82
80
  if not matches and short_descr:
83
81
  matches = [b for b in candidate_boards if b.description == short_descr]
82
+ if not matches:
83
+ # partial match (for added VARIANT)
84
+ matches = [b for b in candidate_boards if b.description.startswith(descr)]
85
+ if not matches and short_descr:
86
+ matches = [b for b in candidate_boards if b.description.startswith(short_descr)]
84
87
  if not matches:
85
88
  raise MPFlashError(f"No board info found for description '{descr}' or '{short_descr}'")
86
89
  return sorted(matches, key=lambda x: x.version)
90
+
@@ -72,16 +72,16 @@ def clean_version(
72
72
 
73
73
 
74
74
  @cache_to_disk(n_days_to_cache=1)
75
- def micropython_versions(minver: str = "v1.20", reverse: bool = False, cache_it=True):
75
+ def micropython_versions(minver: str = "v1.20", reverse: bool = False):
76
76
  """Get the list of micropython versions from github tags"""
77
-
77
+ cache_it = True
78
78
  try:
79
79
  gh_client = GH_CLIENT
80
80
  repo = gh_client.get_repo("micropython/micropython")
81
81
  versions = [tag.name for tag in repo.get_tags() if parse(tag.name) >= parse(minver)]
82
82
  # Only keep the last preview
83
83
  versions = [v for v in versions if not v.endswith(V_PREVIEW) or v == versions[-1]]
84
- except Exception as e:
84
+ except Exception:
85
85
  versions = [
86
86
  "v9.99.9-preview",
87
87
  "v1.22.2",
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "mpflash"
3
- version = "1.24.1"
3
+ version = "1.24.2"
4
4
  description = "Flash and download tool for MicroPython firmwares"
5
5
  authors = ["Jos Verlinde <jos_verlinde@hotmail.com>"]
6
6
  license = "MIT"
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