cleepcli 1.49.3__tar.gz → 1.49.4__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 (43) hide show
  1. {cleepcli-1.49.3/cleepcli.egg-info → cleepcli-1.49.4}/PKG-INFO +7 -1
  2. {cleepcli-1.49.3 → cleepcli-1.49.4}/README.md +6 -0
  3. {cleepcli-1.49.3 → cleepcli-1.49.4}/bin/ccli +12 -2
  4. {cleepcli-1.49.3 → cleepcli-1.49.4}/bin/cleep-cli +12 -2
  5. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/version.py +1 -1
  6. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/watch.py +8 -1
  7. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/watchsvc.py +52 -2
  8. {cleepcli-1.49.3 → cleepcli-1.49.4/cleepcli.egg-info}/PKG-INFO +7 -1
  9. {cleepcli-1.49.3 → cleepcli-1.49.4}/tests/test_file_sync_all.py +34 -1
  10. {cleepcli-1.49.3 → cleepcli-1.49.4}/tests/test_watchsvc.py +46 -1
  11. {cleepcli-1.49.3 → cleepcli-1.49.4}/LICENSE +0 -0
  12. {cleepcli-1.49.3 → cleepcli-1.49.4}/MANIFEST.in +0 -0
  13. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/__init__.py +0 -0
  14. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/check.py +0 -0
  15. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/ci.py +0 -0
  16. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/cleepapi.py +0 -0
  17. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/config.py +0 -0
  18. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/console.py +0 -0
  19. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/docs.py +0 -0
  20. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/file.py +0 -0
  21. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/git.py +0 -0
  22. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/module.py +0 -0
  23. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/package.py +0 -0
  24. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/pico.py +0 -0
  25. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/systemd/cleep-watch.service +0 -0
  26. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/test.py +0 -0
  27. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli/tools.py +0 -0
  28. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli.egg-info/SOURCES.txt +0 -0
  29. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli.egg-info/dependency_links.txt +0 -0
  30. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli.egg-info/requires.txt +0 -0
  31. {cleepcli-1.49.3 → cleepcli-1.49.4}/cleepcli.egg-info/top_level.txt +0 -0
  32. {cleepcli-1.49.3 → cleepcli-1.49.4}/pyproject.toml +0 -0
  33. {cleepcli-1.49.3 → cleepcli-1.49.4}/requirements.txt +0 -0
  34. {cleepcli-1.49.3 → cleepcli-1.49.4}/setup.cfg +0 -0
  35. {cleepcli-1.49.3 → cleepcli-1.49.4}/setup.py +0 -0
  36. {cleepcli-1.49.3 → cleepcli-1.49.4}/tests/test_check.py +0 -0
  37. {cleepcli-1.49.3 → cleepcli-1.49.4}/tests/test_config.py +0 -0
  38. {cleepcli-1.49.3 → cleepcli-1.49.4}/tests/test_console.py +0 -0
  39. {cleepcli-1.49.3 → cleepcli-1.49.4}/tests/test_coverage.py +0 -0
  40. {cleepcli-1.49.3 → cleepcli-1.49.4}/tests/test_docs_breaking.py +0 -0
  41. {cleepcli-1.49.3 → cleepcli-1.49.4}/tests/test_module_scaffold.py +0 -0
  42. {cleepcli-1.49.3 → cleepcli-1.49.4}/tests/test_pico.py +0 -0
  43. {cleepcli-1.49.3 → cleepcli-1.49.4}/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.4
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
  ```
@@ -440,7 +440,12 @@ def watch(quiet, loglevel, rpc_url, skip_catchup):
440
440
  is_flag=True,
441
441
  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
442
  )
443
- def watchsvc_cmd(action, restart_if_active):
443
+ @click.option(
444
+ '--skip-catchup',
445
+ is_flag=True,
446
+ help='With start: resume watching without catch-up sync/restart (e.g. after create-app modsync).',
447
+ )
448
+ def watchsvc_cmd(action, restart_if_active, skip_catchup):
444
449
  """
445
450
  Manage the durable cleep-watch systemd unit.
446
451
 
@@ -455,6 +460,10 @@ def watchsvc_cmd(action, restart_if_active):
455
460
  the watcher when the on-disk binary is newer than the running process. Force with::
456
461
 
457
462
  cleep-cli watchsvc install --restart-if-active
463
+
464
+ Resume after a deliberate pause without restarting Cleep::
465
+
466
+ cleep-cli watchsvc start --skip-catchup
458
467
  """
459
468
  svc = WatchService()
460
469
  if action == 'status':
@@ -466,12 +475,13 @@ def watchsvc_cmd(action, restart_if_active):
466
475
 
467
476
  if action == 'install':
468
477
  ok = svc.install(restart_if_active=restart_if_active)
478
+ elif action == 'start':
479
+ ok = svc.start(skip_catchup=skip_catchup)
469
480
  else:
470
481
  handlers = {
471
482
  'uninstall': svc.uninstall,
472
483
  'enable': svc.enable,
473
484
  'disable': svc.disable,
474
- 'start': svc.start,
475
485
  'stop': svc.stop,
476
486
  'restart': svc.restart,
477
487
  }
@@ -440,7 +440,12 @@ def watch(quiet, loglevel, rpc_url, skip_catchup):
440
440
  is_flag=True,
441
441
  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
442
  )
443
- def watchsvc_cmd(action, restart_if_active):
443
+ @click.option(
444
+ '--skip-catchup',
445
+ is_flag=True,
446
+ help='With start: resume watching without catch-up sync/restart (e.g. after create-app modsync).',
447
+ )
448
+ def watchsvc_cmd(action, restart_if_active, skip_catchup):
444
449
  """
445
450
  Manage the durable cleep-watch systemd unit.
446
451
 
@@ -455,6 +460,10 @@ def watchsvc_cmd(action, restart_if_active):
455
460
  the watcher when the on-disk binary is newer than the running process. Force with::
456
461
 
457
462
  cleep-cli watchsvc install --restart-if-active
463
+
464
+ Resume after a deliberate pause without restarting Cleep::
465
+
466
+ cleep-cli watchsvc start --skip-catchup
458
467
  """
459
468
  svc = WatchService()
460
469
  if action == 'status':
@@ -466,12 +475,13 @@ def watchsvc_cmd(action, restart_if_active):
466
475
 
467
476
  if action == 'install':
468
477
  ok = svc.install(restart_if_active=restart_if_active)
478
+ elif action == 'start':
479
+ ok = svc.start(skip_catchup=skip_catchup)
469
480
  else:
470
481
  handlers = {
471
482
  'uninstall': svc.uninstall,
472
483
  'enable': svc.enable,
473
484
  'disable': svc.disable,
474
- 'start': svc.start,
475
485
  'stop': svc.stop,
476
486
  'restart': svc.restart,
477
487
  }
@@ -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.4"
@@ -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.4
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()
@@ -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
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