cleepcli 1.48.1__tar.gz → 1.49.0__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.0}/PKG-INFO +1 -1
- {cleepcli-1.48.1 → cleepcli-1.49.0}/bin/ccli +189 -16
- {cleepcli-1.48.1 → cleepcli-1.49.0}/bin/cleep-cli +189 -16
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/check.py +32 -9
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/config.py +11 -0
- cleepcli-1.49.0/cleepcli/pico.py +407 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/version.py +1 -1
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/watch.py +11 -2
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/watchsvc.py +32 -1
- {cleepcli-1.48.1 → cleepcli-1.49.0/cleepcli.egg-info}/PKG-INFO +1 -1
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli.egg-info/SOURCES.txt +2 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/tests/test_file_sync_all.py +60 -4
- cleepcli-1.49.0/tests/test_pico.py +95 -0
- cleepcli-1.49.0/tests/test_watchsvc.py +109 -0
- cleepcli-1.48.1/tests/test_watchsvc.py +0 -57
- {cleepcli-1.48.1 → cleepcli-1.49.0}/LICENSE +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/MANIFEST.in +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/README.md +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/__init__.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/ci.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/cleepapi.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/console.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/docs.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/file.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/git.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/module.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/package.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/systemd/cleep-watch.service +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/test.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli/tools.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli.egg-info/dependency_links.txt +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli.egg-info/requires.txt +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/cleepcli.egg-info/top_level.txt +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/pyproject.toml +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/requirements.txt +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/setup.cfg +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/setup.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/tests/test_check.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/tests/test_config.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/tests/test_console.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/tests/test_coverage.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/tests/test_docs_breaking.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/tests/test_module_scaffold.py +0 -0
- {cleepcli-1.48.1 → cleepcli-1.49.0}/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.')
|
|
@@ -406,7 +409,12 @@ def watch(quiet, loglevel, rpc_url, skip_catchup):
|
|
|
406
409
|
['install', 'uninstall', 'enable', 'disable', 'start', 'stop', 'restart', 'status']
|
|
407
410
|
),
|
|
408
411
|
)
|
|
409
|
-
|
|
412
|
+
@click.option(
|
|
413
|
+
'--restart-if-active',
|
|
414
|
+
is_flag=True,
|
|
415
|
+
help='With install: restart the unit if it is already running (pick up a new cleep-cli).',
|
|
416
|
+
)
|
|
417
|
+
def watchsvc_cmd(action, restart_if_active):
|
|
410
418
|
"""
|
|
411
419
|
Manage the durable cleep-watch systemd unit.
|
|
412
420
|
|
|
@@ -416,17 +424,12 @@ def watchsvc_cmd(action):
|
|
|
416
424
|
|
|
417
425
|
cleep-cli watchsvc install
|
|
418
426
|
cleep-cli watchsvc enable
|
|
427
|
+
|
|
428
|
+
After upgrading cleep-cli (pip), restart the watcher so it loads the new code::
|
|
429
|
+
|
|
430
|
+
cleep-cli watchsvc restart
|
|
419
431
|
"""
|
|
420
432
|
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
433
|
if action == 'status':
|
|
431
434
|
status = svc.status()
|
|
432
435
|
logging.info(status)
|
|
@@ -434,7 +437,19 @@ def watchsvc_cmd(action):
|
|
|
434
437
|
sys.exit(1)
|
|
435
438
|
return
|
|
436
439
|
|
|
437
|
-
if
|
|
440
|
+
if action == 'install':
|
|
441
|
+
ok = svc.install(restart_if_active=restart_if_active)
|
|
442
|
+
else:
|
|
443
|
+
handlers = {
|
|
444
|
+
'uninstall': svc.uninstall,
|
|
445
|
+
'enable': svc.enable,
|
|
446
|
+
'disable': svc.disable,
|
|
447
|
+
'start': svc.start,
|
|
448
|
+
'stop': svc.stop,
|
|
449
|
+
'restart': svc.restart,
|
|
450
|
+
}
|
|
451
|
+
ok = handlers[action]()
|
|
452
|
+
if not ok:
|
|
438
453
|
sys.exit(1)
|
|
439
454
|
|
|
440
455
|
@click.group()
|
|
@@ -935,14 +950,172 @@ def cicorecheckversion():
|
|
|
935
950
|
sys.exit(1)
|
|
936
951
|
|
|
937
952
|
|
|
953
|
+
@click.group()
|
|
954
|
+
def pico():
|
|
955
|
+
"""Raspberry Pi Pico SDK and UF2 firmware builds."""
|
|
956
|
+
pass
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
@click.group()
|
|
960
|
+
def pico_sdk():
|
|
961
|
+
"""Install / update / remove the shared Pico SDK."""
|
|
962
|
+
pass
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
@pico_sdk.command('install')
|
|
966
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
967
|
+
def pico_sdk_install(as_json):
|
|
968
|
+
"""Install toolchain packages and clone the Pico SDK."""
|
|
969
|
+
try:
|
|
970
|
+
meta = Pico().sdk_install()
|
|
971
|
+
except PicoError as error:
|
|
972
|
+
logging.error(str(error))
|
|
973
|
+
sys.exit(1)
|
|
974
|
+
if as_json:
|
|
975
|
+
click.echo(json.dumps(meta, indent=2))
|
|
976
|
+
else:
|
|
977
|
+
logging.info(
|
|
978
|
+
'SDK installed=%s version=%s revision=%s toolchain_ok=%s',
|
|
979
|
+
meta.get('installed'),
|
|
980
|
+
meta.get('version'),
|
|
981
|
+
meta.get('revision'),
|
|
982
|
+
meta.get('toolchain_ok'),
|
|
983
|
+
)
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
@pico_sdk.command('update')
|
|
987
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
988
|
+
def pico_sdk_update(as_json):
|
|
989
|
+
"""Update the Pico SDK checkout."""
|
|
990
|
+
try:
|
|
991
|
+
meta = Pico().sdk_update()
|
|
992
|
+
except PicoError as error:
|
|
993
|
+
logging.error(str(error))
|
|
994
|
+
sys.exit(1)
|
|
995
|
+
if as_json:
|
|
996
|
+
click.echo(json.dumps(meta, indent=2))
|
|
997
|
+
else:
|
|
998
|
+
logging.info(
|
|
999
|
+
'SDK updated version=%s revision=%s',
|
|
1000
|
+
meta.get('version'),
|
|
1001
|
+
meta.get('revision'),
|
|
1002
|
+
)
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
@pico_sdk.command('uninstall')
|
|
1006
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1007
|
+
def pico_sdk_uninstall(as_json):
|
|
1008
|
+
"""Remove the Pico SDK (keeps apt toolchain packages)."""
|
|
1009
|
+
try:
|
|
1010
|
+
meta = Pico().sdk_uninstall()
|
|
1011
|
+
except PicoError as error:
|
|
1012
|
+
logging.error(str(error))
|
|
1013
|
+
sys.exit(1)
|
|
1014
|
+
if as_json:
|
|
1015
|
+
click.echo(json.dumps(meta, indent=2))
|
|
1016
|
+
else:
|
|
1017
|
+
logging.info('Pico SDK uninstalled')
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
@pico_sdk.command('info')
|
|
1021
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1022
|
+
def pico_sdk_info(as_json):
|
|
1023
|
+
"""Show Pico SDK install status."""
|
|
1024
|
+
meta = Pico().sdk_info()
|
|
1025
|
+
if as_json:
|
|
1026
|
+
click.echo(json.dumps(meta, indent=2))
|
|
1027
|
+
else:
|
|
1028
|
+
logging.info(
|
|
1029
|
+
'installed=%s path=%s version=%s revision=%s updated_at=%s toolchain_ok=%s',
|
|
1030
|
+
meta.get('installed'),
|
|
1031
|
+
meta.get('path'),
|
|
1032
|
+
meta.get('version'),
|
|
1033
|
+
meta.get('revision'),
|
|
1034
|
+
meta.get('updated_at'),
|
|
1035
|
+
meta.get('toolchain_ok'),
|
|
1036
|
+
)
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
@pico.command('build')
|
|
1040
|
+
@click.option('--module', required=True, help='Module name.')
|
|
1041
|
+
@click.option('--firmware', default=None, help='Firmware slug (default: all uf2).')
|
|
1042
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON result.')
|
|
1043
|
+
def pico_build(module, firmware, as_json):
|
|
1044
|
+
"""Compile UF2 firmwares for a module (writes firmwares/<slug>/.build/)."""
|
|
1045
|
+
try:
|
|
1046
|
+
result = Pico().build_firmware(module, slug=firmware)
|
|
1047
|
+
except PicoError as error:
|
|
1048
|
+
logging.error(str(error))
|
|
1049
|
+
sys.exit(1)
|
|
1050
|
+
if as_json:
|
|
1051
|
+
click.echo(json.dumps(result, indent=2))
|
|
1052
|
+
else:
|
|
1053
|
+
logging.info('Built %s UF2 firmware(s)', result.get('count'))
|
|
1054
|
+
|
|
1055
|
+
|
|
1056
|
+
@pico.command('status')
|
|
1057
|
+
@click.option('--module', required=True, help='Module name.')
|
|
1058
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON result.')
|
|
1059
|
+
def pico_status(module, as_json):
|
|
1060
|
+
"""Show UF2 build freshness for a module's firmwares."""
|
|
1061
|
+
try:
|
|
1062
|
+
result = Pico().status(module)
|
|
1063
|
+
except PicoError as error:
|
|
1064
|
+
logging.error(str(error))
|
|
1065
|
+
sys.exit(1)
|
|
1066
|
+
if as_json:
|
|
1067
|
+
click.echo(json.dumps(result, indent=2))
|
|
1068
|
+
else:
|
|
1069
|
+
logging.info(
|
|
1070
|
+
'uf2_ready=%s count=%s',
|
|
1071
|
+
result.get('uf2_ready'),
|
|
1072
|
+
result.get('count'),
|
|
1073
|
+
)
|
|
1074
|
+
for item in result.get('items') or []:
|
|
1075
|
+
logging.info(
|
|
1076
|
+
' %s [%s] %s — %s',
|
|
1077
|
+
item.get('slug'),
|
|
1078
|
+
item.get('kind'),
|
|
1079
|
+
item.get('status'),
|
|
1080
|
+
item.get('message'),
|
|
1081
|
+
)
|
|
1082
|
+
for msg in result.get('uf2_blocking') or []:
|
|
1083
|
+
logging.warning('blocking: %s', msg)
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
pico.add_command(pico_sdk, name='sdk')
|
|
1087
|
+
|
|
1088
|
+
|
|
938
1089
|
def print_version(ctx, param, value):
|
|
939
1090
|
if not value or ctx.resilient_parsing:
|
|
940
1091
|
return
|
|
941
1092
|
click.echo('cleep-cli version %s' % VERSION)
|
|
942
1093
|
ctx.exit()
|
|
943
1094
|
|
|
1095
|
+
|
|
1096
|
+
class CleepCliCollection(click.CommandCollection):
|
|
1097
|
+
"""
|
|
1098
|
+
Flatten legacy command groups, but keep ``pico`` nested
|
|
1099
|
+
(``cleep-cli pico sdk install``, ``cleep-cli pico build``, …).
|
|
1100
|
+
"""
|
|
1101
|
+
|
|
1102
|
+
def list_commands(self, ctx):
|
|
1103
|
+
names = list(click.CommandCollection.list_commands(self, ctx))
|
|
1104
|
+
if 'pico' not in names:
|
|
1105
|
+
names.append('pico')
|
|
1106
|
+
return names
|
|
1107
|
+
|
|
1108
|
+
def get_command(self, ctx, cmd_name):
|
|
1109
|
+
if cmd_name == 'pico':
|
|
1110
|
+
return pico
|
|
1111
|
+
return click.CommandCollection.get_command(self, ctx, cmd_name)
|
|
1112
|
+
|
|
1113
|
+
|
|
944
1114
|
# https://github.com/pallets/click/issues/341
|
|
945
|
-
@click.command(
|
|
1115
|
+
@click.command(
|
|
1116
|
+
cls=CleepCliCollection,
|
|
1117
|
+
sources=[core, mod, watchdog, test, package, docs, check, ci],
|
|
1118
|
+
)
|
|
946
1119
|
@click.option('--version', is_flag=True, callback=print_version, expose_value=False, is_eager=True)
|
|
947
1120
|
def cli():
|
|
948
1121
|
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.')
|
|
@@ -406,7 +409,12 @@ def watch(quiet, loglevel, rpc_url, skip_catchup):
|
|
|
406
409
|
['install', 'uninstall', 'enable', 'disable', 'start', 'stop', 'restart', 'status']
|
|
407
410
|
),
|
|
408
411
|
)
|
|
409
|
-
|
|
412
|
+
@click.option(
|
|
413
|
+
'--restart-if-active',
|
|
414
|
+
is_flag=True,
|
|
415
|
+
help='With install: restart the unit if it is already running (pick up a new cleep-cli).',
|
|
416
|
+
)
|
|
417
|
+
def watchsvc_cmd(action, restart_if_active):
|
|
410
418
|
"""
|
|
411
419
|
Manage the durable cleep-watch systemd unit.
|
|
412
420
|
|
|
@@ -416,17 +424,12 @@ def watchsvc_cmd(action):
|
|
|
416
424
|
|
|
417
425
|
cleep-cli watchsvc install
|
|
418
426
|
cleep-cli watchsvc enable
|
|
427
|
+
|
|
428
|
+
After upgrading cleep-cli (pip), restart the watcher so it loads the new code::
|
|
429
|
+
|
|
430
|
+
cleep-cli watchsvc restart
|
|
419
431
|
"""
|
|
420
432
|
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
433
|
if action == 'status':
|
|
431
434
|
status = svc.status()
|
|
432
435
|
logging.info(status)
|
|
@@ -434,7 +437,19 @@ def watchsvc_cmd(action):
|
|
|
434
437
|
sys.exit(1)
|
|
435
438
|
return
|
|
436
439
|
|
|
437
|
-
if
|
|
440
|
+
if action == 'install':
|
|
441
|
+
ok = svc.install(restart_if_active=restart_if_active)
|
|
442
|
+
else:
|
|
443
|
+
handlers = {
|
|
444
|
+
'uninstall': svc.uninstall,
|
|
445
|
+
'enable': svc.enable,
|
|
446
|
+
'disable': svc.disable,
|
|
447
|
+
'start': svc.start,
|
|
448
|
+
'stop': svc.stop,
|
|
449
|
+
'restart': svc.restart,
|
|
450
|
+
}
|
|
451
|
+
ok = handlers[action]()
|
|
452
|
+
if not ok:
|
|
438
453
|
sys.exit(1)
|
|
439
454
|
|
|
440
455
|
@click.group()
|
|
@@ -935,14 +950,172 @@ def cicorecheckversion():
|
|
|
935
950
|
sys.exit(1)
|
|
936
951
|
|
|
937
952
|
|
|
953
|
+
@click.group()
|
|
954
|
+
def pico():
|
|
955
|
+
"""Raspberry Pi Pico SDK and UF2 firmware builds."""
|
|
956
|
+
pass
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
@click.group()
|
|
960
|
+
def pico_sdk():
|
|
961
|
+
"""Install / update / remove the shared Pico SDK."""
|
|
962
|
+
pass
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
@pico_sdk.command('install')
|
|
966
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
967
|
+
def pico_sdk_install(as_json):
|
|
968
|
+
"""Install toolchain packages and clone the Pico SDK."""
|
|
969
|
+
try:
|
|
970
|
+
meta = Pico().sdk_install()
|
|
971
|
+
except PicoError as error:
|
|
972
|
+
logging.error(str(error))
|
|
973
|
+
sys.exit(1)
|
|
974
|
+
if as_json:
|
|
975
|
+
click.echo(json.dumps(meta, indent=2))
|
|
976
|
+
else:
|
|
977
|
+
logging.info(
|
|
978
|
+
'SDK installed=%s version=%s revision=%s toolchain_ok=%s',
|
|
979
|
+
meta.get('installed'),
|
|
980
|
+
meta.get('version'),
|
|
981
|
+
meta.get('revision'),
|
|
982
|
+
meta.get('toolchain_ok'),
|
|
983
|
+
)
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
@pico_sdk.command('update')
|
|
987
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
988
|
+
def pico_sdk_update(as_json):
|
|
989
|
+
"""Update the Pico SDK checkout."""
|
|
990
|
+
try:
|
|
991
|
+
meta = Pico().sdk_update()
|
|
992
|
+
except PicoError as error:
|
|
993
|
+
logging.error(str(error))
|
|
994
|
+
sys.exit(1)
|
|
995
|
+
if as_json:
|
|
996
|
+
click.echo(json.dumps(meta, indent=2))
|
|
997
|
+
else:
|
|
998
|
+
logging.info(
|
|
999
|
+
'SDK updated version=%s revision=%s',
|
|
1000
|
+
meta.get('version'),
|
|
1001
|
+
meta.get('revision'),
|
|
1002
|
+
)
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
@pico_sdk.command('uninstall')
|
|
1006
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1007
|
+
def pico_sdk_uninstall(as_json):
|
|
1008
|
+
"""Remove the Pico SDK (keeps apt toolchain packages)."""
|
|
1009
|
+
try:
|
|
1010
|
+
meta = Pico().sdk_uninstall()
|
|
1011
|
+
except PicoError as error:
|
|
1012
|
+
logging.error(str(error))
|
|
1013
|
+
sys.exit(1)
|
|
1014
|
+
if as_json:
|
|
1015
|
+
click.echo(json.dumps(meta, indent=2))
|
|
1016
|
+
else:
|
|
1017
|
+
logging.info('Pico SDK uninstalled')
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
@pico_sdk.command('info')
|
|
1021
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON metadata.')
|
|
1022
|
+
def pico_sdk_info(as_json):
|
|
1023
|
+
"""Show Pico SDK install status."""
|
|
1024
|
+
meta = Pico().sdk_info()
|
|
1025
|
+
if as_json:
|
|
1026
|
+
click.echo(json.dumps(meta, indent=2))
|
|
1027
|
+
else:
|
|
1028
|
+
logging.info(
|
|
1029
|
+
'installed=%s path=%s version=%s revision=%s updated_at=%s toolchain_ok=%s',
|
|
1030
|
+
meta.get('installed'),
|
|
1031
|
+
meta.get('path'),
|
|
1032
|
+
meta.get('version'),
|
|
1033
|
+
meta.get('revision'),
|
|
1034
|
+
meta.get('updated_at'),
|
|
1035
|
+
meta.get('toolchain_ok'),
|
|
1036
|
+
)
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
@pico.command('build')
|
|
1040
|
+
@click.option('--module', required=True, help='Module name.')
|
|
1041
|
+
@click.option('--firmware', default=None, help='Firmware slug (default: all uf2).')
|
|
1042
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON result.')
|
|
1043
|
+
def pico_build(module, firmware, as_json):
|
|
1044
|
+
"""Compile UF2 firmwares for a module (writes firmwares/<slug>/.build/)."""
|
|
1045
|
+
try:
|
|
1046
|
+
result = Pico().build_firmware(module, slug=firmware)
|
|
1047
|
+
except PicoError as error:
|
|
1048
|
+
logging.error(str(error))
|
|
1049
|
+
sys.exit(1)
|
|
1050
|
+
if as_json:
|
|
1051
|
+
click.echo(json.dumps(result, indent=2))
|
|
1052
|
+
else:
|
|
1053
|
+
logging.info('Built %s UF2 firmware(s)', result.get('count'))
|
|
1054
|
+
|
|
1055
|
+
|
|
1056
|
+
@pico.command('status')
|
|
1057
|
+
@click.option('--module', required=True, help='Module name.')
|
|
1058
|
+
@click.option('--json', 'as_json', is_flag=True, help='Print JSON result.')
|
|
1059
|
+
def pico_status(module, as_json):
|
|
1060
|
+
"""Show UF2 build freshness for a module's firmwares."""
|
|
1061
|
+
try:
|
|
1062
|
+
result = Pico().status(module)
|
|
1063
|
+
except PicoError as error:
|
|
1064
|
+
logging.error(str(error))
|
|
1065
|
+
sys.exit(1)
|
|
1066
|
+
if as_json:
|
|
1067
|
+
click.echo(json.dumps(result, indent=2))
|
|
1068
|
+
else:
|
|
1069
|
+
logging.info(
|
|
1070
|
+
'uf2_ready=%s count=%s',
|
|
1071
|
+
result.get('uf2_ready'),
|
|
1072
|
+
result.get('count'),
|
|
1073
|
+
)
|
|
1074
|
+
for item in result.get('items') or []:
|
|
1075
|
+
logging.info(
|
|
1076
|
+
' %s [%s] %s — %s',
|
|
1077
|
+
item.get('slug'),
|
|
1078
|
+
item.get('kind'),
|
|
1079
|
+
item.get('status'),
|
|
1080
|
+
item.get('message'),
|
|
1081
|
+
)
|
|
1082
|
+
for msg in result.get('uf2_blocking') or []:
|
|
1083
|
+
logging.warning('blocking: %s', msg)
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
pico.add_command(pico_sdk, name='sdk')
|
|
1087
|
+
|
|
1088
|
+
|
|
938
1089
|
def print_version(ctx, param, value):
|
|
939
1090
|
if not value or ctx.resilient_parsing:
|
|
940
1091
|
return
|
|
941
1092
|
click.echo('cleep-cli version %s' % VERSION)
|
|
942
1093
|
ctx.exit()
|
|
943
1094
|
|
|
1095
|
+
|
|
1096
|
+
class CleepCliCollection(click.CommandCollection):
|
|
1097
|
+
"""
|
|
1098
|
+
Flatten legacy command groups, but keep ``pico`` nested
|
|
1099
|
+
(``cleep-cli pico sdk install``, ``cleep-cli pico build``, …).
|
|
1100
|
+
"""
|
|
1101
|
+
|
|
1102
|
+
def list_commands(self, ctx):
|
|
1103
|
+
names = list(click.CommandCollection.list_commands(self, ctx))
|
|
1104
|
+
if 'pico' not in names:
|
|
1105
|
+
names.append('pico')
|
|
1106
|
+
return names
|
|
1107
|
+
|
|
1108
|
+
def get_command(self, ctx, cmd_name):
|
|
1109
|
+
if cmd_name == 'pico':
|
|
1110
|
+
return pico
|
|
1111
|
+
return click.CommandCollection.get_command(self, ctx, cmd_name)
|
|
1112
|
+
|
|
1113
|
+
|
|
944
1114
|
# https://github.com/pallets/click/issues/341
|
|
945
|
-
@click.command(
|
|
1115
|
+
@click.command(
|
|
1116
|
+
cls=CleepCliCollection,
|
|
1117
|
+
sources=[core, mod, watchdog, test, package, docs, check, ci],
|
|
1118
|
+
)
|
|
946
1119
|
@click.option('--version', is_flag=True, callback=print_version, expose_value=False, is_eager=True)
|
|
947
1120
|
def cli():
|
|
948
1121
|
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):
|
|
@@ -58,3 +58,14 @@ DOCS_PROJECT_NAME = 'Cleep core'
|
|
|
58
58
|
CORE_VERSION = get_core_version_from_sources(REPO_DIR)
|
|
59
59
|
|
|
60
60
|
CONFIG_DIR = '/etc/cleep'
|
|
61
|
+
|
|
62
|
+
# Raspberry Pi Pico SDK (shared install for cleep-cli pico build)
|
|
63
|
+
PICO_SDK_DIR = '/var/opt/cleep/pico-sdk'
|
|
64
|
+
PICO_SDK_META = '/var/opt/cleep/pico-sdk.json'
|
|
65
|
+
PICO_SDK_REPO = 'https://github.com/raspberrypi/pico-sdk.git'
|
|
66
|
+
PICO_TOOLCHAIN_PACKAGES = (
|
|
67
|
+
'cmake',
|
|
68
|
+
'gcc-arm-none-eabi',
|
|
69
|
+
'libnewlib-arm-none-eabi',
|
|
70
|
+
'libstdc++-arm-none-eabi-newlib',
|
|
71
|
+
)
|