cleepcli 1.49.3__tar.gz → 1.49.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 (44) hide show
  1. {cleepcli-1.49.3/cleepcli.egg-info → cleepcli-1.49.5}/PKG-INFO +7 -1
  2. {cleepcli-1.49.3 → cleepcli-1.49.5}/README.md +6 -0
  3. {cleepcli-1.49.3 → cleepcli-1.49.5}/bin/ccli +35 -11
  4. {cleepcli-1.49.3 → cleepcli-1.49.5}/bin/cleep-cli +35 -11
  5. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/module.py +115 -22
  6. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/pico.py +147 -50
  7. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/version.py +1 -1
  8. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/watch.py +8 -1
  9. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/watchsvc.py +52 -2
  10. {cleepcli-1.49.3 → cleepcli-1.49.5/cleepcli.egg-info}/PKG-INFO +7 -1
  11. {cleepcli-1.49.3 → cleepcli-1.49.5}/tests/test_file_sync_all.py +34 -1
  12. cleepcli-1.49.5/tests/test_module_scaffold.py +68 -0
  13. {cleepcli-1.49.3 → cleepcli-1.49.5}/tests/test_pico.py +6 -10
  14. {cleepcli-1.49.3 → cleepcli-1.49.5}/tests/test_watchsvc.py +46 -1
  15. cleepcli-1.49.3/tests/test_module_scaffold.py +0 -26
  16. {cleepcli-1.49.3 → cleepcli-1.49.5}/LICENSE +0 -0
  17. {cleepcli-1.49.3 → cleepcli-1.49.5}/MANIFEST.in +0 -0
  18. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/__init__.py +0 -0
  19. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/check.py +0 -0
  20. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/ci.py +0 -0
  21. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/cleepapi.py +0 -0
  22. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/config.py +0 -0
  23. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/console.py +0 -0
  24. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/docs.py +0 -0
  25. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/file.py +0 -0
  26. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/git.py +0 -0
  27. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/package.py +0 -0
  28. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/systemd/cleep-watch.service +0 -0
  29. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/test.py +0 -0
  30. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli/tools.py +0 -0
  31. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli.egg-info/SOURCES.txt +0 -0
  32. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli.egg-info/dependency_links.txt +0 -0
  33. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli.egg-info/requires.txt +0 -0
  34. {cleepcli-1.49.3 → cleepcli-1.49.5}/cleepcli.egg-info/top_level.txt +0 -0
  35. {cleepcli-1.49.3 → cleepcli-1.49.5}/pyproject.toml +0 -0
  36. {cleepcli-1.49.3 → cleepcli-1.49.5}/requirements.txt +0 -0
  37. {cleepcli-1.49.3 → cleepcli-1.49.5}/setup.cfg +0 -0
  38. {cleepcli-1.49.3 → cleepcli-1.49.5}/setup.py +0 -0
  39. {cleepcli-1.49.3 → cleepcli-1.49.5}/tests/test_check.py +0 -0
  40. {cleepcli-1.49.3 → cleepcli-1.49.5}/tests/test_config.py +0 -0
  41. {cleepcli-1.49.3 → cleepcli-1.49.5}/tests/test_console.py +0 -0
  42. {cleepcli-1.49.3 → cleepcli-1.49.5}/tests/test_coverage.py +0 -0
  43. {cleepcli-1.49.3 → cleepcli-1.49.5}/tests/test_docs_breaking.py +0 -0
  44. {cleepcli-1.49.3 → cleepcli-1.49.5}/tests/test_watch.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cleepcli
3
- Version: 1.49.3
3
+ Version: 1.49.5
4
4
  Summary: Cleep-cli helps developers to build great Cleep applications from command line.
5
5
  Home-page: https://github.com/CleepDevice/cleep-cli
6
6
  Author: Tanguy Bonneau
@@ -98,6 +98,12 @@ The unit runs `cleep-cli watch`, survives `systemctl restart cleep`, and on each
98
98
 
99
99
  After `pip install` / upgrade of `cleepcli`, the next `watchsvc install` (idempotent ensure) restarts the unit when the on-disk binary is newer than the running process, so the watcher loads the new CLI without a forced bounce on every Cleep boot.
100
100
 
101
+ Resume watching after a deliberate pause (e.g. create-app already ran `modsync`) without catch-up restarting Cleep:
102
+
103
+ ```
104
+ cleep-cli watchsvc start --skip-catchup
105
+ ```
106
+
101
107
  Manual one-shot resync (when the UI looks stale) — `syncall` also mints a fresh asset bust and reloads the device UI:
102
108
 
103
109
  ```
@@ -62,6 +62,12 @@ The unit runs `cleep-cli watch`, survives `systemctl restart cleep`, and on each
62
62
 
63
63
  After `pip install` / upgrade of `cleepcli`, the next `watchsvc install` (idempotent ensure) restarts the unit when the on-disk binary is newer than the running process, so the watcher loads the new CLI without a forced bounce on every Cleep boot.
64
64
 
65
+ Resume watching after a deliberate pause (e.g. create-app already ran `modsync`) without catch-up restarting Cleep:
66
+
67
+ ```
68
+ cleep-cli watchsvc start --skip-catchup
69
+ ```
70
+
65
71
  Manual one-shot resync (when the UI looks stale) — `syncall` also mints a fresh asset bust and reloads the device UI:
66
72
 
67
73
  ```
@@ -368,8 +368,17 @@ def modsync(module):
368
368
  help='Market category (cleep.common.CATEGORIES).',
369
369
  )
370
370
  @click.option('--tag', multiple=True, help='MODULE_TAGS entry (repeatable).')
371
- @click.option('--firmware', is_flag=True, help='Also scaffold firmwares/<module>/ UF2 sources.')
372
- def modcreate(module, base_class, category, tag, firmware):
371
+ @click.option('--dep', multiple=True, help='MODULE_DEPS entry (repeatable).')
372
+ @click.option('--description', default=None, help='MODULE_DESCRIPTION (short market summary).')
373
+ @click.option('--long-description', default=None, help='MODULE_LONGDESCRIPTION (market page).')
374
+ @click.option('--url', default=None, help='MODULE_URLSITE (homepage / GitHub / service).')
375
+ @click.option(
376
+ '--firmware',
377
+ type=click.Choice(['uf2', 'micropython'], case_sensitive=True),
378
+ default=None,
379
+ help='Scaffold firmwares/<module>/ (uf2 C/C++ or micropython).',
380
+ )
381
+ def modcreate(module, base_class, category, tag, dep, description, long_description, url, firmware):
373
382
  """
374
383
  Create new module skeleton
375
384
  """
@@ -379,7 +388,11 @@ def modcreate(module, base_class, category, tag, firmware):
379
388
  base_class=base_class,
380
389
  category=category,
381
390
  tags=list(tag),
382
- with_firmware=firmware,
391
+ deps=list(dep),
392
+ description=description,
393
+ long_description=long_description,
394
+ url=url,
395
+ firmware=firmware,
383
396
  )
384
397
 
385
398
  if not res:
@@ -440,7 +453,12 @@ def watch(quiet, loglevel, rpc_url, skip_catchup):
440
453
  is_flag=True,
441
454
  help='With install: force-restart if already running. Default install also restarts when the unit changed or cleep-cli binary is newer than the running watch.',
442
455
  )
443
- def watchsvc_cmd(action, restart_if_active):
456
+ @click.option(
457
+ '--skip-catchup',
458
+ is_flag=True,
459
+ help='With start: resume watching without catch-up sync/restart (e.g. after create-app modsync).',
460
+ )
461
+ def watchsvc_cmd(action, restart_if_active, skip_catchup):
444
462
  """
445
463
  Manage the durable cleep-watch systemd unit.
446
464
 
@@ -455,6 +473,10 @@ def watchsvc_cmd(action, restart_if_active):
455
473
  the watcher when the on-disk binary is newer than the running process. Force with::
456
474
 
457
475
  cleep-cli watchsvc install --restart-if-active
476
+
477
+ Resume after a deliberate pause without restarting Cleep::
478
+
479
+ cleep-cli watchsvc start --skip-catchup
458
480
  """
459
481
  svc = WatchService()
460
482
  if action == 'status':
@@ -466,12 +488,13 @@ def watchsvc_cmd(action, restart_if_active):
466
488
 
467
489
  if action == 'install':
468
490
  ok = svc.install(restart_if_active=restart_if_active)
491
+ elif action == 'start':
492
+ ok = svc.start(skip_catchup=skip_catchup)
469
493
  else:
470
494
  handlers = {
471
495
  'uninstall': svc.uninstall,
472
496
  'enable': svc.enable,
473
497
  'disable': svc.disable,
474
- 'start': svc.start,
475
498
  'stop': svc.stop,
476
499
  'restart': svc.restart,
477
500
  }
@@ -999,7 +1022,8 @@ def pico_sdk_install(as_json):
999
1022
  logging.error(str(error))
1000
1023
  sys.exit(1)
1001
1024
  if as_json:
1002
- click.echo(json.dumps(meta, indent=2))
1025
+ # Compact one-line JSON (developer parses via Console line filter).
1026
+ click.echo(json.dumps(meta, separators=(',', ':')))
1003
1027
  else:
1004
1028
  logging.info(
1005
1029
  'SDK installed=%s version=%s revision=%s toolchain_ok=%s',
@@ -1020,7 +1044,7 @@ def pico_sdk_update(as_json):
1020
1044
  logging.error(str(error))
1021
1045
  sys.exit(1)
1022
1046
  if as_json:
1023
- click.echo(json.dumps(meta, indent=2))
1047
+ click.echo(json.dumps(meta, separators=(',', ':')))
1024
1048
  else:
1025
1049
  logging.info(
1026
1050
  'SDK updated version=%s revision=%s',
@@ -1039,7 +1063,7 @@ def pico_sdk_uninstall(as_json):
1039
1063
  logging.error(str(error))
1040
1064
  sys.exit(1)
1041
1065
  if as_json:
1042
- click.echo(json.dumps(meta, indent=2))
1066
+ click.echo(json.dumps(meta, separators=(',', ':')))
1043
1067
  else:
1044
1068
  logging.info('Pico SDK uninstalled')
1045
1069
 
@@ -1050,7 +1074,7 @@ def pico_sdk_info(as_json):
1050
1074
  """Show Pico SDK install status."""
1051
1075
  meta = Pico().sdk_info()
1052
1076
  if as_json:
1053
- click.echo(json.dumps(meta, indent=2))
1077
+ click.echo(json.dumps(meta, separators=(',', ':')))
1054
1078
  else:
1055
1079
  logging.info(
1056
1080
  'installed=%s path=%s version=%s revision=%s updated_at=%s toolchain_ok=%s',
@@ -1075,7 +1099,7 @@ def pico_build(module, firmware, as_json):
1075
1099
  logging.error(str(error))
1076
1100
  sys.exit(1)
1077
1101
  if as_json:
1078
- click.echo(json.dumps(result, indent=2))
1102
+ click.echo(json.dumps(result, separators=(',', ':')))
1079
1103
  else:
1080
1104
  logging.info('Built %s UF2 firmware(s)', result.get('count'))
1081
1105
 
@@ -1091,7 +1115,7 @@ def pico_status(module, as_json):
1091
1115
  logging.error(str(error))
1092
1116
  sys.exit(1)
1093
1117
  if as_json:
1094
- click.echo(json.dumps(result, indent=2))
1118
+ click.echo(json.dumps(result, separators=(',', ':')))
1095
1119
  else:
1096
1120
  logging.info(
1097
1121
  'uf2_ready=%s count=%s',
@@ -368,8 +368,17 @@ def modsync(module):
368
368
  help='Market category (cleep.common.CATEGORIES).',
369
369
  )
370
370
  @click.option('--tag', multiple=True, help='MODULE_TAGS entry (repeatable).')
371
- @click.option('--firmware', is_flag=True, help='Also scaffold firmwares/<module>/ UF2 sources.')
372
- def modcreate(module, base_class, category, tag, firmware):
371
+ @click.option('--dep', multiple=True, help='MODULE_DEPS entry (repeatable).')
372
+ @click.option('--description', default=None, help='MODULE_DESCRIPTION (short market summary).')
373
+ @click.option('--long-description', default=None, help='MODULE_LONGDESCRIPTION (market page).')
374
+ @click.option('--url', default=None, help='MODULE_URLSITE (homepage / GitHub / service).')
375
+ @click.option(
376
+ '--firmware',
377
+ type=click.Choice(['uf2', 'micropython'], case_sensitive=True),
378
+ default=None,
379
+ help='Scaffold firmwares/<module>/ (uf2 C/C++ or micropython).',
380
+ )
381
+ def modcreate(module, base_class, category, tag, dep, description, long_description, url, firmware):
373
382
  """
374
383
  Create new module skeleton
375
384
  """
@@ -379,7 +388,11 @@ def modcreate(module, base_class, category, tag, firmware):
379
388
  base_class=base_class,
380
389
  category=category,
381
390
  tags=list(tag),
382
- with_firmware=firmware,
391
+ deps=list(dep),
392
+ description=description,
393
+ long_description=long_description,
394
+ url=url,
395
+ firmware=firmware,
383
396
  )
384
397
 
385
398
  if not res:
@@ -440,7 +453,12 @@ def watch(quiet, loglevel, rpc_url, skip_catchup):
440
453
  is_flag=True,
441
454
  help='With install: force-restart if already running. Default install also restarts when the unit changed or cleep-cli binary is newer than the running watch.',
442
455
  )
443
- def watchsvc_cmd(action, restart_if_active):
456
+ @click.option(
457
+ '--skip-catchup',
458
+ is_flag=True,
459
+ help='With start: resume watching without catch-up sync/restart (e.g. after create-app modsync).',
460
+ )
461
+ def watchsvc_cmd(action, restart_if_active, skip_catchup):
444
462
  """
445
463
  Manage the durable cleep-watch systemd unit.
446
464
 
@@ -455,6 +473,10 @@ def watchsvc_cmd(action, restart_if_active):
455
473
  the watcher when the on-disk binary is newer than the running process. Force with::
456
474
 
457
475
  cleep-cli watchsvc install --restart-if-active
476
+
477
+ Resume after a deliberate pause without restarting Cleep::
478
+
479
+ cleep-cli watchsvc start --skip-catchup
458
480
  """
459
481
  svc = WatchService()
460
482
  if action == 'status':
@@ -466,12 +488,13 @@ def watchsvc_cmd(action, restart_if_active):
466
488
 
467
489
  if action == 'install':
468
490
  ok = svc.install(restart_if_active=restart_if_active)
491
+ elif action == 'start':
492
+ ok = svc.start(skip_catchup=skip_catchup)
469
493
  else:
470
494
  handlers = {
471
495
  'uninstall': svc.uninstall,
472
496
  'enable': svc.enable,
473
497
  'disable': svc.disable,
474
- 'start': svc.start,
475
498
  'stop': svc.stop,
476
499
  'restart': svc.restart,
477
500
  }
@@ -999,7 +1022,8 @@ def pico_sdk_install(as_json):
999
1022
  logging.error(str(error))
1000
1023
  sys.exit(1)
1001
1024
  if as_json:
1002
- click.echo(json.dumps(meta, indent=2))
1025
+ # Compact one-line JSON (developer parses via Console line filter).
1026
+ click.echo(json.dumps(meta, separators=(',', ':')))
1003
1027
  else:
1004
1028
  logging.info(
1005
1029
  'SDK installed=%s version=%s revision=%s toolchain_ok=%s',
@@ -1020,7 +1044,7 @@ def pico_sdk_update(as_json):
1020
1044
  logging.error(str(error))
1021
1045
  sys.exit(1)
1022
1046
  if as_json:
1023
- click.echo(json.dumps(meta, indent=2))
1047
+ click.echo(json.dumps(meta, separators=(',', ':')))
1024
1048
  else:
1025
1049
  logging.info(
1026
1050
  'SDK updated version=%s revision=%s',
@@ -1039,7 +1063,7 @@ def pico_sdk_uninstall(as_json):
1039
1063
  logging.error(str(error))
1040
1064
  sys.exit(1)
1041
1065
  if as_json:
1042
- click.echo(json.dumps(meta, indent=2))
1066
+ click.echo(json.dumps(meta, separators=(',', ':')))
1043
1067
  else:
1044
1068
  logging.info('Pico SDK uninstalled')
1045
1069
 
@@ -1050,7 +1074,7 @@ def pico_sdk_info(as_json):
1050
1074
  """Show Pico SDK install status."""
1051
1075
  meta = Pico().sdk_info()
1052
1076
  if as_json:
1053
- click.echo(json.dumps(meta, indent=2))
1077
+ click.echo(json.dumps(meta, separators=(',', ':')))
1054
1078
  else:
1055
1079
  logging.info(
1056
1080
  'installed=%s path=%s version=%s revision=%s updated_at=%s toolchain_ok=%s',
@@ -1075,7 +1099,7 @@ def pico_build(module, firmware, as_json):
1075
1099
  logging.error(str(error))
1076
1100
  sys.exit(1)
1077
1101
  if as_json:
1078
- click.echo(json.dumps(result, indent=2))
1102
+ click.echo(json.dumps(result, separators=(',', ':')))
1079
1103
  else:
1080
1104
  logging.info('Built %s UF2 firmware(s)', result.get('count'))
1081
1105
 
@@ -1091,7 +1115,7 @@ def pico_status(module, as_json):
1091
1115
  logging.error(str(error))
1092
1116
  sys.exit(1)
1093
1117
  if as_json:
1094
- click.echo(json.dumps(result, indent=2))
1118
+ click.echo(json.dumps(result, separators=(',', ':')))
1095
1119
  else:
1096
1120
  logging.info(
1097
1121
  'uf2_ready=%s count=%s',
@@ -298,14 +298,14 @@ class %(MODULE_NAME_CAPITALIZED)s(%(BASE_CLASS)s):
298
298
  # --- Market / install metadata (shown in CleepDesktop & the device market) ---
299
299
  MODULE_AUTHOR = 'TODO'
300
300
  MODULE_VERSION = '0.0.0' # semver; bump when you release
301
- MODULE_DEPS = [] # other Cleep apps required at runtime, e.g. ['audio']
302
- MODULE_DESCRIPTION = 'TODO' # short one-line summary
303
- MODULE_LONGDESCRIPTION = 'TODO' # longer description for the market page
301
+ MODULE_DEPS = %(MODULE_DEPS)s # other Cleep apps required at runtime, e.g. ['gpio']
302
+ MODULE_DESCRIPTION = %(MODULE_DESCRIPTION)s # short one-line summary
303
+ MODULE_LONGDESCRIPTION = %(MODULE_LONGDESCRIPTION)s # longer description for the market page
304
304
  MODULE_TAGS = %(MODULE_TAGS)s # keywords for market search
305
305
  MODULE_CATEGORY = CATEGORIES.%(MODULE_CATEGORY)s
306
306
  MODULE_URLINFO = None # project / docs URL
307
307
  MODULE_URLHELP = None # help / wiki URL
308
- MODULE_URLSITE = None # homepage
308
+ MODULE_URLSITE = %(MODULE_URLSITE)s # homepage / GitHub / service site
309
309
  MODULE_URLBUGS = None # bug tracker
310
310
 
311
311
  # --- Persistent config (JSON file under the device config path) ---
@@ -417,13 +417,15 @@ class %(MODULE_NAME_CAPITALIZED)s(%(BASE_CLASS)s):
417
417
  "CleepRemoteAccessModule",
418
418
  )
419
419
 
420
+ FIRMWARE_KINDS = ("uf2", "micropython")
421
+
420
422
  FIRMWARE_MANIFEST_SKEL = """{
421
423
  "schema_version": 1,
422
424
  "name": "%(MODULE_NAME_CAPITALIZED)s Pico",
423
425
  "app": "%(MODULE_NAME)s",
424
426
  "version": "0.0.1",
425
427
  "targets": ["pico"],
426
- "kind": "uf2",
428
+ "kind": "%(FIRMWARE_KIND)s",
427
429
  "description": "Companion firmware for %(MODULE_NAME)s"
428
430
  }
429
431
  """
@@ -466,6 +468,15 @@ int main() {
466
468
  }
467
469
  """
468
470
 
471
+ FIRMWARE_MAIN_PY_SKEL = """from machine import Pin
472
+ import time
473
+
474
+ led = Pin("LED", Pin.OUT)
475
+ while True:
476
+ led.toggle()
477
+ time.sleep(0.25)
478
+ """
479
+
469
480
  TEST_DEFAULT = """#!/usr/bin/env python
470
481
  # -*- coding: utf-8 -*-
471
482
  import logging
@@ -780,12 +791,37 @@ a:hover.icon.icon-home {
780
791
  }
781
792
  return extras.get(base_class, extras["CleepModule"])
782
793
 
794
+ @staticmethod
795
+ def _skel_str(value, default="TODO"):
796
+ """Sanitize a free-text value for embedding as a single-quoted Python string."""
797
+ text = re.sub(r"[\r\n\t]+", " ", str(value or "")).strip()
798
+ for char in ("\\", "'", '"', "`", "$"):
799
+ text = text.replace(char, "")
800
+ if not text:
801
+ return "'%s'" % default
802
+ return "'%s'" % text
803
+
804
+ @staticmethod
805
+ def _skel_url(value):
806
+ """Sanitize a URL for MODULE_URLSITE (None when empty)."""
807
+ text = str(value or "").strip()
808
+ for char in ("\\", "'", '"', "`", "$", " "):
809
+ text = text.replace(char, "")
810
+ if not text:
811
+ return "None"
812
+ return "'%s'" % text
813
+
783
814
  def create(
784
815
  self,
785
816
  module_name,
786
817
  base_class="CleepModule",
787
818
  category="APPLICATION",
788
819
  tags=None,
820
+ deps=None,
821
+ description=None,
822
+ long_description=None,
823
+ url=None,
824
+ firmware=None,
789
825
  with_firmware=False,
790
826
  ):
791
827
  """
@@ -796,7 +832,12 @@ a:hover.icon.icon-home {
796
832
  base_class (string): core base class (CleepModule, CleepRenderer, ...)
797
833
  category (string): CATEGORIES value
798
834
  tags (list): optional MODULE_TAGS values
799
- with_firmware (bool): also scaffold firmwares/<module>/ UF2 sources
835
+ deps (list): optional MODULE_DEPS values (other Cleep apps)
836
+ description (string): optional MODULE_DESCRIPTION
837
+ long_description (string): optional MODULE_LONGDESCRIPTION
838
+ url (string): optional MODULE_URLSITE (homepage / GitHub / service)
839
+ firmware (string): optional firmware kind (``uf2`` or ``micropython``)
840
+ with_firmware (bool): deprecated alias for ``firmware="uf2"``
800
841
  """
801
842
  module_name = re.sub('[^0-9a-zA-Z]+', '', module_name).lstrip('0123456789').lower()
802
843
  self.logger.debug('Module name to create: %s' % module_name)
@@ -812,12 +853,30 @@ a:hover.icon.icon-home {
812
853
  self.logger.error('Unsupported category "%s"' % category)
813
854
  return False
814
855
 
856
+ # Legacy bool flag from older callers / --firmware without kind.
857
+ if firmware is None and with_firmware:
858
+ firmware = "uf2"
859
+ if firmware is not None:
860
+ firmware = str(firmware).strip().lower()
861
+ if firmware not in self.FIRMWARE_KINDS:
862
+ self.logger.error('Unsupported firmware kind "%s"' % firmware)
863
+ return False
864
+
815
865
  if os.path.exists(path):
816
866
  self.logger.error('Module "%s" already exists in "%s"' % (module_name, path))
817
867
  return False
818
868
 
819
869
  tags = [str(tag).strip() for tag in (tags or []) if str(tag).strip()]
820
870
  tags_repr = "[" + ", ".join("'%s'" % tag.replace("'", "") for tag in tags) + "]"
871
+ deps_clean = []
872
+ for dep in deps or []:
873
+ dep_name = re.sub('[^0-9a-zA-Z]+', '', str(dep)).lstrip('0123456789').lower()
874
+ if dep_name and dep_name != module_name and dep_name not in deps_clean:
875
+ deps_clean.append(dep_name)
876
+ deps_repr = "[" + ", ".join("'%s'" % dep for dep in deps_clean) + "]"
877
+ description_repr = self._skel_str(description)
878
+ long_description_repr = self._skel_str(long_description)
879
+ url_repr = self._skel_url(url)
821
880
  extras = self.__base_class_extras(base_class)
822
881
 
823
882
  title = 'Welcome to %s\'s documentation!' % module_name.capitalize()
@@ -831,6 +890,10 @@ a:hover.icon.icon-home {
831
890
  'MODULE_NAME_CAPITALIZED': module_name.capitalize(),
832
891
  'BASE_CLASS': base_class,
833
892
  'MODULE_TAGS': tags_repr,
893
+ 'MODULE_DEPS': deps_repr,
894
+ 'MODULE_DESCRIPTION': description_repr,
895
+ 'MODULE_LONGDESCRIPTION': long_description_repr,
896
+ 'MODULE_URLSITE': url_repr,
834
897
  'MODULE_CATEGORY': category,
835
898
  'EXTRA_IMPORTS': extras['extra_imports'],
836
899
  'EXTRA_MEMBERS': extras['extra_members'],
@@ -891,13 +954,35 @@ a:hover.icon.icon-home {
891
954
  shutil.rmtree(path)
892
955
  return False
893
956
 
894
- if with_firmware:
895
- fw_dir = os.path.join(path, "firmwares", module_name)
896
- fw_ctx = {
897
- "MODULE_NAME": module_name,
898
- "MODULE_NAME_CAPITALIZED": module_name.capitalize(),
899
- }
900
- # Single-quoted echoes: CMakeLists contains $ENV{...} that must not expand.
957
+ if firmware:
958
+ if not self.__scaffold_firmware(c, path, module_name, firmware):
959
+ shutil.rmtree(path)
960
+ return False
961
+
962
+ self.logger.info('Done')
963
+ return True
964
+
965
+ def __scaffold_firmware(self, console, module_path, module_name, firmware_kind):
966
+ """
967
+ Write firmwares/<module>/ skeleton for the given kind.
968
+
969
+ Args:
970
+ console (Console): command runner
971
+ module_path (string): module root under MODULES_SRC
972
+ module_name (string): module name
973
+ firmware_kind (string): ``uf2`` or ``micropython``
974
+
975
+ Returns:
976
+ bool: True on success
977
+ """
978
+ fw_dir = os.path.join(module_path, "firmwares", module_name)
979
+ fw_ctx = {
980
+ "MODULE_NAME": module_name,
981
+ "MODULE_NAME_CAPITALIZED": module_name.capitalize(),
982
+ "FIRMWARE_KIND": firmware_kind,
983
+ }
984
+ # Single-quoted echoes: CMakeLists contains $ENV{...} that must not expand.
985
+ if firmware_kind == "uf2":
901
986
  fw_cmd = """
902
987
  /bin/mkdir -p "%(FW_DIR)s"
903
988
  /bin/echo '%(MANIFEST)s' > "%(FW_DIR)s/firmware.manifest"
@@ -909,16 +994,24 @@ a:hover.icon.icon-home {
909
994
  "CMAKE": (self.FIRMWARE_CMAKE_SKEL % fw_ctx).replace("'", "'\\''"),
910
995
  "MAIN_C": self.FIRMWARE_MAIN_C_SKEL.replace("'", "'\\''"),
911
996
  }
912
- fw_resp = c.command(fw_cmd, 10)
913
- if fw_resp["killed"] or fw_resp["returncode"] != 0:
914
- self.logger.error(
915
- "Error creating firmware skeleton: %s",
916
- "killed" if fw_resp["killed"] else fw_resp["stderr"],
917
- )
918
- shutil.rmtree(path)
919
- return False
997
+ else:
998
+ fw_cmd = """
999
+ /bin/mkdir -p "%(FW_DIR)s/files"
1000
+ /bin/echo '%(MANIFEST)s' > "%(FW_DIR)s/firmware.manifest"
1001
+ /bin/echo '%(MAIN_PY)s' > "%(FW_DIR)s/files/main.py"
1002
+ """ % {
1003
+ "FW_DIR": fw_dir,
1004
+ "MANIFEST": (self.FIRMWARE_MANIFEST_SKEL % fw_ctx).replace("'", "'\\''"),
1005
+ "MAIN_PY": self.FIRMWARE_MAIN_PY_SKEL.replace("'", "'\\''"),
1006
+ }
920
1007
 
921
- self.logger.info('Done')
1008
+ fw_resp = console.command(fw_cmd, 10)
1009
+ if fw_resp["killed"] or fw_resp["returncode"] != 0:
1010
+ self.logger.error(
1011
+ "Error creating firmware skeleton: %s",
1012
+ "killed" if fw_resp["killed"] else fw_resp["stderr"],
1013
+ )
1014
+ return False
922
1015
  return True
923
1016
 
924
1017
  def delete(self, module_name):
@@ -14,7 +14,6 @@ from datetime import datetime, timezone
14
14
  from typing import Any
15
15
 
16
16
  import cleepcli.config as config
17
- from cleepcli.console import Console
18
17
 
19
18
 
20
19
  class PicoError(Exception):
@@ -26,11 +25,69 @@ class Pico:
26
25
  Install / update the Pico SDK and compile app UF2 firmwares.
27
26
  """
28
27
 
28
+ # Machine-readable step markers for developer UI progress (stdout).
29
+ STEP_MARKER_PREFIX = "CLEEP_PICO_STEP:"
30
+ INSTALL_STEPS = (
31
+ ("toolchain", "Install apt toolchain (cmake, arm-none-eabi)"),
32
+ ("clone", "Clone pico-sdk"),
33
+ ("submodules", "Initialize pico-sdk submodules"),
34
+ ("finalize", "Write SDK metadata"),
35
+ )
36
+ UPDATE_STEPS = (
37
+ ("toolchain", "Check apt toolchain"),
38
+ ("fetch", "Fetch latest pico-sdk"),
39
+ ("reset", "Reset pico-sdk to origin/master"),
40
+ ("submodules", "Update pico-sdk submodules"),
41
+ )
42
+
29
43
  def __init__(self):
30
44
  self.logger = logging.getLogger(self.__class__.__name__)
31
45
 
32
46
  # ------------------------------------------------------------------ SDK
33
47
 
48
+ def _emit(self, message: str) -> None:
49
+ """Print a line to stdout (streamed by developer EndlessConsole)."""
50
+ # print only: cleep-cli logging also uses stdout and would duplicate lines.
51
+ print(message, flush=True)
52
+ self.logger.debug("%s", message)
53
+
54
+ def _emit_step(self, index: int, total: int, step_id: str, label: str) -> None:
55
+ """Emit a progress marker + human-readable step header."""
56
+ self._emit(
57
+ "%s%s/%s:%s:%s"
58
+ % (self.STEP_MARKER_PREFIX, index, total, step_id, label)
59
+ )
60
+ self._emit("=== [%s/%s] %s ===" % (index, total, label))
61
+
62
+ def _run_streamed(self, args: list[str] | str, error_prefix: str, shell: bool = False) -> None:
63
+ """
64
+ Run a command and stream combined stdout/stderr line by line.
65
+
66
+ Args:
67
+ args: argv list, or shell command string when shell=True
68
+ error_prefix: message prefix on non-zero exit
69
+ shell: pass command through the shell
70
+ """
71
+ env = os.environ.copy()
72
+ env["GIT_TERMINAL_PROMPT"] = "0"
73
+ # Make apt less chatty about progress bars that redraw the same line.
74
+ env.setdefault("DEBIAN_FRONTEND", "noninteractive")
75
+ proc = subprocess.Popen(
76
+ args,
77
+ stdout=subprocess.PIPE,
78
+ stderr=subprocess.STDOUT,
79
+ text=True,
80
+ bufsize=1,
81
+ shell=shell,
82
+ env=env,
83
+ )
84
+ assert proc.stdout is not None
85
+ for line in proc.stdout:
86
+ print(line, end="", flush=True)
87
+ returncode = proc.wait()
88
+ if returncode != 0:
89
+ raise PicoError("%s (exit %s)" % (error_prefix, returncode))
90
+
34
91
  def _toolchain_ok(self) -> bool:
35
92
  return bool(shutil.which("cmake") and shutil.which("arm-none-eabi-gcc"))
36
93
 
@@ -104,27 +161,36 @@ class Pico:
104
161
  )
105
162
  return data
106
163
 
107
- def _ensure_toolchain(self) -> None:
164
+ def _ensure_toolchain(self, *, emit_steps: bool = False, step_index: int = 1, step_total: int = 4) -> None:
165
+ """
166
+ Ensure cmake + arm-none-eabi-gcc are on PATH (apt install if needed).
167
+
168
+ Args:
169
+ emit_steps: print step markers / headers for UI progress
170
+ step_index: 1-based step index when emit_steps
171
+ step_total: total steps when emit_steps
172
+ """
173
+ label = self.INSTALL_STEPS[0][1]
174
+ if emit_steps:
175
+ self._emit_step(step_index, step_total, "toolchain", label)
108
176
  if self._toolchain_ok():
177
+ self._emit("Toolchain already present (cmake, arm-none-eabi-gcc) — skipping apt.")
109
178
  return
110
179
  packages = " ".join(config.PICO_TOOLCHAIN_PACKAGES)
111
- self.logger.info("Installing Pico toolchain packages: %s", packages)
112
- console = Console()
180
+ self._emit("Installing Pico toolchain packages via apt: %s" % packages)
181
+ self._emit("(This step alone can take several minutes on a Raspberry Pi.)")
182
+ # No -qq: stream apt download/install lines to the developer console.
113
183
  cmd = (
114
184
  "export DEBIAN_FRONTEND=noninteractive; "
115
- "apt-get update -qq && apt-get install -y -qq %s" % packages
185
+ "apt-get update && apt-get install -y %s" % packages
116
186
  )
117
- result = console.command(cmd, 600.0)
118
- if result.get("killed") or result.get("returncode") != 0:
119
- raise PicoError(
120
- "Failed to install toolchain packages: %s"
121
- % ("\n".join(result.get("stderr") or []) or "apt error")
122
- )
187
+ self._run_streamed(cmd, "Failed to install toolchain packages", shell=True)
123
188
  if not self._toolchain_ok():
124
189
  raise PicoError(
125
190
  "Toolchain still missing after apt install "
126
191
  "(need cmake and arm-none-eabi-gcc on PATH)"
127
192
  )
193
+ self._emit("Toolchain install complete.")
128
194
 
129
195
  def sdk_info(self) -> dict[str, Any]:
130
196
  """Return SDK installation metadata."""
@@ -132,21 +198,29 @@ class Pico:
132
198
 
133
199
  def sdk_install(self) -> dict[str, Any]:
134
200
  """Install toolchain packages + clone pico-sdk with submodules."""
135
- self._ensure_toolchain()
201
+ total = len(self.INSTALL_STEPS)
202
+ self._emit(
203
+ "Pico SDK install started (often 10+ minutes on first run — "
204
+ "apt toolchain + git clone + submodules)."
205
+ )
206
+ self._ensure_toolchain(emit_steps=True, step_index=1, step_total=total)
207
+
136
208
  sdk_dir = config.PICO_SDK_DIR
137
209
  if os.path.isdir(os.path.join(sdk_dir, ".git")):
138
- self.logger.info("Pico SDK already installed at %s — updating", sdk_dir)
210
+ self._emit("Pico SDK already installed at %s — switching to update." % sdk_dir)
139
211
  return self.sdk_update()
140
212
 
141
213
  os.makedirs(os.path.dirname(sdk_dir), exist_ok=True)
142
214
  if os.path.exists(sdk_dir):
143
215
  shutil.rmtree(sdk_dir)
144
216
 
145
- self.logger.info("Cloning Pico SDK into %s", sdk_dir)
146
- clone = subprocess.run(
217
+ self._emit_step(2, total, "clone", self.INSTALL_STEPS[1][1])
218
+ self._emit("Cloning %s into %s" % (config.PICO_SDK_REPO, sdk_dir))
219
+ self._run_streamed(
147
220
  [
148
221
  "git",
149
222
  "clone",
223
+ "--progress",
150
224
  "--depth",
151
225
  "1",
152
226
  "--branch",
@@ -154,57 +228,80 @@ class Pico:
154
228
  config.PICO_SDK_REPO,
155
229
  sdk_dir,
156
230
  ],
157
- capture_output=True,
158
- text=True,
231
+ "git clone failed",
159
232
  )
160
- if clone.returncode != 0:
161
- raise PicoError(
162
- "git clone failed: %s" % ((clone.stderr or clone.stdout or "").strip())
163
- )
164
233
 
165
- sub = subprocess.run(
166
- ["git", "-C", sdk_dir, "submodule", "update", "--init"],
167
- capture_output=True,
168
- text=True,
234
+ self._emit_step(3, total, "submodules", self.INSTALL_STEPS[2][1])
235
+ self._run_streamed(
236
+ [
237
+ "git",
238
+ "-C",
239
+ sdk_dir,
240
+ "submodule",
241
+ "update",
242
+ "--init",
243
+ "--progress",
244
+ ],
245
+ "git submodule update failed",
169
246
  )
170
- if sub.returncode != 0:
171
- raise PicoError(
172
- "git submodule update failed: %s"
173
- % ((sub.stderr or sub.stdout or "").strip())
174
- )
175
247
 
248
+ self._emit_step(4, total, "finalize", self.INSTALL_STEPS[3][1])
176
249
  meta = self._write_meta()
177
- self.logger.info(
178
- "Pico SDK installed (%s / %s)", meta.get("version"), meta.get("revision")
250
+ self._emit(
251
+ "Pico SDK installed (%s / %s)"
252
+ % (meta.get("version"), meta.get("revision"))
253
+ )
254
+ self._emit(
255
+ "%s%s/%s:done:Install complete"
256
+ % (self.STEP_MARKER_PREFIX, total, total)
179
257
  )
180
258
  return meta
181
259
 
182
260
  def sdk_update(self) -> dict[str, Any]:
183
261
  """Pull latest pico-sdk and refresh submodules."""
184
- self._ensure_toolchain()
262
+ total = len(self.UPDATE_STEPS)
263
+ self._emit("Pico SDK update started.")
264
+ self._ensure_toolchain(emit_steps=True, step_index=1, step_total=total)
265
+
185
266
  sdk_dir = config.PICO_SDK_DIR
186
267
  if not os.path.isdir(os.path.join(sdk_dir, ".git")):
187
268
  return self.sdk_install()
188
269
 
189
- self.logger.info("Updating Pico SDK in %s", sdk_dir)
190
- for args in (
191
- ["git", "-C", sdk_dir, "fetch", "--depth", "1", "origin", "master"],
270
+ self._emit_step(2, total, "fetch", self.UPDATE_STEPS[1][1])
271
+ self._run_streamed(
272
+ ["git", "-C", sdk_dir, "fetch", "--progress", "--depth", "1", "origin", "master"],
273
+ "SDK fetch failed",
274
+ )
275
+
276
+ self._emit_step(3, total, "reset", self.UPDATE_STEPS[2][1])
277
+ self._run_streamed(
192
278
  ["git", "-C", sdk_dir, "reset", "--hard", "origin/master"],
193
- ["git", "-C", sdk_dir, "submodule", "update", "--init", "--recursive"],
194
- ):
195
- result = subprocess.run(args, capture_output=True, text=True)
196
- if result.returncode != 0:
197
- raise PicoError(
198
- "SDK update failed (%s): %s"
199
- % (
200
- " ".join(args),
201
- (result.stderr or result.stdout or "").strip(),
202
- )
203
- )
279
+ "SDK reset failed",
280
+ )
281
+
282
+ self._emit_step(4, total, "submodules", self.UPDATE_STEPS[3][1])
283
+ self._run_streamed(
284
+ [
285
+ "git",
286
+ "-C",
287
+ sdk_dir,
288
+ "submodule",
289
+ "update",
290
+ "--init",
291
+ "--recursive",
292
+ "--progress",
293
+ ],
294
+ "SDK submodule update failed",
295
+ )
204
296
 
205
297
  meta = self._write_meta()
206
- self.logger.info(
207
- "Pico SDK updated (%s / %s)", meta.get("version"), meta.get("revision")
298
+ self._emit(
299
+ "Pico SDK updated (%s / %s)"
300
+ % (meta.get("version"), meta.get("revision"))
301
+ )
302
+ self._emit(
303
+ "%s%s/%s:done:Update complete"
304
+ % (self.STEP_MARKER_PREFIX, total, total)
208
305
  )
209
306
  return meta
210
307
 
@@ -213,7 +310,7 @@ class Pico:
213
310
  sdk_dir = config.PICO_SDK_DIR
214
311
  if os.path.isdir(sdk_dir):
215
312
  shutil.rmtree(sdk_dir)
216
- self.logger.info("Removed %s", sdk_dir)
313
+ self._emit("Removed %s" % sdk_dir)
217
314
  if os.path.isfile(config.PICO_SDK_META):
218
315
  os.remove(config.PICO_SDK_META)
219
316
  return {
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- VERSION = "1.49.3"
4
+ VERSION = "1.49.5"
@@ -18,7 +18,7 @@ from watchdog.events import (
18
18
  import watchdog.events as events
19
19
  from .cleepapi import CleepApi
20
20
  from .file import File
21
- from .watchsvc import WATCH_SERVICE
21
+ from .watchsvc import WATCH_SERVICE, consume_skip_catchup_once
22
22
 
23
23
  _WATCHED_EVENT_TYPES = (
24
24
  EVENT_TYPE_CREATED,
@@ -558,6 +558,13 @@ class CleepWatchdog:
558
558
  )
559
559
  return False
560
560
 
561
+ # One-shot flag from ``watchsvc start --skip-catchup`` (create-app resume).
562
+ if consume_skip_catchup_once():
563
+ self.logger.info(
564
+ "Skipping catch-up sync (one-shot flag from watchsvc start)"
565
+ )
566
+ self.catch_up = False
567
+
561
568
  # Catch-up before inotify: Desktop (or editors) may have written while
562
569
  # this process was stopped (cleep restart, create-app pause, boot).
563
570
  if self.catch_up:
@@ -16,6 +16,48 @@ from .console import Console
16
16
 
17
17
  WATCH_SERVICE = "cleep-watch.service"
18
18
  WATCH_UNIT_DST = "/lib/systemd/system/%s" % WATCH_SERVICE
19
+ # One-shot flag for ``watchsvc start --skip-catchup``: watch consumes and deletes it.
20
+ SKIP_CATCHUP_ONCE_PATH = "/run/cleep-watch.skip-catchup"
21
+
22
+
23
+ def arm_skip_catchup_once():
24
+ """
25
+ Arm a one-shot skip of watch catch-up on the next watch process start.
26
+
27
+ Returns:
28
+ bool: True if the flag file was written
29
+ """
30
+ try:
31
+ directory = os.path.dirname(SKIP_CATCHUP_ONCE_PATH)
32
+ if directory:
33
+ os.makedirs(directory, exist_ok=True)
34
+ with open(SKIP_CATCHUP_ONCE_PATH, "w", encoding="utf-8") as handle:
35
+ handle.write("1\n")
36
+ return True
37
+ except OSError as error:
38
+ logging.getLogger("WatchService").error(
39
+ "Unable to arm skip-catchup flag %s: %s",
40
+ SKIP_CATCHUP_ONCE_PATH,
41
+ error,
42
+ )
43
+ return False
44
+
45
+
46
+ def consume_skip_catchup_once():
47
+ """
48
+ Consume the one-shot skip-catchup flag if present.
49
+
50
+ Returns:
51
+ bool: True when catch-up must be skipped for this watch start
52
+ """
53
+ if not os.path.exists(SKIP_CATCHUP_ONCE_PATH):
54
+ return False
55
+ try:
56
+ os.remove(SKIP_CATCHUP_ONCE_PATH)
57
+ except OSError:
58
+ # Still honor the flag even if unlink fails (avoid surprise restart).
59
+ pass
60
+ return True
19
61
 
20
62
 
21
63
  def bundled_unit_path():
@@ -207,9 +249,15 @@ class WatchService:
207
249
  )
208
250
  return True
209
251
 
210
- def start(self):
252
+ def start(self, skip_catchup=False):
211
253
  """
212
- Start the unit (catch-up sync runs on ExecStart).
254
+ Start the unit.
255
+
256
+ Args:
257
+ skip_catchup (bool): when True, arm a one-shot flag so the next
258
+ watch process skips catch-up sync/restart (e.g. resume after
259
+ create-app already ran ``modsync``). Default False: catch-up
260
+ runs on ExecStart.
213
261
 
214
262
  Returns:
215
263
  bool: True on success
@@ -217,6 +265,8 @@ class WatchService:
217
265
  if not os.path.isfile(WATCH_UNIT_DST):
218
266
  if not self.install():
219
267
  return False
268
+ if skip_catchup and not arm_skip_catchup_once():
269
+ return False
220
270
  resp = self._systemctl("start", WATCH_SERVICE)
221
271
  if not self._ok(resp):
222
272
  self.logger.error(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cleepcli
3
- Version: 1.49.3
3
+ Version: 1.49.5
4
4
  Summary: Cleep-cli helps developers to build great Cleep applications from command line.
5
5
  Home-page: https://github.com/CleepDevice/cleep-cli
6
6
  Author: Tanguy Bonneau
@@ -98,6 +98,12 @@ The unit runs `cleep-cli watch`, survives `systemctl restart cleep`, and on each
98
98
 
99
99
  After `pip install` / upgrade of `cleepcli`, the next `watchsvc install` (idempotent ensure) restarts the unit when the on-disk binary is newer than the running process, so the watcher loads the new CLI without a forced bounce on every Cleep boot.
100
100
 
101
+ Resume watching after a deliberate pause (e.g. create-app already ran `modsync`) without catch-up restarting Cleep:
102
+
103
+ ```
104
+ cleep-cli watchsvc start --skip-catchup
105
+ ```
106
+
101
107
  Manual one-shot resync (when the UI looks stale) — `syncall` also mints a fresh asset bust and reloads the device UI:
102
108
 
103
109
  ```
@@ -91,6 +91,8 @@ def test_watch_catch_up_calls_sync_all():
91
91
  "cleepcli.watch.ActionsExecutor"
92
92
  ) as executor_cls, patch(
93
93
  "cleepcli.watch.time.sleep", side_effect=KeyboardInterrupt
94
+ ), patch(
95
+ "cleepcli.watch.consume_skip_catchup_once", return_value=False
94
96
  ):
95
97
  file_cls.return_value.sync_all.return_value = True
96
98
  handler = handler_cls.return_value
@@ -117,7 +119,9 @@ def test_watch_catch_up_fails_when_backend_restart_fails():
117
119
  "cleepcli.watch.CleepHandler"
118
120
  ) as handler_cls, patch(
119
121
  "cleepcli.watch.ActionsExecutor"
120
- ) as executor_cls:
122
+ ) as executor_cls, patch(
123
+ "cleepcli.watch.consume_skip_catchup_once", return_value=False
124
+ ):
121
125
  file_cls.return_value.sync_all.return_value = True
122
126
  handler_cls.return_value._watched = {"/tmp"}
123
127
  executor = executor_cls.return_value
@@ -140,6 +144,8 @@ def test_watch_skip_catch_up():
140
144
  "cleepcli.watch.ActionsExecutor"
141
145
  ) as executor_cls, patch(
142
146
  "cleepcli.watch.time.sleep", side_effect=KeyboardInterrupt
147
+ ), patch(
148
+ "cleepcli.watch.consume_skip_catchup_once", return_value=False
143
149
  ):
144
150
  handler = handler_cls.return_value
145
151
  handler._watched = {"/tmp"}
@@ -155,3 +161,30 @@ def test_watch_skip_catch_up():
155
161
  executor.cleep.ensure_frontend_nocache.assert_not_called()
156
162
  executor.cleep.restart_backend.assert_not_called()
157
163
  executor.cleep.restart_frontend.assert_not_called()
164
+
165
+
166
+ def test_watch_consumes_skip_catchup_once_flag():
167
+ CleepWatchdog = _import_watch_with_fake_watchdog()
168
+
169
+ with patch("cleepcli.watch.File") as file_cls, patch(
170
+ "cleepcli.watch.os.path.exists", return_value=True
171
+ ), patch("cleepcli.watch.Observer"), patch(
172
+ "cleepcli.watch.CleepHandler"
173
+ ) as handler_cls, patch(
174
+ "cleepcli.watch.ActionsExecutor"
175
+ ) as executor_cls, patch(
176
+ "cleepcli.watch.time.sleep", side_effect=KeyboardInterrupt
177
+ ), patch(
178
+ "cleepcli.watch.consume_skip_catchup_once", return_value=True
179
+ ):
180
+ handler = handler_cls.return_value
181
+ handler._watched = {"/tmp"}
182
+ handler.schedule_all = Mock()
183
+ executor = executor_cls.return_value
184
+ executor.cleep.ensure_frontend_nocache = Mock()
185
+ executor.cleep.restart_backend = Mock()
186
+
187
+ watchdog = CleepWatchdog("https://127.0.0.1:443", catch_up=True)
188
+ assert watchdog.watch() is True
189
+ file_cls.return_value.sync_all.assert_not_called()
190
+ executor.cleep.restart_backend.assert_not_called()
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ from cleepcli.module import Module
5
+
6
+
7
+ def test_test_default_is_pytest_style():
8
+ rendered = Module.TEST_DEFAULT % {
9
+ "MODULE_NAME": "demo",
10
+ "MODULE_NAME_CAPITALIZED": "Demo",
11
+ }
12
+ assert "import pytest" in rendered
13
+ assert "def test_get_module_config(cleep_session):" in rendered
14
+ assert "def test_my_function(cleep_session):" in rendered
15
+ assert "get_log_level" in rendered
16
+ assert "unittest.TestCase" not in rendered
17
+ assert "hybrid" not in rendered.lower()
18
+
19
+
20
+ def test_conftest_default_exposes_cleep_session():
21
+ assert "cleep.libs.tests.fixtures" in Module.CONFTEST_DEFAULT
22
+
23
+
24
+ def test_pytest_ini_default_sets_pythonpath():
25
+ assert "pythonpath = ." in Module.PYTEST_INI_DEFAULT
26
+ assert "testpaths = tests" in Module.PYTEST_INI_DEFAULT
27
+
28
+
29
+ def test_python_module_skel_accepts_module_deps():
30
+ rendered = Module.PYTHON_MODULE_SKEL % {
31
+ "MODULE_NAME": "demo",
32
+ "MODULE_NAME_CAPITALIZED": "Demo",
33
+ "BASE_CLASS": "CleepModule",
34
+ "MODULE_TAGS": "['led']",
35
+ "MODULE_DEPS": "['gpio', 'sensors']",
36
+ "MODULE_DESCRIPTION": "'Short summary'",
37
+ "MODULE_LONGDESCRIPTION": "'Longer market text'",
38
+ "MODULE_URLSITE": "'https://example.com'",
39
+ "MODULE_CATEGORY": "APPLICATION",
40
+ "EXTRA_IMPORTS": "",
41
+ "EXTRA_MEMBERS": "",
42
+ "EXTRA_METHODS": "",
43
+ }
44
+ assert "MODULE_DEPS = ['gpio', 'sensors']" in rendered
45
+ assert "MODULE_DESCRIPTION = 'Short summary'" in rendered
46
+ assert "MODULE_LONGDESCRIPTION = 'Longer market text'" in rendered
47
+ assert "MODULE_URLSITE = 'https://example.com'" in rendered
48
+
49
+
50
+ def test_skel_str_and_url_helpers():
51
+ assert Module._skel_str("") == "'TODO'"
52
+ assert Module._skel_str("Hello 'world'") == "'Hello world'"
53
+ assert Module._skel_url("") == "None"
54
+ assert Module._skel_url(" https://example.com ") == "'https://example.com'"
55
+
56
+
57
+ def test_firmware_manifest_skel_accepts_kind():
58
+ rendered = Module.FIRMWARE_MANIFEST_SKEL % {
59
+ "MODULE_NAME": "demo",
60
+ "MODULE_NAME_CAPITALIZED": "Demo",
61
+ "FIRMWARE_KIND": "micropython",
62
+ }
63
+ assert '"kind": "micropython"' in rendered
64
+
65
+
66
+ def test_firmware_main_py_skel_is_micropython():
67
+ assert "from machine import Pin" in Module.FIRMWARE_MAIN_PY_SKEL
68
+ assert "led.toggle()" in Module.FIRMWARE_MAIN_PY_SKEL
@@ -45,19 +45,14 @@ class PicoSdkTests(unittest.TestCase):
45
45
  self.assertFalse(os.path.isfile(self.meta))
46
46
  self.assertFalse(info["installed"])
47
47
 
48
- @patch("cleepcli.pico.subprocess.run")
48
+ @patch.object(Pico, "_run_streamed")
49
49
  @patch.object(Pico, "_ensure_toolchain")
50
- def test_sdk_install_clones(self, _toolchain, run_mock):
51
- run_mock.return_value = MagicMock(returncode=0, stdout="abc123\n", stderr="")
52
- os.makedirs(os.path.join(self.sdk_dir, ".git"), exist_ok=True)
53
- # Pretend clone created .git by side effect of first call
54
- def _run(args, **_kwargs):
55
- if args[0:2] == ["git", "clone"]:
50
+ def test_sdk_install_clones(self, _toolchain, streamed_mock):
51
+ def _streamed(args, error_prefix, shell=False):
52
+ if isinstance(args, list) and args[0:2] == ["git", "clone"]:
56
53
  os.makedirs(os.path.join(self.sdk_dir, ".git"), exist_ok=True)
57
- return MagicMock(returncode=0, stdout="deadbee\n", stderr="")
58
54
 
59
- run_mock.side_effect = _run
60
- # Start without sdk
55
+ streamed_mock.side_effect = _streamed
61
56
  if os.path.exists(self.sdk_dir):
62
57
  import shutil
63
58
 
@@ -69,6 +64,7 @@ class PicoSdkTests(unittest.TestCase):
69
64
  meta = self.pico.sdk_install()
70
65
  self.assertTrue(meta["installed"])
71
66
  self.assertTrue(os.path.isfile(self.meta))
67
+ self.assertGreaterEqual(streamed_mock.call_count, 2)
72
68
 
73
69
  def test_status_empty_firmwares(self):
74
70
  modules = os.path.join(self.root, "modules")
@@ -4,7 +4,13 @@
4
4
  import os
5
5
  from unittest.mock import Mock, patch
6
6
 
7
- from cleepcli.watchsvc import WatchService, WATCH_UNIT_DST, bundled_unit_path
7
+ from cleepcli.watchsvc import (
8
+ WatchService,
9
+ WATCH_UNIT_DST,
10
+ arm_skip_catchup_once,
11
+ bundled_unit_path,
12
+ consume_skip_catchup_once,
13
+ )
8
14
 
9
15
 
10
16
  def test_bundled_unit_path_exists():
@@ -145,3 +151,42 @@ def test_status_active():
145
151
  }
146
152
  with patch("cleepcli.watchsvc.os.path.isfile", return_value=True):
147
153
  assert svc.status() == "active"
154
+
155
+
156
+ def test_start_skip_catchup_arms_flag():
157
+ svc = WatchService()
158
+ svc.console = Mock()
159
+ svc.console.command.return_value = {"returncode": 0, "stdout": "", "stderr": ""}
160
+
161
+ with patch("cleepcli.watchsvc.os.path.isfile", return_value=True), patch(
162
+ "cleepcli.watchsvc.arm_skip_catchup_once", return_value=True
163
+ ) as arm:
164
+ assert svc.start(skip_catchup=True) is True
165
+ arm.assert_called_once_with()
166
+ svc.console.command.assert_called_with(
167
+ "/bin/systemctl start %s" % "cleep-watch.service", 60.0
168
+ )
169
+
170
+
171
+ def test_start_default_does_not_arm_skip_catchup():
172
+ svc = WatchService()
173
+ svc.console = Mock()
174
+ svc.console.command.return_value = {"returncode": 0, "stdout": "", "stderr": ""}
175
+
176
+ with patch("cleepcli.watchsvc.os.path.isfile", return_value=True), patch(
177
+ "cleepcli.watchsvc.arm_skip_catchup_once"
178
+ ) as arm:
179
+ assert svc.start() is True
180
+ arm.assert_not_called()
181
+
182
+
183
+ def test_arm_and_consume_skip_catchup_once(tmp_path, monkeypatch):
184
+ flag = tmp_path / "cleep-watch.skip-catchup"
185
+ monkeypatch.setattr("cleepcli.watchsvc.SKIP_CATCHUP_ONCE_PATH", str(flag))
186
+
187
+ assert consume_skip_catchup_once() is False
188
+ assert arm_skip_catchup_once() is True
189
+ assert flag.is_file()
190
+ assert consume_skip_catchup_once() is True
191
+ assert not flag.exists()
192
+ assert consume_skip_catchup_once() is False
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- from cleepcli.module import Module
5
-
6
-
7
- def test_test_default_is_pytest_style():
8
- rendered = Module.TEST_DEFAULT % {
9
- "MODULE_NAME": "demo",
10
- "MODULE_NAME_CAPITALIZED": "Demo",
11
- }
12
- assert "import pytest" in rendered
13
- assert "def test_get_module_config(cleep_session):" in rendered
14
- assert "def test_my_function(cleep_session):" in rendered
15
- assert "get_log_level" in rendered
16
- assert "unittest.TestCase" not in rendered
17
- assert "hybrid" not in rendered.lower()
18
-
19
-
20
- def test_conftest_default_exposes_cleep_session():
21
- assert "cleep.libs.tests.fixtures" in Module.CONFTEST_DEFAULT
22
-
23
-
24
- def test_pytest_ini_default_sets_pythonpath():
25
- assert "pythonpath = ." in Module.PYTEST_INI_DEFAULT
26
- assert "testpaths = tests" in Module.PYTEST_INI_DEFAULT
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