mposcli 0.6.0__tar.gz → 0.7.1__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. {mposcli-0.6.0 → mposcli-0.7.1}/PKG-INFO +32 -14
  2. {mposcli-0.6.0 → mposcli-0.7.1}/README.md +31 -13
  3. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/__init__.py +1 -1
  4. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/cli_app/build.py +2 -2
  5. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/cli_app/copy_mpos.py +15 -22
  6. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/cli_app/flash.py +2 -2
  7. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/cli_app/run_deskop.py +2 -2
  8. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/cli_app/shell.py +2 -2
  9. mposcli-0.7.1/mposcli/cli_app/update.py +102 -0
  10. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/cli_dev/code_style.py +1 -1
  11. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/cli_dev/packaging.py +1 -1
  12. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/cli_dev/shell_completion.py +2 -2
  13. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/cli_dev/testing.py +1 -1
  14. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/cli_dev/update_readme_history.py +1 -1
  15. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/fs_utils.py +1 -1
  16. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/mpos_utils.py +1 -1
  17. mposcli-0.7.1/mposcli/shared_tyro.py +17 -0
  18. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/utilities/mpremote.py +13 -8
  19. {mposcli-0.6.0 → mposcli-0.7.1}/uv.lock +266 -247
  20. mposcli-0.6.0/mposcli/cli_app/update.py +0 -61
  21. {mposcli-0.6.0 → mposcli-0.7.1}/.editorconfig +0 -0
  22. {mposcli-0.6.0 → mposcli-0.7.1}/.github/workflows/tests.yml +0 -0
  23. {mposcli-0.6.0 → mposcli-0.7.1}/.gitignore +0 -0
  24. {mposcli-0.6.0 → mposcli-0.7.1}/.idea/.gitignore +0 -0
  25. {mposcli-0.6.0 → mposcli-0.7.1}/.pre-commit-config.yaml +0 -0
  26. {mposcli-0.6.0 → mposcli-0.7.1}/.pre-commit-hooks.yaml +0 -0
  27. {mposcli-0.6.0 → mposcli-0.7.1}/.run/Template Python tests.run.xml +0 -0
  28. {mposcli-0.6.0 → mposcli-0.7.1}/.run/Template Python.run.xml +0 -0
  29. {mposcli-0.6.0 → mposcli-0.7.1}/.run/Unittests __all__.run.xml +0 -0
  30. {mposcli-0.6.0 → mposcli-0.7.1}/.run/cli --help.run.xml +0 -0
  31. {mposcli-0.6.0 → mposcli-0.7.1}/.run/dev-cli --help.run.xml +0 -0
  32. {mposcli-0.6.0 → mposcli-0.7.1}/.run/dev-cli test.run.xml +0 -0
  33. {mposcli-0.6.0 → mposcli-0.7.1}/.venv-app/.gitignore +0 -0
  34. {mposcli-0.6.0 → mposcli-0.7.1}/.venv-app/lib/python3.14/site-packages/cli_base/tests/shell_complete_snapshots/.gitignore +0 -0
  35. {mposcli-0.6.0 → mposcli-0.7.1}/cli.py +0 -0
  36. {mposcli-0.6.0 → mposcli-0.7.1}/dev-cli.py +0 -0
  37. {mposcli-0.6.0 → mposcli-0.7.1}/dist/.gitignore +0 -0
  38. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/__main__.py +0 -0
  39. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/cli_app/__init__.py +0 -0
  40. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/cli_dev/__init__.py +0 -0
  41. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/cli_dev/__main__.py +0 -0
  42. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/constants.py +0 -0
  43. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/tests/__init__.py +0 -0
  44. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/tests/test_doctests.py +0 -0
  45. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/tests/test_mpremote_cp_utils.py +0 -0
  46. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/tests/test_project_setup.py +0 -0
  47. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/tests/test_readme.py +0 -0
  48. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/tests/test_readme_history.py +0 -0
  49. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/tools.py +0 -0
  50. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/user_input.py +0 -0
  51. {mposcli-0.6.0 → mposcli-0.7.1}/mposcli/utilities/__init__.py +0 -0
  52. {mposcli-0.6.0 → mposcli-0.7.1}/noxfile.py +0 -0
  53. {mposcli-0.6.0 → mposcli-0.7.1}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mposcli
3
- Version: 0.6.0
3
+ Version: 0.7.1
4
4
  Summary: CLI helper for MicroPythonOS: https://github.com/MicroPythonOS/MicroPythonOS
5
5
  Project-URL: Documentation, https://github.com/jedie/mposcli
6
6
  Project-URL: Source, https://github.com/jedie/mposcli
@@ -244,16 +244,22 @@ the REPL. The goal it to try to get a REPL in a loop until it works.
244
244
 
245
245
  [comment]: <> (✂✂✂ auto generated update start ✂✂✂)
246
246
  ```
247
- usage: mposcli update [-h] [-v]
247
+ usage: mposcli update [-h] [--cleanup | --no-cleanup] [--shallow-clone | --no-shallow-
248
+ clone] [-v]
248
249
 
249
250
  Update MicroPythonOS repository. Assume that there is a "origin" and/or "upstream" remote
250
251
  configured. Will also ask if you want to update the submodules as well, which is
251
252
  recommended.
252
253
 
253
- ╭─ options ────────────────────────────────────────────────────────────────╮
254
- │ -h, --help show this help message and exit
255
- -v, --verbosity Verbosity level; e.g.: -v, -vv, -vvv, etc. (repeatable)
256
- ╰──────────────────────────────────────────────────────────────────────────╯
254
+ ╭─ options ──────────────────────────────────────────────────────────────────────────────╮
255
+ │ -h, --help show this help message and exit
256
+ --cleanup, --no-cleanup
257
+ │ Cleanup unnecessary files and optimize the local repository, too? │
258
+ │ (default: True) │
259
+ │ --shallow-clone, --no-shallow-clone │
260
+ │ Submodules only a shallow clone with --depth=1? (default: False) │
261
+ │ -v, --verbosity Verbosity level; e.g.: -v, -vv, -vvv, etc. (repeatable) │
262
+ ╰────────────────────────────────────────────────────────────────────────────────────────╯
257
263
  ```
258
264
  [comment]: <> (✂✂✂ auto generated update end ✂✂✂)
259
265
 
@@ -265,16 +271,22 @@ recommended.
265
271
 
266
272
  [comment]: <> (✂✂✂ auto generated update-submodules start ✂✂✂)
267
273
  ```
268
- usage: mposcli update-submodules [-h] [-v]
274
+ usage: mposcli update-submodules [-h] [--cleanup | --no-cleanup] [--shallow-clone | --no-
275
+ shallow-clone] [-v]
269
276
 
270
277
  Updates MicroPythonOS git submodules only. Use "mposcli update" to update the main
271
278
  repository and optionally the submodules as well. see: https://docs.micropythonos.com/os-
272
279
  development/linux/#optional-updating-the-code
273
280
 
274
- ╭─ options ────────────────────────────────────────────────────────────────╮
275
- │ -h, --help show this help message and exit
276
- -v, --verbosity Verbosity level; e.g.: -v, -vv, -vvv, etc. (repeatable)
277
- ╰──────────────────────────────────────────────────────────────────────────╯
281
+ ╭─ options ──────────────────────────────────────────────────────────────────────────────╮
282
+ │ -h, --help show this help message and exit
283
+ --cleanup, --no-cleanup
284
+ │ Cleanup unnecessary files and optimize the local repository, too? │
285
+ │ (default: True) │
286
+ │ --shallow-clone, --no-shallow-clone │
287
+ │ Submodules only a shallow clone with --depth=1? (default: False) │
288
+ │ -v, --verbosity Verbosity level; e.g.: -v, -vv, -vvv, etc. (repeatable) │
289
+ ╰────────────────────────────────────────────────────────────────────────────────────────╯
278
290
  ```
279
291
  [comment]: <> (✂✂✂ auto generated update-submodules end ✂✂✂)
280
292
 
@@ -343,6 +355,12 @@ completion,test,update,update-readme-history,update-test-snapshot-files,version}
343
355
 
344
356
  [comment]: <> (✂✂✂ auto generated history start ✂✂✂)
345
357
 
358
+ * [v0.7.1](https://github.com/jedie/mposcli/compare/v0.7.0...v0.7.1)
359
+ * 2026-03-24 - Warn if non executeable build found
360
+ * 2026-03-24 - Set log level to WARNING as default
361
+ * [v0.7.0](https://github.com/jedie/mposcli/compare/v0.6.0...v0.7.0)
362
+ * 2026-03-24 - Safe diskspace in mposcli update / update-submodules
363
+ * 2026-03-22 - Use "retry loop" for copy, too
346
364
  * [v0.6.0](https://github.com/jedie/mposcli/compare/v0.5.0...v0.6.0)
347
365
  * 2026-03-21 - NEW: "shell" to start the REPL
348
366
  * [v0.5.0](https://github.com/jedie/mposcli/compare/v0.4.1...v0.5.0)
@@ -350,6 +368,9 @@ completion,test,update,update-readme-history,update-test-snapshot-files,version}
350
368
  * 2026-03-05 - Enhance "cp" command and auto restart "mpremote repl"
351
369
  * 2026-03-03 - Refactor "cp" command
352
370
  * 2026-03-03 - flash command: use port auto detection as default
371
+
372
+ <details><summary>Expand older history entries ...</summary>
373
+
353
374
  * [v0.4.1](https://github.com/jedie/mposcli/compare/v0.4.0...v0.4.1)
354
375
  * 2026-02-27 - Use "--force" for pulling submodules to overwrite local changes
355
376
  * [v0.4.0](https://github.com/jedie/mposcli/compare/v0.3.0...v0.4.0)
@@ -358,9 +379,6 @@ completion,test,update,update-readme-history,update-test-snapshot-files,version}
358
379
  * 2026-02-23 - Update requirements and fix code style
359
380
  * 2026-02-23 - "build" command: target as positional argument
360
381
  * 2026-02-23 - Expand "cp" command and allow optional filesystem path
361
-
362
- <details><summary>Expand older history entries ...</summary>
363
-
364
382
  * [v0.3.0](https://github.com/jedie/mposcli/compare/v0.2.0...v0.3.0)
365
383
  * 2026-02-18 - Add "update" beside "update-submodules"
366
384
  * 2026-02-17 - Update requirements
@@ -229,16 +229,22 @@ the REPL. The goal it to try to get a REPL in a loop until it works.
229
229
 
230
230
  [comment]: <> (✂✂✂ auto generated update start ✂✂✂)
231
231
  ```
232
- usage: mposcli update [-h] [-v]
232
+ usage: mposcli update [-h] [--cleanup | --no-cleanup] [--shallow-clone | --no-shallow-
233
+ clone] [-v]
233
234
 
234
235
  Update MicroPythonOS repository. Assume that there is a "origin" and/or "upstream" remote
235
236
  configured. Will also ask if you want to update the submodules as well, which is
236
237
  recommended.
237
238
 
238
- ╭─ options ────────────────────────────────────────────────────────────────╮
239
- │ -h, --help show this help message and exit
240
- -v, --verbosity Verbosity level; e.g.: -v, -vv, -vvv, etc. (repeatable)
241
- ╰──────────────────────────────────────────────────────────────────────────╯
239
+ ╭─ options ──────────────────────────────────────────────────────────────────────────────╮
240
+ │ -h, --help show this help message and exit
241
+ --cleanup, --no-cleanup
242
+ │ Cleanup unnecessary files and optimize the local repository, too? │
243
+ │ (default: True) │
244
+ │ --shallow-clone, --no-shallow-clone │
245
+ │ Submodules only a shallow clone with --depth=1? (default: False) │
246
+ │ -v, --verbosity Verbosity level; e.g.: -v, -vv, -vvv, etc. (repeatable) │
247
+ ╰────────────────────────────────────────────────────────────────────────────────────────╯
242
248
  ```
243
249
  [comment]: <> (✂✂✂ auto generated update end ✂✂✂)
244
250
 
@@ -250,16 +256,22 @@ recommended.
250
256
 
251
257
  [comment]: <> (✂✂✂ auto generated update-submodules start ✂✂✂)
252
258
  ```
253
- usage: mposcli update-submodules [-h] [-v]
259
+ usage: mposcli update-submodules [-h] [--cleanup | --no-cleanup] [--shallow-clone | --no-
260
+ shallow-clone] [-v]
254
261
 
255
262
  Updates MicroPythonOS git submodules only. Use "mposcli update" to update the main
256
263
  repository and optionally the submodules as well. see: https://docs.micropythonos.com/os-
257
264
  development/linux/#optional-updating-the-code
258
265
 
259
- ╭─ options ────────────────────────────────────────────────────────────────╮
260
- │ -h, --help show this help message and exit
261
- -v, --verbosity Verbosity level; e.g.: -v, -vv, -vvv, etc. (repeatable)
262
- ╰──────────────────────────────────────────────────────────────────────────╯
266
+ ╭─ options ──────────────────────────────────────────────────────────────────────────────╮
267
+ │ -h, --help show this help message and exit
268
+ --cleanup, --no-cleanup
269
+ │ Cleanup unnecessary files and optimize the local repository, too? │
270
+ │ (default: True) │
271
+ │ --shallow-clone, --no-shallow-clone │
272
+ │ Submodules only a shallow clone with --depth=1? (default: False) │
273
+ │ -v, --verbosity Verbosity level; e.g.: -v, -vv, -vvv, etc. (repeatable) │
274
+ ╰────────────────────────────────────────────────────────────────────────────────────────╯
263
275
  ```
264
276
  [comment]: <> (✂✂✂ auto generated update-submodules end ✂✂✂)
265
277
 
@@ -328,6 +340,12 @@ completion,test,update,update-readme-history,update-test-snapshot-files,version}
328
340
 
329
341
  [comment]: <> (✂✂✂ auto generated history start ✂✂✂)
330
342
 
343
+ * [v0.7.1](https://github.com/jedie/mposcli/compare/v0.7.0...v0.7.1)
344
+ * 2026-03-24 - Warn if non executeable build found
345
+ * 2026-03-24 - Set log level to WARNING as default
346
+ * [v0.7.0](https://github.com/jedie/mposcli/compare/v0.6.0...v0.7.0)
347
+ * 2026-03-24 - Safe diskspace in mposcli update / update-submodules
348
+ * 2026-03-22 - Use "retry loop" for copy, too
331
349
  * [v0.6.0](https://github.com/jedie/mposcli/compare/v0.5.0...v0.6.0)
332
350
  * 2026-03-21 - NEW: "shell" to start the REPL
333
351
  * [v0.5.0](https://github.com/jedie/mposcli/compare/v0.4.1...v0.5.0)
@@ -335,6 +353,9 @@ completion,test,update,update-readme-history,update-test-snapshot-files,version}
335
353
  * 2026-03-05 - Enhance "cp" command and auto restart "mpremote repl"
336
354
  * 2026-03-03 - Refactor "cp" command
337
355
  * 2026-03-03 - flash command: use port auto detection as default
356
+
357
+ <details><summary>Expand older history entries ...</summary>
358
+
338
359
  * [v0.4.1](https://github.com/jedie/mposcli/compare/v0.4.0...v0.4.1)
339
360
  * 2026-02-27 - Use "--force" for pulling submodules to overwrite local changes
340
361
  * [v0.4.0](https://github.com/jedie/mposcli/compare/v0.3.0...v0.4.0)
@@ -343,9 +364,6 @@ completion,test,update,update-readme-history,update-test-snapshot-files,version}
343
364
  * 2026-02-23 - Update requirements and fix code style
344
365
  * 2026-02-23 - "build" command: target as positional argument
345
366
  * 2026-02-23 - Expand "cp" command and allow optional filesystem path
346
-
347
- <details><summary>Expand older history entries ...</summary>
348
-
349
367
  * [v0.3.0](https://github.com/jedie/mposcli/compare/v0.2.0...v0.3.0)
350
368
  * 2026-02-18 - Add "update" beside "update-submodules"
351
369
  * 2026-02-17 - Update requirements
@@ -4,5 +4,5 @@
4
4
  """
5
5
 
6
6
  # See https://packaging.python.org/en/latest/specifications/version-specifiers/
7
- __version__ = '0.6.0'
7
+ __version__ = '0.7.1'
8
8
  __author__ = 'Jens Diemer <cookiecutter_templates@jensdiemer.de>'
@@ -5,11 +5,11 @@ import tyro
5
5
  from bx_py_utils.path import assert_is_file
6
6
  from cli_base.cli_tools.subprocess_utils import verbose_check_call
7
7
  from cli_base.cli_tools.verbosity import setup_logging
8
- from cli_base.tyro_commands import TyroVerbosityArgType
9
8
  from rich import print # noqa
10
9
 
11
10
  from mposcli.cli_app import app
12
11
  from mposcli.mpos_utils import get_mpos_path
12
+ from mposcli.shared_tyro import DEFAULT_VERBOSITY, TyroVerbosityArgType
13
13
 
14
14
 
15
15
  logger = logging.getLogger(__name__)
@@ -24,7 +24,7 @@ def build(
24
24
  ),
25
25
  ] = 'unix',
26
26
  /,
27
- verbosity: TyroVerbosityArgType = 1,
27
+ verbosity: TyroVerbosityArgType = DEFAULT_VERBOSITY,
28
28
  ):
29
29
  """
30
30
  Build MicroPythonOS by calling: ./scripts/build_mpos.sh <target>
@@ -7,14 +7,14 @@ import tyro
7
7
  from bx_py_utils.path import assert_is_dir
8
8
  from cli_base.cli_tools.subprocess_utils import verbose_check_call
9
9
  from cli_base.cli_tools.verbosity import setup_logging
10
- from cli_base.tyro_commands import TyroVerbosityArgType
11
10
  from rich import print
12
11
 
13
12
  from mposcli.cli_app import app
14
13
  from mposcli.mpos_utils import get_mpos_path
14
+ from mposcli.shared_tyro import DEFAULT_VERBOSITY, TyroVerbosityArgType
15
15
  from mposcli.tools import get_mpremote_bin
16
16
  from mposcli.user_input import choose_newest_modified_directory, get_newest_files
17
- from mposcli.utilities.mpremote import MpOsPathResolver, start_mpremote_repl
17
+ from mposcli.utilities.mpremote import MpOsPathResolver, check_call_loop, start_mpremote_repl
18
18
 
19
19
 
20
20
  logger = logging.getLogger(__name__)
@@ -39,7 +39,7 @@ def cp(
39
39
  bool,
40
40
  tyro.conf.arg(help='After flashing/verify start REPL with mpremote to see the output of the device?'),
41
41
  ] = True,
42
- verbosity: TyroVerbosityArgType = 1,
42
+ verbosity: TyroVerbosityArgType = DEFAULT_VERBOSITY,
43
43
  ):
44
44
  """
45
45
  Copy/update internal_filesystem/lib/mpos files to the device via "mpremote fs cp".
@@ -79,12 +79,11 @@ def cp(
79
79
  else:
80
80
  print(f'Copying file "[bold]{local_path_str}[/bold]" to device at "[bold]{remote_str}[/bold]" ...')
81
81
 
82
- verbose_check_call(
83
- *popenargs,
84
- 'cp',
85
- local_path_str,
86
- remote_str,
87
- verbose=True,
82
+ popenargs += ('cp', local_path_str, remote_str)
83
+ check_call_loop(
84
+ popen_args=popenargs,
85
+ max_try=10,
86
+ wait_time=1,
88
87
  cwd=mpos_path,
89
88
  text=None,
90
89
  )
@@ -113,7 +112,7 @@ def cp_app(
113
112
  bool,
114
113
  tyro.conf.arg(help='After flashing/verify start REPL with mpremote to see the output of the device?'),
115
114
  ] = True,
116
- verbosity: TyroVerbosityArgType = 1,
115
+ verbosity: TyroVerbosityArgType = DEFAULT_VERBOSITY,
117
116
  ):
118
117
  """
119
118
  Copy/update internal_filesystem/apps to the device via "mpremote fs cp".
@@ -146,9 +145,11 @@ def cp_app(
146
145
  remote_path = f':/apps/{app.name}'
147
146
 
148
147
  popenargs += (local_path, remote_path)
149
- verbose_check_call(
150
- *popenargs,
151
- verbose=True,
148
+
149
+ check_call_loop(
150
+ popen_args=popenargs,
151
+ max_try=10,
152
+ wait_time=1,
152
153
  cwd=mpos_path,
153
154
  text=None,
154
155
  )
@@ -164,12 +165,4 @@ def cp_app(
164
165
  )
165
166
 
166
167
  if repl:
167
- time.sleep(1)
168
- verbose_check_call(
169
- mpremote_bin,
170
- 'repl',
171
- verbose=True,
172
- cwd=mpos_path,
173
- timeout=None,
174
- text=None,
175
- )
168
+ start_mpremote_repl()
@@ -4,11 +4,11 @@ from typing import Annotated
4
4
  import tyro
5
5
  from cli_base.cli_tools.subprocess_utils import verbose_check_call
6
6
  from cli_base.cli_tools.verbosity import setup_logging
7
- from cli_base.tyro_commands import TyroVerbosityArgType
8
7
  from rich import print
9
8
 
10
9
  from mposcli.cli_app import app
11
10
  from mposcli.mpos_utils import get_mpos_path
11
+ from mposcli.shared_tyro import DEFAULT_VERBOSITY, TyroVerbosityArgType
12
12
  from mposcli.tools import get_esptool_bin, get_mpremote_bin
13
13
  from mposcli.user_input import file_chooser
14
14
 
@@ -34,7 +34,7 @@ def flash(
34
34
  bool,
35
35
  tyro.conf.arg(help='After flashing/verify start REPL with mpremote to see the output of the device?'),
36
36
  ] = True,
37
- verbosity: TyroVerbosityArgType = 1,
37
+ verbosity: TyroVerbosityArgType = DEFAULT_VERBOSITY,
38
38
  ):
39
39
  """
40
40
  Flash MicroPythonOS to the device. Display a file chooser to select the image to flash.
@@ -9,12 +9,12 @@ import tyro
9
9
  from bx_py_utils.path import assert_is_file
10
10
  from cli_base.cli_tools.subprocess_utils import verbose_check_call
11
11
  from cli_base.cli_tools.verbosity import setup_logging
12
- from cli_base.tyro_commands import TyroVerbosityArgType
13
12
  from rich import print
14
13
 
15
14
  from mposcli.cli_app import app
16
15
  from mposcli.fs_utils import list_executables
17
16
  from mposcli.mpos_utils import get_mpos_path
17
+ from mposcli.shared_tyro import DEFAULT_VERBOSITY, TyroVerbosityArgType
18
18
  from mposcli.user_input import file_chooser
19
19
 
20
20
 
@@ -40,7 +40,7 @@ def run_desktop(
40
40
  ' If omitted, shows a file chooser to select one from the lvgl_micropython build directory.'
41
41
  ),
42
42
  ] = None,
43
- verbosity: TyroVerbosityArgType = 1,
43
+ verbosity: TyroVerbosityArgType = DEFAULT_VERBOSITY,
44
44
  ):
45
45
  """
46
46
  Run MicroPythonOS on desktop.
@@ -5,10 +5,10 @@ from typing import Annotated
5
5
  import tyro
6
6
  from cli_base.cli_tools.subprocess_utils import verbose_check_call
7
7
  from cli_base.cli_tools.verbosity import setup_logging
8
- from cli_base.tyro_commands import TyroVerbosityArgType
9
8
 
10
9
  from mposcli.cli_app import app
11
10
  from mposcli.mpos_utils import get_mpos_path
11
+ from mposcli.shared_tyro import DEFAULT_VERBOSITY, TyroVerbosityArgType
12
12
  from mposcli.tools import get_mpremote_bin
13
13
  from mposcli.utilities.mpremote import start_mpremote_repl
14
14
 
@@ -22,7 +22,7 @@ def shell(
22
22
  bool,
23
23
  tyro.conf.arg(help='Reset the device before starting the REPL?'),
24
24
  ] = False,
25
- verbosity: TyroVerbosityArgType = 1,
25
+ verbosity: TyroVerbosityArgType = DEFAULT_VERBOSITY,
26
26
  ):
27
27
  """
28
28
  Start a REPL shell connected to the device using mpremote. Optional reset before starting the REPL.
@@ -0,0 +1,102 @@
1
+ import logging
2
+ import shutil
3
+ from typing import Annotated
4
+
5
+ import tyro
6
+ from cli_base.cli_tools.git import Git
7
+ from cli_base.cli_tools.verbosity import setup_logging
8
+ from rich import print
9
+
10
+ from mposcli.cli_app import app
11
+ from mposcli.mpos_utils import get_mpos_path
12
+ from mposcli.shared_tyro import DEFAULT_VERBOSITY, TyroVerbosityArgType
13
+
14
+
15
+ logger = logging.getLogger(__name__)
16
+
17
+
18
+ def _update_submodules(git: Git, *, cleanup, shallow_clone):
19
+ if shallow_clone:
20
+ git.git_verbose_check_call('submodule', 'deinit', '-f', '--all')
21
+ modules_path = git.cwd / '.git' / 'modules'
22
+ if modules_path.exists():
23
+ shutil.rmtree(modules_path)
24
+ git.git_verbose_check_call('submodule', 'update', '--init', '--depth', '1', '--recursive')
25
+ else:
26
+ git.git_verbose_check_call(
27
+ 'submodule', 'foreach', '--recursive', 'git', 'clean', '-f', ';', 'git', 'checkout', '.'
28
+ )
29
+ git.git_verbose_check_call('pull', '--recurse-submodules', '--force')
30
+
31
+ if cleanup:
32
+ git.git_verbose_check_call(
33
+ 'submodule', 'foreach', '--recursive', 'git', 'gc', '--aggressive', '--prune=now'
34
+ )
35
+
36
+
37
+ @app.command
38
+ def update_submodules(
39
+ cleanup: Annotated[
40
+ bool,
41
+ tyro.conf.arg(help='Cleanup unnecessary files and optimize the local repository, too?'),
42
+ ] = True,
43
+ shallow_clone: Annotated[
44
+ bool,
45
+ tyro.conf.arg(help='Submodules only a shallow clone with --depth=1?'),
46
+ ] = False,
47
+ verbosity: TyroVerbosityArgType = DEFAULT_VERBOSITY,
48
+ ):
49
+ """
50
+ Updates MicroPythonOS git submodules only.
51
+ Use "mposcli update" to update the main repository and optionally the submodules as well.
52
+ see: https://docs.micropythonos.com/os-development/linux/#optional-updating-the-code
53
+ """
54
+ setup_logging(verbosity=verbosity)
55
+ mpos_path = get_mpos_path()
56
+ git = Git(cwd=mpos_path)
57
+ _update_submodules(git, cleanup=cleanup, shallow_clone=shallow_clone)
58
+
59
+
60
+ @app.command
61
+ def update(
62
+ cleanup: Annotated[
63
+ bool,
64
+ tyro.conf.arg(help='Cleanup unnecessary files and optimize the local repository, too?'),
65
+ ] = True,
66
+ shallow_clone: Annotated[
67
+ bool,
68
+ tyro.conf.arg(help='Submodules only a shallow clone with --depth=1?'),
69
+ ] = False,
70
+ verbosity: TyroVerbosityArgType = DEFAULT_VERBOSITY,
71
+ ):
72
+ """
73
+ Update MicroPythonOS repository. Assume that there is a "origin" and/or "upstream" remote configured.
74
+ Will also ask if you want to update the submodules as well, which is recommended.
75
+ """
76
+ setup_logging(verbosity=verbosity)
77
+ mpos_path = get_mpos_path()
78
+ git = Git(cwd=mpos_path)
79
+
80
+ main_branch_name = git.get_main_branch_name()
81
+ print(f'The main branch is: [yellow blue]{main_branch_name}')
82
+
83
+ git.git_verbose_check_call('fetch', '--all')
84
+
85
+ output = git.git_verbose_check_output('remote')
86
+ remotes = output.splitlines()
87
+ print(f'Git {remotes=}')
88
+
89
+ for remote_name in ('origin', 'upstream'):
90
+ if remote_name in remotes:
91
+ git.git_verbose_check_call('rebase', '--no-verify', f'{remote_name}/{main_branch_name}', exit_on_error=True)
92
+ else:
93
+ print(f'[yellow]Remote "{remote_name}" not found, skipping rebase to it.')
94
+
95
+ if cleanup:
96
+ print('\nCleaning up the git repository...\n')
97
+ git.git_verbose_check_call('gc', '--aggressive', '--prune=now')
98
+
99
+ print('\n')
100
+ if input('Do you want to update submodules as well? [Y/n] (default: Yes): ') in ('y', ''):
101
+ print('\nUpdating submodules...\n')
102
+ _update_submodules(git, cleanup=cleanup, shallow_clone=shallow_clone)
@@ -1,7 +1,7 @@
1
1
  from cli_base.cli_tools.code_style import assert_code_style
2
- from cli_base.tyro_commands import TyroVerbosityArgType
3
2
 
4
3
  from mposcli.cli_dev import PACKAGE_ROOT, app
4
+ from mposcli.shared_tyro import TyroVerbosityArgType
5
5
 
6
6
 
7
7
  @app.command
@@ -4,11 +4,11 @@ from cli_base.cli_tools.dev_tools import run_unittest_cli
4
4
  from cli_base.cli_tools.subprocess_utils import ToolsExecutor
5
5
  from cli_base.cli_tools.verbosity import setup_logging
6
6
  from cli_base.run_pip_audit import run_pip_audit
7
- from cli_base.tyro_commands import TyroVerbosityArgType
8
7
  from manageprojects.utilities.publish import publish_package
9
8
 
10
9
  import mposcli
11
10
  from mposcli.cli_dev import PACKAGE_ROOT, app
11
+ from mposcli.shared_tyro import TyroVerbosityArgType
12
12
 
13
13
 
14
14
  logger = logging.getLogger(__name__)
@@ -2,17 +2,17 @@ import logging
2
2
 
3
3
  from cli_base.cli_tools.shell_completion import setup_tyro_shell_completion
4
4
  from cli_base.cli_tools.verbosity import setup_logging
5
- from cli_base.tyro_commands import TyroVerbosityArgType
6
5
  from rich import print # noqa
7
6
 
8
7
  from mposcli.cli_dev import app
8
+ from mposcli.shared_tyro import DEFAULT_VERBOSITY, TyroVerbosityArgType
9
9
 
10
10
 
11
11
  logger = logging.getLogger(__name__)
12
12
 
13
13
 
14
14
  @app.command
15
- def shell_completion(verbosity: TyroVerbosityArgType = 1, remove: bool = False) -> None:
15
+ def shell_completion(verbosity: TyroVerbosityArgType = DEFAULT_VERBOSITY, remove: bool = False) -> None:
16
16
  """
17
17
  Setup shell completion for this CLI (Currently only for bash shell)
18
18
  """
@@ -1,9 +1,9 @@
1
1
  from cli_base.cli_tools.dev_tools import run_coverage, run_nox, run_unittest_cli
2
2
  from cli_base.cli_tools.subprocess_utils import verbose_check_call
3
3
  from cli_base.cli_tools.test_utils.snapshot import UpdateTestSnapshotFiles
4
- from cli_base.tyro_commands import TyroVerbosityArgType
5
4
 
6
5
  from mposcli.cli_dev import PACKAGE_ROOT, app
6
+ from mposcli.shared_tyro import TyroVerbosityArgType
7
7
 
8
8
 
9
9
  @app.command
@@ -4,10 +4,10 @@ from pathlib import Path
4
4
 
5
5
  from cli_base.cli_tools import git_history
6
6
  from cli_base.cli_tools.verbosity import setup_logging
7
- from cli_base.tyro_commands import TyroVerbosityArgType
8
7
  from rich import print
9
8
 
10
9
  from mposcli.cli_dev import app
10
+ from mposcli.shared_tyro import TyroVerbosityArgType
11
11
 
12
12
 
13
13
  logger = logging.getLogger(__name__)
@@ -22,5 +22,5 @@ def list_executables(directory: Path) -> list[Path]:
22
22
  if os.access(entry, os.X_OK):
23
23
  executables.append(entry)
24
24
  else:
25
- logger.info('Skipping non-executable file: %s', entry)
25
+ logger.warning('%s is not executable! (Hint: "chmod +x <filename>")', entry)
26
26
  return executables
@@ -16,7 +16,7 @@ def get_mpos_path() -> Path:
16
16
  current_path = Path().cwd().resolve()
17
17
  logger.info('Current working directory: %s', current_path)
18
18
 
19
- for dir_name in ('internal_filesystem', Path('lvgl_micropython', 'build')):
19
+ for dir_name in ('internal_filesystem', 'lvgl_micropython'):
20
20
  dir_path = current_path / dir_name
21
21
  logger.debug('Checking for directory: %s', dir_path)
22
22
  if not dir_path.is_dir():
@@ -0,0 +1,17 @@
1
+ from typing import Annotated
2
+
3
+ import tyro
4
+ from tyro.conf import UseCounterAction
5
+
6
+
7
+ DEFAULT_VERBOSITY = 1 # Display warnings by default
8
+
9
+ # https://brentyi.github.io/tyro/examples/04_additional/12_counters/
10
+ TyroVerbosityArgType = Annotated[
11
+ UseCounterAction[int],
12
+ tyro.conf.arg(
13
+ aliases=['-v'],
14
+ help='Verbosity level; e.g.: -v, -vv, -vvv, etc.',
15
+ default=DEFAULT_VERBOSITY,
16
+ ),
17
+ ]
@@ -45,20 +45,25 @@ class MpOsPathResolver:
45
45
  return local_path_str, remote_str
46
46
 
47
47
 
48
- def start_mpremote_repl(max_try=10, wait_time=1):
49
- print('Starting mpremote REPL...')
50
- time.sleep(wait_time)
51
- mpremote_bin = get_mpremote_bin()
52
-
53
- popen_args = (mpremote_bin, 'repl')
54
-
48
+ def check_call_loop(*, popen_args, max_try=10, wait_time=1, **popen_kwargs):
55
49
  for try_count in range(max_try):
56
50
  print(f'\n+ {shlex.join(str(arg) for arg in popen_args)}')
57
51
  try:
58
- return subprocess.check_call(popen_args)
52
+ return subprocess.check_call(popen_args, **popen_kwargs)
59
53
  except subprocess.CalledProcessError as err:
60
54
  print(
61
55
  f'[yellow]mpremote finished with [red]exit code {err.returncode!r}[/red]'
62
56
  f' Retrying in {wait_time} seconds... (try {try_count + 1}/{max_try})'
63
57
  )
64
58
  time.sleep(wait_time)
59
+ raise RuntimeError(f'mpremote failed after {max_try} attempts')
60
+
61
+
62
+ def start_mpremote_repl(max_try=10, wait_time=1):
63
+ print('Starting mpremote REPL...')
64
+ mpremote_bin = get_mpremote_bin()
65
+ return check_call_loop(
66
+ popen_args=(mpremote_bin, 'repl'),
67
+ max_try=max_try,
68
+ wait_time=wait_time,
69
+ )