cleepcli 1.49.8__tar.gz → 1.50.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.49.8/cleepcli.egg-info → cleepcli-1.50.0}/PKG-INFO +1 -1
- {cleepcli-1.49.8 → cleepcli-1.50.0}/bin/ccli +27 -5
- {cleepcli-1.49.8 → cleepcli-1.50.0}/bin/cleep-cli +27 -5
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/config.py +61 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/version.py +1 -1
- {cleepcli-1.49.8 → cleepcli-1.50.0/cleepcli.egg-info}/PKG-INFO +1 -1
- cleepcli-1.50.0/tests/test_config.py +50 -0
- cleepcli-1.49.8/tests/test_config.py +0 -15
- {cleepcli-1.49.8 → cleepcli-1.50.0}/LICENSE +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/MANIFEST.in +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/README.md +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/__init__.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/check.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/ci.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/cleepapi.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/console.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/docs.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/file.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/git.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/module.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/package.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/pico.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/systemd/cleep-watch.service +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/test.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/tools.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/watch.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli/watchsvc.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli.egg-info/SOURCES.txt +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli.egg-info/dependency_links.txt +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli.egg-info/requires.txt +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/cleepcli.egg-info/top_level.txt +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/pyproject.toml +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/requirements.txt +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/setup.cfg +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/setup.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/tests/test_check.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/tests/test_console.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/tests/test_coverage.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/tests/test_docs_breaking.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/tests/test_file_sync_all.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/tests/test_module_scaffold.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/tests/test_pico.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/tests/test_watch.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.0}/tests/test_watchsvc.py +0 -0
|
@@ -54,19 +54,31 @@ def get_core_mods(git=None, branch=None):
|
|
|
54
54
|
|
|
55
55
|
Args:
|
|
56
56
|
git (Git): Git instance. Create new instance if not provided
|
|
57
|
-
branch (str): branch
|
|
57
|
+
branch (str): optional branch/ref applied to every module (overrides
|
|
58
|
+
``mandatory-modules-branches.json`` when set)
|
|
58
59
|
|
|
59
60
|
Returns:
|
|
60
61
|
bool: True if modules installed successfully
|
|
61
62
|
"""
|
|
62
63
|
g = git or Git()
|
|
64
|
+
file_branches = {}
|
|
65
|
+
if branch is None:
|
|
66
|
+
file_branches = config.load_mandatory_module_branches()
|
|
67
|
+
if file_branches:
|
|
68
|
+
logging.info(
|
|
69
|
+
'Using per-module branches from %s',
|
|
70
|
+
config.MANDATORY_MODULES_BRANCHES_FILENAME,
|
|
71
|
+
)
|
|
63
72
|
|
|
64
73
|
for module in config.DEFAULT_MODULES:
|
|
74
|
+
mod_branch = branch if branch is not None else file_branches.get(module)
|
|
75
|
+
if mod_branch:
|
|
76
|
+
logging.info('Module "%s" -> branch "%s"', module, mod_branch)
|
|
65
77
|
module_path = os.path.join(config.MODULES_SRC, module)
|
|
66
78
|
if not os.path.exists(module_path):
|
|
67
|
-
res = g.clone_mod(module,
|
|
79
|
+
res = g.clone_mod(module, mod_branch)
|
|
68
80
|
else:
|
|
69
|
-
res = g.pull_mod(module,
|
|
81
|
+
res = g.pull_mod(module, mod_branch)
|
|
70
82
|
|
|
71
83
|
if not res:
|
|
72
84
|
logging.error('Error getting "%s" default module' % module)
|
|
@@ -976,10 +988,20 @@ def cimoddocpublish(module, version, ghtoken, ghowner, docfile):
|
|
|
976
988
|
@ci.command(hidden=True)
|
|
977
989
|
@click.pass_context
|
|
978
990
|
@click.option('--nosync', is_flag=True, default=False, help='Sync mods.')
|
|
979
|
-
@click.option(
|
|
991
|
+
@click.option(
|
|
992
|
+
'--branch',
|
|
993
|
+
default=None,
|
|
994
|
+
help=(
|
|
995
|
+
'Checkout this branch/ref for every mandatory module '
|
|
996
|
+
'(overrides mandatory-modules-branches.json in the Cleep repo)'
|
|
997
|
+
),
|
|
998
|
+
)
|
|
980
999
|
def cigetmods(ctx, nosync, branch):
|
|
981
1000
|
"""
|
|
982
|
-
Get all core modules from git repos
|
|
1001
|
+
Get all core modules from git repos.
|
|
1002
|
+
|
|
1003
|
+
Without --branch, each module uses the ref from
|
|
1004
|
+
mandatory-modules-branches.json at the Cleep repo root when present.
|
|
983
1005
|
"""
|
|
984
1006
|
if not get_core_mods(branch=branch):
|
|
985
1007
|
sys.exit(1)
|
|
@@ -54,19 +54,31 @@ def get_core_mods(git=None, branch=None):
|
|
|
54
54
|
|
|
55
55
|
Args:
|
|
56
56
|
git (Git): Git instance. Create new instance if not provided
|
|
57
|
-
branch (str): branch
|
|
57
|
+
branch (str): optional branch/ref applied to every module (overrides
|
|
58
|
+
``mandatory-modules-branches.json`` when set)
|
|
58
59
|
|
|
59
60
|
Returns:
|
|
60
61
|
bool: True if modules installed successfully
|
|
61
62
|
"""
|
|
62
63
|
g = git or Git()
|
|
64
|
+
file_branches = {}
|
|
65
|
+
if branch is None:
|
|
66
|
+
file_branches = config.load_mandatory_module_branches()
|
|
67
|
+
if file_branches:
|
|
68
|
+
logging.info(
|
|
69
|
+
'Using per-module branches from %s',
|
|
70
|
+
config.MANDATORY_MODULES_BRANCHES_FILENAME,
|
|
71
|
+
)
|
|
63
72
|
|
|
64
73
|
for module in config.DEFAULT_MODULES:
|
|
74
|
+
mod_branch = branch if branch is not None else file_branches.get(module)
|
|
75
|
+
if mod_branch:
|
|
76
|
+
logging.info('Module "%s" -> branch "%s"', module, mod_branch)
|
|
65
77
|
module_path = os.path.join(config.MODULES_SRC, module)
|
|
66
78
|
if not os.path.exists(module_path):
|
|
67
|
-
res = g.clone_mod(module,
|
|
79
|
+
res = g.clone_mod(module, mod_branch)
|
|
68
80
|
else:
|
|
69
|
-
res = g.pull_mod(module,
|
|
81
|
+
res = g.pull_mod(module, mod_branch)
|
|
70
82
|
|
|
71
83
|
if not res:
|
|
72
84
|
logging.error('Error getting "%s" default module' % module)
|
|
@@ -976,10 +988,20 @@ def cimoddocpublish(module, version, ghtoken, ghowner, docfile):
|
|
|
976
988
|
@ci.command(hidden=True)
|
|
977
989
|
@click.pass_context
|
|
978
990
|
@click.option('--nosync', is_flag=True, default=False, help='Sync mods.')
|
|
979
|
-
@click.option(
|
|
991
|
+
@click.option(
|
|
992
|
+
'--branch',
|
|
993
|
+
default=None,
|
|
994
|
+
help=(
|
|
995
|
+
'Checkout this branch/ref for every mandatory module '
|
|
996
|
+
'(overrides mandatory-modules-branches.json in the Cleep repo)'
|
|
997
|
+
),
|
|
998
|
+
)
|
|
980
999
|
def cigetmods(ctx, nosync, branch):
|
|
981
1000
|
"""
|
|
982
|
-
Get all core modules from git repos
|
|
1001
|
+
Get all core modules from git repos.
|
|
1002
|
+
|
|
1003
|
+
Without --branch, each module uses the ref from
|
|
1004
|
+
mandatory-modules-branches.json at the Cleep repo root when present.
|
|
983
1005
|
"""
|
|
984
1006
|
if not get_core_mods(branch=branch):
|
|
985
1007
|
sys.exit(1)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
|
+
import json
|
|
5
|
+
import logging
|
|
4
6
|
import os
|
|
5
7
|
from importlib.machinery import SourceFileLoader
|
|
6
8
|
try:
|
|
@@ -27,6 +29,9 @@ MODULES_REPO_URL = {
|
|
|
27
29
|
}
|
|
28
30
|
DEFAULT_MODULES = list(MODULES_REPO_URL.keys())
|
|
29
31
|
|
|
32
|
+
# Per-module git refs for cigetmods / core builds (in the Cleep core repo).
|
|
33
|
+
MANDATORY_MODULES_BRANCHES_FILENAME = "mandatory-modules-branches.json"
|
|
34
|
+
|
|
30
35
|
GITHUB_ORG = 'CleepDevice'
|
|
31
36
|
GITHUB_REPO = 'cleep'
|
|
32
37
|
GITHUB_REPO_DOCS = 'cleep-api-docs'
|
|
@@ -59,6 +64,62 @@ CORE_VERSION = get_core_version_from_sources(REPO_DIR)
|
|
|
59
64
|
|
|
60
65
|
CONFIG_DIR = '/etc/cleep'
|
|
61
66
|
|
|
67
|
+
|
|
68
|
+
def load_mandatory_module_branches(repo_dir=None):
|
|
69
|
+
"""
|
|
70
|
+
Load per-module branch/ref map from the Cleep core checkout.
|
|
71
|
+
|
|
72
|
+
File format (repo root)::
|
|
73
|
+
|
|
74
|
+
{
|
|
75
|
+
"audio": "master",
|
|
76
|
+
"cleepbus": "feature/foo",
|
|
77
|
+
...
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
repo_dir (str): Cleep core repo root (defaults to REPO_DIR)
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
dict: module name -> branch/ref string (only known mandatory modules)
|
|
85
|
+
"""
|
|
86
|
+
root = repo_dir if repo_dir is not None else REPO_DIR
|
|
87
|
+
path = os.path.join(root, MANDATORY_MODULES_BRANCHES_FILENAME)
|
|
88
|
+
if not os.path.isfile(path):
|
|
89
|
+
return {}
|
|
90
|
+
|
|
91
|
+
logger = logging.getLogger("cleepcli.config")
|
|
92
|
+
try:
|
|
93
|
+
with open(path, "r", encoding="utf-8") as handle:
|
|
94
|
+
data = json.load(handle)
|
|
95
|
+
except (OSError, ValueError) as error:
|
|
96
|
+
logger.error('Unable to read "%s": %s', path, error)
|
|
97
|
+
return {}
|
|
98
|
+
|
|
99
|
+
if not isinstance(data, dict):
|
|
100
|
+
logger.error(
|
|
101
|
+
'Invalid "%s": expected a JSON object of module -> branch', path
|
|
102
|
+
)
|
|
103
|
+
return {}
|
|
104
|
+
|
|
105
|
+
branches = {}
|
|
106
|
+
for key, value in data.items():
|
|
107
|
+
if key.startswith("$") or key.startswith("_"):
|
|
108
|
+
continue
|
|
109
|
+
if key not in MODULES_REPO_URL:
|
|
110
|
+
logger.warning(
|
|
111
|
+
'Ignoring unknown mandatory module "%s" in %s', key, path
|
|
112
|
+
)
|
|
113
|
+
continue
|
|
114
|
+
if not isinstance(value, str) or not value.strip():
|
|
115
|
+
logger.warning(
|
|
116
|
+
'Ignoring invalid branch for module "%s" in %s', key, path
|
|
117
|
+
)
|
|
118
|
+
continue
|
|
119
|
+
branches[key] = value.strip()
|
|
120
|
+
return branches
|
|
121
|
+
|
|
122
|
+
|
|
62
123
|
# Raspberry Pi Pico SDK (shared install for cleep-cli pico build)
|
|
63
124
|
PICO_SDK_DIR = '/var/opt/cleep/pico-sdk'
|
|
64
125
|
PICO_SDK_META = '/var/opt/cleep/pico-sdk.json'
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
from cleepcli.config import (
|
|
7
|
+
MANDATORY_MODULES_BRANCHES_FILENAME,
|
|
8
|
+
get_core_version_from_sources,
|
|
9
|
+
load_mandatory_module_branches,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_get_core_version_from_sources(tmp_path):
|
|
14
|
+
pkg = tmp_path / "cleep"
|
|
15
|
+
pkg.mkdir()
|
|
16
|
+
(pkg / "__init__.py").write_text('__version__ = "0.2.0"\n')
|
|
17
|
+
assert get_core_version_from_sources(str(tmp_path)) == "0.2.0"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_get_core_version_from_sources_missing_returns_none(tmp_path):
|
|
21
|
+
assert get_core_version_from_sources(str(tmp_path)) is None
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def test_load_mandatory_module_branches_missing_file(tmp_path):
|
|
25
|
+
assert load_mandatory_module_branches(str(tmp_path)) == {}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_load_mandatory_module_branches_valid(tmp_path):
|
|
29
|
+
path = tmp_path / MANDATORY_MODULES_BRANCHES_FILENAME
|
|
30
|
+
path.write_text(
|
|
31
|
+
json.dumps(
|
|
32
|
+
{
|
|
33
|
+
"update": "feat/os-update",
|
|
34
|
+
"audio": "master",
|
|
35
|
+
"unknown": "nope",
|
|
36
|
+
"_comment": "ignored",
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
encoding="utf-8",
|
|
40
|
+
)
|
|
41
|
+
assert load_mandatory_module_branches(str(tmp_path)) == {
|
|
42
|
+
"update": "feat/os-update",
|
|
43
|
+
"audio": "master",
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_load_mandatory_module_branches_invalid_json(tmp_path):
|
|
48
|
+
path = tmp_path / MANDATORY_MODULES_BRANCHES_FILENAME
|
|
49
|
+
path.write_text("{not-json", encoding="utf-8")
|
|
50
|
+
assert load_mandatory_module_branches(str(tmp_path)) == {}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
from cleepcli.config import get_core_version_from_sources
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def test_get_core_version_from_sources(tmp_path):
|
|
8
|
-
pkg = tmp_path / "cleep"
|
|
9
|
-
pkg.mkdir()
|
|
10
|
-
(pkg / "__init__.py").write_text('__version__ = "0.2.0"\n')
|
|
11
|
-
assert get_core_version_from_sources(str(tmp_path)) == "0.2.0"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def test_get_core_version_from_sources_missing_returns_none(tmp_path):
|
|
15
|
-
assert get_core_version_from_sources(str(tmp_path)) is None
|
|
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
|
|
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
|