cleepcli 1.48.1__tar.gz → 1.49.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cleepcli-1.48.1/cleepcli.egg-info → cleepcli-1.49.2}/PKG-INFO +1 -1
- {cleepcli-1.48.1 → cleepcli-1.49.2}/bin/ccli +217 -18
- {cleepcli-1.48.1 → cleepcli-1.49.2}/bin/cleep-cli +217 -18
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/check.py +32 -9
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/config.py +11 -0
- cleepcli-1.49.2/cleepcli/module.py +950 -0
- cleepcli-1.49.2/cleepcli/pico.py +407 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/test.py +3 -1
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/version.py +1 -1
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/watch.py +11 -2
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/watchsvc.py +32 -1
- {cleepcli-1.48.1 → cleepcli-1.49.2/cleepcli.egg-info}/PKG-INFO +1 -1
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli.egg-info/SOURCES.txt +2 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/tests/test_file_sync_all.py +60 -4
- cleepcli-1.49.2/tests/test_pico.py +95 -0
- cleepcli-1.49.2/tests/test_watchsvc.py +109 -0
- cleepcli-1.48.1/cleepcli/module.py +0 -704
- cleepcli-1.48.1/tests/test_watchsvc.py +0 -57
- {cleepcli-1.48.1 → cleepcli-1.49.2}/LICENSE +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/MANIFEST.in +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/README.md +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/__init__.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/ci.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/cleepapi.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/console.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/docs.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/file.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/git.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/package.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/systemd/cleep-watch.service +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli/tools.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli.egg-info/dependency_links.txt +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli.egg-info/requires.txt +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/cleepcli.egg-info/top_level.txt +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/pyproject.toml +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/requirements.txt +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/setup.cfg +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/setup.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/tests/test_check.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/tests/test_config.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/tests/test_console.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/tests/test_coverage.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/tests/test_docs_breaking.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/tests/test_module_scaffold.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.2}/tests/test_watch.py +0 -0
|
@@ -23,6 +23,7 @@ from cleepcli.package import Package
|
|
|
23
23
|
from cleepcli.docs import Docs
|
|
24
24
|
from cleepcli.check import Check
|
|
25
25
|
from cleepcli.ci import Ci
|
|
26
|
+
from cleepcli.pico import Pico, PicoError
|
|
26
27
|
import cleepcli.config as config
|
|
27
28
|
from cleepcli.version import VERSION
|
|
28
29
|
|
|
@@ -114,9 +115,8 @@ def syncall():
|
|
|
114
115
|
"""
|
|
115
116
|
Synchronize core and all modules from /root/cleep-dev to execution folders.
|
|
116
117
|
|
|
117
|
-
Same catch-up used when cleep-watch.service starts.
|
|
118
|
-
|
|
119
|
-
cannot keep stale JS.
|
|
118
|
+
Same catch-up used when cleep-watch.service starts. Disables frontend static
|
|
119
|
+
cache, then restarts the Cleep backend so Python modules (not only JS) reload.
|
|
120
120
|
"""
|
|
121
121
|
from cleepcli.cleepapi import CleepApi
|
|
122
122
|
|
|
@@ -125,7 +125,10 @@ def syncall():
|
|
|
125
125
|
sys.exit(1)
|
|
126
126
|
api = CleepApi(None)
|
|
127
127
|
api.ensure_frontend_nocache()
|
|
128
|
-
|
|
128
|
+
# Backend restart is required: sync_all updates on-disk apps, but a
|
|
129
|
+
# frontend-only reload would keep stale Python RPC commands in memory.
|
|
130
|
+
if not api.restart_backend():
|
|
131
|
+
sys.exit(1)
|
|
129
132
|
|
|
130
133
|
@core.command()
|
|
131
134
|
@click.option('--coverage', is_flag=True, help='Display coverage report.')
|
|
@@ -346,12 +349,38 @@ def modsync(module):
|
|
|
346
349
|
|
|
347
350
|
@mod.command()
|
|
348
351
|
@click.option('--module', prompt='Module name', help='Module name.')
|
|
349
|
-
|
|
352
|
+
@click.option(
|
|
353
|
+
'--base-class',
|
|
354
|
+
default='CleepModule',
|
|
355
|
+
type=click.Choice(
|
|
356
|
+
['CleepModule', 'CleepResources', 'CleepRenderer', 'CleepExternalBus', 'CleepRemoteAccessModule'],
|
|
357
|
+
case_sensitive=True,
|
|
358
|
+
),
|
|
359
|
+
help='Core base class for the application.',
|
|
360
|
+
)
|
|
361
|
+
@click.option(
|
|
362
|
+
'--category',
|
|
363
|
+
default='APPLICATION',
|
|
364
|
+
type=click.Choice(
|
|
365
|
+
['APPLICATION', 'MOBILE', 'DRIVER', 'HOMEAUTOMATION', 'MEDIA', 'SERVICE', 'HOBBY'],
|
|
366
|
+
case_sensitive=True,
|
|
367
|
+
),
|
|
368
|
+
help='Market category (cleep.common.CATEGORIES).',
|
|
369
|
+
)
|
|
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):
|
|
350
373
|
"""
|
|
351
374
|
Create new module skeleton
|
|
352
375
|
"""
|
|
353
376
|
m = Module()
|
|
354
|
-
res = m.create(
|
|
377
|
+
res = m.create(
|
|
378
|
+
module,
|
|
379
|
+
base_class=base_class,
|
|
380
|
+
category=category,
|
|
381
|
+
tags=list(tag),
|
|
382
|
+
with_firmware=firmware,
|
|
383
|
+
)
|
|
355
384
|
|
|
356
385
|
if not res:
|
|
357
386
|
sys.exit(1)
|
|
@@ -406,7 +435,12 @@ def watch(quiet, loglevel, rpc_url, skip_catchup):
|
|
|
406
435
|
['install', 'uninstall', 'enable', 'disable', 'start', 'stop', 'restart', 'status']
|
|
407
436
|
),
|
|
408
437
|
)
|
|
409
|
-
|
|
438
|
+
@click.option(
|
|
439
|
+
'--restart-if-active',
|
|
440
|
+
is_flag=True,
|
|
441
|
+
help='With install: restart the unit if it is already running (pick up a new cleep-cli).',
|
|
442
|
+
)
|
|
443
|
+
def watchsvc_cmd(action, restart_if_active):
|
|
410
444
|
"""
|
|
411
445
|
Manage the durable cleep-watch systemd unit.
|
|
412
446
|
|
|
@@ -416,17 +450,12 @@ def watchsvc_cmd(action):
|
|
|
416
450
|
|
|
417
451
|
cleep-cli watchsvc install
|
|
418
452
|
cleep-cli watchsvc enable
|
|
453
|
+
|
|
454
|
+
After upgrading cleep-cli (pip), restart the watcher so it loads the new code::
|
|
455
|
+
|
|
456
|
+
cleep-cli watchsvc restart
|
|
419
457
|
"""
|
|
420
458
|
svc = WatchService()
|
|
421
|
-
handlers = {
|
|
422
|
-
'install': svc.install,
|
|
423
|
-
'uninstall': svc.uninstall,
|
|
424
|
-
'enable': svc.enable,
|
|
425
|
-
'disable': svc.disable,
|
|
426
|
-
'start': svc.start,
|
|
427
|
-
'stop': svc.stop,
|
|
428
|
-
'restart': svc.restart,
|
|
429
|
-
}
|
|
430
459
|
if action == 'status':
|
|
431
460
|
status = svc.status()
|
|
432
461
|
logging.info(status)
|
|
@@ -434,7 +463,19 @@ def watchsvc_cmd(action):
|
|
|
434
463
|
sys.exit(1)
|
|
435
464
|
return
|
|
436
465
|
|
|
437
|
-
if
|
|
466
|
+
if action == 'install':
|
|
467
|
+
ok = svc.install(restart_if_active=restart_if_active)
|
|
468
|
+
else:
|
|
469
|
+
handlers = {
|
|
470
|
+
'uninstall': svc.uninstall,
|
|
471
|
+
'enable': svc.enable,
|
|
472
|
+
'disable': svc.disable,
|
|
473
|
+
'start': svc.start,
|
|
474
|
+
'stop': svc.stop,
|
|
475
|
+
'restart': svc.restart,
|
|
476
|
+
}
|
|
477
|
+
ok = handlers[action]()
|
|
478
|
+
if not ok:
|
|
438
479
|
sys.exit(1)
|
|
439
480
|
|
|
440
481
|
@click.group()
|
|
@@ -935,14 +976,172 @@ def cicorecheckversion():
|
|
|
935
976
|
sys.exit(1)
|
|
936
977
|
|
|
937
978
|
|
|
979
|
+
@click.group()
|
|
980
|
+
def pico():
|
|
981
|
+
"""Raspberry Pi Pico SDK and UF2 firmware builds."""
|
|
982
|
+
pass
|
|
983
|
+
|
|
984
|
+
|
|
985
|
+
@click.group()
|
|
986
|
+
def pico_sdk():
|
|
987
|
+
"""Install / update / remove the shared Pico SDK."""
|
|
988
|
+
pass
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
@pico_sdk.command('install')
|
|
992
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
993
|
+
def pico_sdk_install(as_json):
|
|
994
|
+
"""Install toolchain packages and clone the Pico SDK."""
|
|
995
|
+
try:
|
|
996
|
+
meta = Pico().sdk_install()
|
|
997
|
+
except PicoError as error:
|
|
998
|
+
logging.error(str(error))
|
|
999
|
+
sys.exit(1)
|
|
1000
|
+
if as_json:
|
|
1001
|
+
click.echo(json.dumps(meta, indent=2))
|
|
1002
|
+
else:
|
|
1003
|
+
logging.info(
|
|
1004
|
+
'SDK installed=%s version=%s revision=%s toolchain_ok=%s',
|
|
1005
|
+
meta.get('installed'),
|
|
1006
|
+
meta.get('version'),
|
|
1007
|
+
meta.get('revision'),
|
|
1008
|
+
meta.get('toolchain_ok'),
|
|
1009
|
+
)
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
@pico_sdk.command('update')
|
|
1013
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1014
|
+
def pico_sdk_update(as_json):
|
|
1015
|
+
"""Update the Pico SDK checkout."""
|
|
1016
|
+
try:
|
|
1017
|
+
meta = Pico().sdk_update()
|
|
1018
|
+
except PicoError as error:
|
|
1019
|
+
logging.error(str(error))
|
|
1020
|
+
sys.exit(1)
|
|
1021
|
+
if as_json:
|
|
1022
|
+
click.echo(json.dumps(meta, indent=2))
|
|
1023
|
+
else:
|
|
1024
|
+
logging.info(
|
|
1025
|
+
'SDK updated version=%s revision=%s',
|
|
1026
|
+
meta.get('version'),
|
|
1027
|
+
meta.get('revision'),
|
|
1028
|
+
)
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
@pico_sdk.command('uninstall')
|
|
1032
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1033
|
+
def pico_sdk_uninstall(as_json):
|
|
1034
|
+
"""Remove the Pico SDK (keeps apt toolchain packages)."""
|
|
1035
|
+
try:
|
|
1036
|
+
meta = Pico().sdk_uninstall()
|
|
1037
|
+
except PicoError as error:
|
|
1038
|
+
logging.error(str(error))
|
|
1039
|
+
sys.exit(1)
|
|
1040
|
+
if as_json:
|
|
1041
|
+
click.echo(json.dumps(meta, indent=2))
|
|
1042
|
+
else:
|
|
1043
|
+
logging.info('Pico SDK uninstalled')
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
@pico_sdk.command('info')
|
|
1047
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1048
|
+
def pico_sdk_info(as_json):
|
|
1049
|
+
"""Show Pico SDK install status."""
|
|
1050
|
+
meta = Pico().sdk_info()
|
|
1051
|
+
if as_json:
|
|
1052
|
+
click.echo(json.dumps(meta, indent=2))
|
|
1053
|
+
else:
|
|
1054
|
+
logging.info(
|
|
1055
|
+
'installed=%s path=%s version=%s revision=%s updated_at=%s toolchain_ok=%s',
|
|
1056
|
+
meta.get('installed'),
|
|
1057
|
+
meta.get('path'),
|
|
1058
|
+
meta.get('version'),
|
|
1059
|
+
meta.get('revision'),
|
|
1060
|
+
meta.get('updated_at'),
|
|
1061
|
+
meta.get('toolchain_ok'),
|
|
1062
|
+
)
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
@pico.command('build')
|
|
1066
|
+
@click.option('--module', required=True, help='Module name.')
|
|
1067
|
+
@click.option('--firmware', default=None, help='Firmware slug (default: all uf2).')
|
|
1068
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON result.')
|
|
1069
|
+
def pico_build(module, firmware, as_json):
|
|
1070
|
+
"""Compile UF2 firmwares for a module (writes firmwares/<slug>/.build/)."""
|
|
1071
|
+
try:
|
|
1072
|
+
result = Pico().build_firmware(module, slug=firmware)
|
|
1073
|
+
except PicoError as error:
|
|
1074
|
+
logging.error(str(error))
|
|
1075
|
+
sys.exit(1)
|
|
1076
|
+
if as_json:
|
|
1077
|
+
click.echo(json.dumps(result, indent=2))
|
|
1078
|
+
else:
|
|
1079
|
+
logging.info('Built %s UF2 firmware(s)', result.get('count'))
|
|
1080
|
+
|
|
1081
|
+
|
|
1082
|
+
@pico.command('status')
|
|
1083
|
+
@click.option('--module', required=True, help='Module name.')
|
|
1084
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON result.')
|
|
1085
|
+
def pico_status(module, as_json):
|
|
1086
|
+
"""Show UF2 build freshness for a module's firmwares."""
|
|
1087
|
+
try:
|
|
1088
|
+
result = Pico().status(module)
|
|
1089
|
+
except PicoError as error:
|
|
1090
|
+
logging.error(str(error))
|
|
1091
|
+
sys.exit(1)
|
|
1092
|
+
if as_json:
|
|
1093
|
+
click.echo(json.dumps(result, indent=2))
|
|
1094
|
+
else:
|
|
1095
|
+
logging.info(
|
|
1096
|
+
'uf2_ready=%s count=%s',
|
|
1097
|
+
result.get('uf2_ready'),
|
|
1098
|
+
result.get('count'),
|
|
1099
|
+
)
|
|
1100
|
+
for item in result.get('items') or []:
|
|
1101
|
+
logging.info(
|
|
1102
|
+
' %s [%s] %s — %s',
|
|
1103
|
+
item.get('slug'),
|
|
1104
|
+
item.get('kind'),
|
|
1105
|
+
item.get('status'),
|
|
1106
|
+
item.get('message'),
|
|
1107
|
+
)
|
|
1108
|
+
for msg in result.get('uf2_blocking') or []:
|
|
1109
|
+
logging.warning('blocking: %s', msg)
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
pico.add_command(pico_sdk, name='sdk')
|
|
1113
|
+
|
|
1114
|
+
|
|
938
1115
|
def print_version(ctx, param, value):
|
|
939
1116
|
if not value or ctx.resilient_parsing:
|
|
940
1117
|
return
|
|
941
1118
|
click.echo('cleep-cli version %s' % VERSION)
|
|
942
1119
|
ctx.exit()
|
|
943
1120
|
|
|
1121
|
+
|
|
1122
|
+
class CleepCliCollection(click.CommandCollection):
|
|
1123
|
+
"""
|
|
1124
|
+
Flatten legacy command groups, but keep ``pico`` nested
|
|
1125
|
+
(``cleep-cli pico sdk install``, ``cleep-cli pico build``, …).
|
|
1126
|
+
"""
|
|
1127
|
+
|
|
1128
|
+
def list_commands(self, ctx):
|
|
1129
|
+
names = list(click.CommandCollection.list_commands(self, ctx))
|
|
1130
|
+
if 'pico' not in names:
|
|
1131
|
+
names.append('pico')
|
|
1132
|
+
return names
|
|
1133
|
+
|
|
1134
|
+
def get_command(self, ctx, cmd_name):
|
|
1135
|
+
if cmd_name == 'pico':
|
|
1136
|
+
return pico
|
|
1137
|
+
return click.CommandCollection.get_command(self, ctx, cmd_name)
|
|
1138
|
+
|
|
1139
|
+
|
|
944
1140
|
# https://github.com/pallets/click/issues/341
|
|
945
|
-
@click.command(
|
|
1141
|
+
@click.command(
|
|
1142
|
+
cls=CleepCliCollection,
|
|
1143
|
+
sources=[core, mod, watchdog, test, package, docs, check, ci],
|
|
1144
|
+
)
|
|
946
1145
|
@click.option('--version', is_flag=True, callback=print_version, expose_value=False, is_eager=True)
|
|
947
1146
|
def cli():
|
|
948
1147
|
pass
|
|
@@ -23,6 +23,7 @@ from cleepcli.package import Package
|
|
|
23
23
|
from cleepcli.docs import Docs
|
|
24
24
|
from cleepcli.check import Check
|
|
25
25
|
from cleepcli.ci import Ci
|
|
26
|
+
from cleepcli.pico import Pico, PicoError
|
|
26
27
|
import cleepcli.config as config
|
|
27
28
|
from cleepcli.version import VERSION
|
|
28
29
|
|
|
@@ -114,9 +115,8 @@ def syncall():
|
|
|
114
115
|
"""
|
|
115
116
|
Synchronize core and all modules from /root/cleep-dev to execution folders.
|
|
116
117
|
|
|
117
|
-
Same catch-up used when cleep-watch.service starts.
|
|
118
|
-
|
|
119
|
-
cannot keep stale JS.
|
|
118
|
+
Same catch-up used when cleep-watch.service starts. Disables frontend static
|
|
119
|
+
cache, then restarts the Cleep backend so Python modules (not only JS) reload.
|
|
120
120
|
"""
|
|
121
121
|
from cleepcli.cleepapi import CleepApi
|
|
122
122
|
|
|
@@ -125,7 +125,10 @@ def syncall():
|
|
|
125
125
|
sys.exit(1)
|
|
126
126
|
api = CleepApi(None)
|
|
127
127
|
api.ensure_frontend_nocache()
|
|
128
|
-
|
|
128
|
+
# Backend restart is required: sync_all updates on-disk apps, but a
|
|
129
|
+
# frontend-only reload would keep stale Python RPC commands in memory.
|
|
130
|
+
if not api.restart_backend():
|
|
131
|
+
sys.exit(1)
|
|
129
132
|
|
|
130
133
|
@core.command()
|
|
131
134
|
@click.option('--coverage', is_flag=True, help='Display coverage report.')
|
|
@@ -346,12 +349,38 @@ def modsync(module):
|
|
|
346
349
|
|
|
347
350
|
@mod.command()
|
|
348
351
|
@click.option('--module', prompt='Module name', help='Module name.')
|
|
349
|
-
|
|
352
|
+
@click.option(
|
|
353
|
+
'--base-class',
|
|
354
|
+
default='CleepModule',
|
|
355
|
+
type=click.Choice(
|
|
356
|
+
['CleepModule', 'CleepResources', 'CleepRenderer', 'CleepExternalBus', 'CleepRemoteAccessModule'],
|
|
357
|
+
case_sensitive=True,
|
|
358
|
+
),
|
|
359
|
+
help='Core base class for the application.',
|
|
360
|
+
)
|
|
361
|
+
@click.option(
|
|
362
|
+
'--category',
|
|
363
|
+
default='APPLICATION',
|
|
364
|
+
type=click.Choice(
|
|
365
|
+
['APPLICATION', 'MOBILE', 'DRIVER', 'HOMEAUTOMATION', 'MEDIA', 'SERVICE', 'HOBBY'],
|
|
366
|
+
case_sensitive=True,
|
|
367
|
+
),
|
|
368
|
+
help='Market category (cleep.common.CATEGORIES).',
|
|
369
|
+
)
|
|
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):
|
|
350
373
|
"""
|
|
351
374
|
Create new module skeleton
|
|
352
375
|
"""
|
|
353
376
|
m = Module()
|
|
354
|
-
res = m.create(
|
|
377
|
+
res = m.create(
|
|
378
|
+
module,
|
|
379
|
+
base_class=base_class,
|
|
380
|
+
category=category,
|
|
381
|
+
tags=list(tag),
|
|
382
|
+
with_firmware=firmware,
|
|
383
|
+
)
|
|
355
384
|
|
|
356
385
|
if not res:
|
|
357
386
|
sys.exit(1)
|
|
@@ -406,7 +435,12 @@ def watch(quiet, loglevel, rpc_url, skip_catchup):
|
|
|
406
435
|
['install', 'uninstall', 'enable', 'disable', 'start', 'stop', 'restart', 'status']
|
|
407
436
|
),
|
|
408
437
|
)
|
|
409
|
-
|
|
438
|
+
@click.option(
|
|
439
|
+
'--restart-if-active',
|
|
440
|
+
is_flag=True,
|
|
441
|
+
help='With install: restart the unit if it is already running (pick up a new cleep-cli).',
|
|
442
|
+
)
|
|
443
|
+
def watchsvc_cmd(action, restart_if_active):
|
|
410
444
|
"""
|
|
411
445
|
Manage the durable cleep-watch systemd unit.
|
|
412
446
|
|
|
@@ -416,17 +450,12 @@ def watchsvc_cmd(action):
|
|
|
416
450
|
|
|
417
451
|
cleep-cli watchsvc install
|
|
418
452
|
cleep-cli watchsvc enable
|
|
453
|
+
|
|
454
|
+
After upgrading cleep-cli (pip), restart the watcher so it loads the new code::
|
|
455
|
+
|
|
456
|
+
cleep-cli watchsvc restart
|
|
419
457
|
"""
|
|
420
458
|
svc = WatchService()
|
|
421
|
-
handlers = {
|
|
422
|
-
'install': svc.install,
|
|
423
|
-
'uninstall': svc.uninstall,
|
|
424
|
-
'enable': svc.enable,
|
|
425
|
-
'disable': svc.disable,
|
|
426
|
-
'start': svc.start,
|
|
427
|
-
'stop': svc.stop,
|
|
428
|
-
'restart': svc.restart,
|
|
429
|
-
}
|
|
430
459
|
if action == 'status':
|
|
431
460
|
status = svc.status()
|
|
432
461
|
logging.info(status)
|
|
@@ -434,7 +463,19 @@ def watchsvc_cmd(action):
|
|
|
434
463
|
sys.exit(1)
|
|
435
464
|
return
|
|
436
465
|
|
|
437
|
-
if
|
|
466
|
+
if action == 'install':
|
|
467
|
+
ok = svc.install(restart_if_active=restart_if_active)
|
|
468
|
+
else:
|
|
469
|
+
handlers = {
|
|
470
|
+
'uninstall': svc.uninstall,
|
|
471
|
+
'enable': svc.enable,
|
|
472
|
+
'disable': svc.disable,
|
|
473
|
+
'start': svc.start,
|
|
474
|
+
'stop': svc.stop,
|
|
475
|
+
'restart': svc.restart,
|
|
476
|
+
}
|
|
477
|
+
ok = handlers[action]()
|
|
478
|
+
if not ok:
|
|
438
479
|
sys.exit(1)
|
|
439
480
|
|
|
440
481
|
@click.group()
|
|
@@ -935,14 +976,172 @@ def cicorecheckversion():
|
|
|
935
976
|
sys.exit(1)
|
|
936
977
|
|
|
937
978
|
|
|
979
|
+
@click.group()
|
|
980
|
+
def pico():
|
|
981
|
+
"""Raspberry Pi Pico SDK and UF2 firmware builds."""
|
|
982
|
+
pass
|
|
983
|
+
|
|
984
|
+
|
|
985
|
+
@click.group()
|
|
986
|
+
def pico_sdk():
|
|
987
|
+
"""Install / update / remove the shared Pico SDK."""
|
|
988
|
+
pass
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
@pico_sdk.command('install')
|
|
992
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
993
|
+
def pico_sdk_install(as_json):
|
|
994
|
+
"""Install toolchain packages and clone the Pico SDK."""
|
|
995
|
+
try:
|
|
996
|
+
meta = Pico().sdk_install()
|
|
997
|
+
except PicoError as error:
|
|
998
|
+
logging.error(str(error))
|
|
999
|
+
sys.exit(1)
|
|
1000
|
+
if as_json:
|
|
1001
|
+
click.echo(json.dumps(meta, indent=2))
|
|
1002
|
+
else:
|
|
1003
|
+
logging.info(
|
|
1004
|
+
'SDK installed=%s version=%s revision=%s toolchain_ok=%s',
|
|
1005
|
+
meta.get('installed'),
|
|
1006
|
+
meta.get('version'),
|
|
1007
|
+
meta.get('revision'),
|
|
1008
|
+
meta.get('toolchain_ok'),
|
|
1009
|
+
)
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
@pico_sdk.command('update')
|
|
1013
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1014
|
+
def pico_sdk_update(as_json):
|
|
1015
|
+
"""Update the Pico SDK checkout."""
|
|
1016
|
+
try:
|
|
1017
|
+
meta = Pico().sdk_update()
|
|
1018
|
+
except PicoError as error:
|
|
1019
|
+
logging.error(str(error))
|
|
1020
|
+
sys.exit(1)
|
|
1021
|
+
if as_json:
|
|
1022
|
+
click.echo(json.dumps(meta, indent=2))
|
|
1023
|
+
else:
|
|
1024
|
+
logging.info(
|
|
1025
|
+
'SDK updated version=%s revision=%s',
|
|
1026
|
+
meta.get('version'),
|
|
1027
|
+
meta.get('revision'),
|
|
1028
|
+
)
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
@pico_sdk.command('uninstall')
|
|
1032
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1033
|
+
def pico_sdk_uninstall(as_json):
|
|
1034
|
+
"""Remove the Pico SDK (keeps apt toolchain packages)."""
|
|
1035
|
+
try:
|
|
1036
|
+
meta = Pico().sdk_uninstall()
|
|
1037
|
+
except PicoError as error:
|
|
1038
|
+
logging.error(str(error))
|
|
1039
|
+
sys.exit(1)
|
|
1040
|
+
if as_json:
|
|
1041
|
+
click.echo(json.dumps(meta, indent=2))
|
|
1042
|
+
else:
|
|
1043
|
+
logging.info('Pico SDK uninstalled')
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
@pico_sdk.command('info')
|
|
1047
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1048
|
+
def pico_sdk_info(as_json):
|
|
1049
|
+
"""Show Pico SDK install status."""
|
|
1050
|
+
meta = Pico().sdk_info()
|
|
1051
|
+
if as_json:
|
|
1052
|
+
click.echo(json.dumps(meta, indent=2))
|
|
1053
|
+
else:
|
|
1054
|
+
logging.info(
|
|
1055
|
+
'installed=%s path=%s version=%s revision=%s updated_at=%s toolchain_ok=%s',
|
|
1056
|
+
meta.get('installed'),
|
|
1057
|
+
meta.get('path'),
|
|
1058
|
+
meta.get('version'),
|
|
1059
|
+
meta.get('revision'),
|
|
1060
|
+
meta.get('updated_at'),
|
|
1061
|
+
meta.get('toolchain_ok'),
|
|
1062
|
+
)
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
@pico.command('build')
|
|
1066
|
+
@click.option('--module', required=True, help='Module name.')
|
|
1067
|
+
@click.option('--firmware', default=None, help='Firmware slug (default: all uf2).')
|
|
1068
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON result.')
|
|
1069
|
+
def pico_build(module, firmware, as_json):
|
|
1070
|
+
"""Compile UF2 firmwares for a module (writes firmwares/<slug>/.build/)."""
|
|
1071
|
+
try:
|
|
1072
|
+
result = Pico().build_firmware(module, slug=firmware)
|
|
1073
|
+
except PicoError as error:
|
|
1074
|
+
logging.error(str(error))
|
|
1075
|
+
sys.exit(1)
|
|
1076
|
+
if as_json:
|
|
1077
|
+
click.echo(json.dumps(result, indent=2))
|
|
1078
|
+
else:
|
|
1079
|
+
logging.info('Built %s UF2 firmware(s)', result.get('count'))
|
|
1080
|
+
|
|
1081
|
+
|
|
1082
|
+
@pico.command('status')
|
|
1083
|
+
@click.option('--module', required=True, help='Module name.')
|
|
1084
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON result.')
|
|
1085
|
+
def pico_status(module, as_json):
|
|
1086
|
+
"""Show UF2 build freshness for a module's firmwares."""
|
|
1087
|
+
try:
|
|
1088
|
+
result = Pico().status(module)
|
|
1089
|
+
except PicoError as error:
|
|
1090
|
+
logging.error(str(error))
|
|
1091
|
+
sys.exit(1)
|
|
1092
|
+
if as_json:
|
|
1093
|
+
click.echo(json.dumps(result, indent=2))
|
|
1094
|
+
else:
|
|
1095
|
+
logging.info(
|
|
1096
|
+
'uf2_ready=%s count=%s',
|
|
1097
|
+
result.get('uf2_ready'),
|
|
1098
|
+
result.get('count'),
|
|
1099
|
+
)
|
|
1100
|
+
for item in result.get('items') or []:
|
|
1101
|
+
logging.info(
|
|
1102
|
+
' %s [%s] %s — %s',
|
|
1103
|
+
item.get('slug'),
|
|
1104
|
+
item.get('kind'),
|
|
1105
|
+
item.get('status'),
|
|
1106
|
+
item.get('message'),
|
|
1107
|
+
)
|
|
1108
|
+
for msg in result.get('uf2_blocking') or []:
|
|
1109
|
+
logging.warning('blocking: %s', msg)
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
pico.add_command(pico_sdk, name='sdk')
|
|
1113
|
+
|
|
1114
|
+
|
|
938
1115
|
def print_version(ctx, param, value):
|
|
939
1116
|
if not value or ctx.resilient_parsing:
|
|
940
1117
|
return
|
|
941
1118
|
click.echo('cleep-cli version %s' % VERSION)
|
|
942
1119
|
ctx.exit()
|
|
943
1120
|
|
|
1121
|
+
|
|
1122
|
+
class CleepCliCollection(click.CommandCollection):
|
|
1123
|
+
"""
|
|
1124
|
+
Flatten legacy command groups, but keep ``pico`` nested
|
|
1125
|
+
(``cleep-cli pico sdk install``, ``cleep-cli pico build``, …).
|
|
1126
|
+
"""
|
|
1127
|
+
|
|
1128
|
+
def list_commands(self, ctx):
|
|
1129
|
+
names = list(click.CommandCollection.list_commands(self, ctx))
|
|
1130
|
+
if 'pico' not in names:
|
|
1131
|
+
names.append('pico')
|
|
1132
|
+
return names
|
|
1133
|
+
|
|
1134
|
+
def get_command(self, ctx, cmd_name):
|
|
1135
|
+
if cmd_name == 'pico':
|
|
1136
|
+
return pico
|
|
1137
|
+
return click.CommandCollection.get_command(self, ctx, cmd_name)
|
|
1138
|
+
|
|
1139
|
+
|
|
944
1140
|
# https://github.com/pallets/click/issues/341
|
|
945
|
-
@click.command(
|
|
1141
|
+
@click.command(
|
|
1142
|
+
cls=CleepCliCollection,
|
|
1143
|
+
sources=[core, mod, watchdog, test, package, docs, check, ci],
|
|
1144
|
+
)
|
|
946
1145
|
@click.option('--version', is_flag=True, callback=print_version, expose_value=False, is_eager=True)
|
|
947
1146
|
def cli():
|
|
948
1147
|
pass
|
|
@@ -1499,11 +1499,14 @@ overgeneral-exceptions=Exception
|
|
|
1499
1499
|
|
|
1500
1500
|
def check_firmwares(self, module_name):
|
|
1501
1501
|
"""
|
|
1502
|
-
Validate optional ``firmwares
|
|
1503
|
-
|
|
1502
|
+
Validate optional ``firmwares/<slug>/`` source folders (author manifests)
|
|
1503
|
+
and list **built** zip+manifest pairs for packaging.
|
|
1504
|
+
|
|
1505
|
+
Sources live under one folder per firmware. Packaging files come from
|
|
1506
|
+
``firmwares/.dist/`` after :func:`build_all_firmware_packages`.
|
|
1504
1507
|
|
|
1505
1508
|
Returns:
|
|
1506
|
-
dict: errors / warnings / files
|
|
1509
|
+
dict: errors / warnings / files / count
|
|
1507
1510
|
"""
|
|
1508
1511
|
if not os.path.exists(os.path.join(config.MODULES_DST, module_name)):
|
|
1509
1512
|
raise Exception('Module "%s" does not exist' % module_name)
|
|
@@ -1513,6 +1516,7 @@ overgeneral-exceptions=Exception
|
|
|
1513
1516
|
"errors": [],
|
|
1514
1517
|
"warnings": [],
|
|
1515
1518
|
"files": [],
|
|
1519
|
+
"count": 0,
|
|
1516
1520
|
}
|
|
1517
1521
|
if not os.path.isdir(firmwares_path):
|
|
1518
1522
|
return out
|
|
@@ -1520,7 +1524,8 @@ overgeneral-exceptions=Exception
|
|
|
1520
1524
|
try:
|
|
1521
1525
|
from cleep.libs.internals.firmware_manifest import (
|
|
1522
1526
|
FirmwareManifestError,
|
|
1523
|
-
|
|
1527
|
+
build_all_firmware_packages,
|
|
1528
|
+
scan_firmware_sources,
|
|
1524
1529
|
)
|
|
1525
1530
|
except ImportError:
|
|
1526
1531
|
out["errors"].append(
|
|
@@ -1530,15 +1535,33 @@ overgeneral-exceptions=Exception
|
|
|
1530
1535
|
return out
|
|
1531
1536
|
|
|
1532
1537
|
try:
|
|
1533
|
-
|
|
1538
|
+
sources = scan_firmware_sources(firmwares_path)
|
|
1534
1539
|
except FirmwareManifestError as error:
|
|
1535
1540
|
out["errors"].append(str(error))
|
|
1536
1541
|
return out
|
|
1537
1542
|
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1543
|
+
out["count"] = len(sources)
|
|
1544
|
+
if not sources:
|
|
1545
|
+
return out
|
|
1546
|
+
|
|
1547
|
+
try:
|
|
1548
|
+
built = build_all_firmware_packages(firmwares_path)
|
|
1549
|
+
except FirmwareManifestError as error:
|
|
1550
|
+
out["errors"].append(str(error))
|
|
1551
|
+
return out
|
|
1552
|
+
|
|
1553
|
+
for item in built:
|
|
1554
|
+
for key, ext in (("zip", ".zip"), ("manifest", ".manifest")):
|
|
1555
|
+
fullpath = item[key]
|
|
1556
|
+
out["files"].append(
|
|
1557
|
+
{
|
|
1558
|
+
"fullpath": fullpath,
|
|
1559
|
+
"filename": os.path.basename(fullpath),
|
|
1560
|
+
"path": os.path.join(
|
|
1561
|
+
"firmwares", os.path.basename(fullpath)
|
|
1562
|
+
),
|
|
1563
|
+
}
|
|
1564
|
+
)
|
|
1542
1565
|
return out
|
|
1543
1566
|
|
|
1544
1567
|
def check_tests(self, module_name):
|