mpflash 1.0.4__tar.gz → 1.0.5__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 (52) hide show
  1. {mpflash-1.0.4 → mpflash-1.0.5}/PKG-INFO +1 -1
  2. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/basicgit.py +27 -7
  3. {mpflash-1.0.4 → mpflash-1.0.5}/pyproject.toml +1 -1
  4. {mpflash-1.0.4 → mpflash-1.0.5}/LICENSE +0 -0
  5. {mpflash-1.0.4 → mpflash-1.0.5}/README.md +0 -0
  6. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/__init__.py +0 -0
  7. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/add_firmware.py +0 -0
  8. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/ask_input.py +0 -0
  9. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/bootloader/__init__.py +0 -0
  10. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/bootloader/activate.py +0 -0
  11. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/bootloader/detect.py +0 -0
  12. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/bootloader/manual.py +0 -0
  13. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/bootloader/micropython.py +0 -0
  14. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/bootloader/touch1200.py +0 -0
  15. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/cli_download.py +0 -0
  16. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/cli_flash.py +0 -0
  17. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/cli_group.py +0 -0
  18. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/cli_list.py +0 -0
  19. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/cli_main.py +0 -0
  20. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/common.py +0 -0
  21. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/config.py +0 -0
  22. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/connected.py +0 -0
  23. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/download.py +0 -0
  24. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/downloaded.py +0 -0
  25. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/errors.py +0 -0
  26. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/flash/__init__.py +0 -0
  27. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/flash/esp.py +0 -0
  28. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/flash/stm32.py +0 -0
  29. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/flash/stm32_dfu.py +0 -0
  30. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/flash/uf2/__init__.py +0 -0
  31. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/flash/uf2/boardid.py +0 -0
  32. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/flash/uf2/linux.py +0 -0
  33. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/flash/uf2/macos.py +0 -0
  34. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/flash/uf2/uf2disk.py +0 -0
  35. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/flash/uf2/windows.py +0 -0
  36. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/flash/worklist.py +0 -0
  37. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/list.py +0 -0
  38. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/logger.py +0 -0
  39. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/mpboard_id/__init__.py +0 -0
  40. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/mpboard_id/add_boards.py +0 -0
  41. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/mpboard_id/board.py +0 -0
  42. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/mpboard_id/board_id.py +0 -0
  43. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/mpboard_id/board_info.zip +0 -0
  44. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/mpboard_id/store.py +0 -0
  45. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/mpremoteboard/__init__.py +0 -0
  46. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/mpremoteboard/mpy_fw_info.py +0 -0
  47. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/mpremoteboard/runner.py +0 -0
  48. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/vendor/click_aliases.py +0 -0
  49. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/vendor/dfu.py +0 -0
  50. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/vendor/pydfu.py +0 -0
  51. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/vendor/readme.md +0 -0
  52. {mpflash-1.0.4 → mpflash-1.0.5}/mpflash/versions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mpflash
3
- Version: 1.0.4
3
+ Version: 1.0.5
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:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "mpflash"
3
- version = "1.0.4"
3
+ version = "1.0.5"
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes