cleepcli 1.49.8__tar.gz → 1.50.1__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.1}/PKG-INFO +1 -1
- {cleepcli-1.49.8 → cleepcli-1.50.1}/bin/ccli +55 -19
- {cleepcli-1.49.8 → cleepcli-1.50.1}/bin/cleep-cli +55 -19
- cleepcli-1.50.1/cleepcli/config.py +145 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/file.py +3 -2
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/version.py +1 -1
- {cleepcli-1.49.8 → cleepcli-1.50.1/cleepcli.egg-info}/PKG-INFO +1 -1
- cleepcli-1.50.1/tests/test_config.py +50 -0
- cleepcli-1.49.8/cleepcli/config.py +0 -71
- cleepcli-1.49.8/tests/test_config.py +0 -15
- {cleepcli-1.49.8 → cleepcli-1.50.1}/LICENSE +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/MANIFEST.in +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/README.md +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/__init__.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/check.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/ci.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/cleepapi.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/console.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/docs.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/git.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/module.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/package.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/pico.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/systemd/cleep-watch.service +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/test.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/tools.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/watch.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli/watchsvc.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli.egg-info/SOURCES.txt +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli.egg-info/dependency_links.txt +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli.egg-info/requires.txt +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/cleepcli.egg-info/top_level.txt +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/pyproject.toml +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/requirements.txt +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/setup.cfg +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/setup.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/tests/test_check.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/tests/test_console.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/tests/test_coverage.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/tests/test_docs_breaking.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/tests/test_file_sync_all.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/tests/test_module_scaffold.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/tests/test_pico.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/tests/test_watch.py +0 -0
- {cleepcli-1.49.8 → cleepcli-1.50.1}/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)
|
|
@@ -311,21 +323,35 @@ def modssync(run_scripts):
|
|
|
311
323
|
logging.info('Synchronizing mandatory modules...')
|
|
312
324
|
f = File()
|
|
313
325
|
|
|
314
|
-
|
|
326
|
+
# Order: config.MANDATORY_MODULES_ORDER (update first — InstallManifest provider)
|
|
327
|
+
for module in config.MANDATORY_MODULES_ORDER:
|
|
315
328
|
if run_scripts:
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
+
if module == "update":
|
|
330
|
+
# Full sync before manifests so InstallManifest is importable
|
|
331
|
+
# (also for update's own JSON if added later).
|
|
332
|
+
res = f.module_sync(module)
|
|
333
|
+
if not res:
|
|
334
|
+
sys.exit(1)
|
|
335
|
+
res = f.module_run_phase_manifest(module, "preinst")
|
|
336
|
+
if not res:
|
|
337
|
+
sys.exit(1)
|
|
338
|
+
res = f.module_run_phase_manifest(module, "postinst")
|
|
339
|
+
if not res:
|
|
340
|
+
sys.exit(1)
|
|
341
|
+
else:
|
|
342
|
+
# Same order as package install: scripts + preinst, then files, then postinst
|
|
343
|
+
res = f.module_sync(module, backend=False, frontend=False, scripts=True)
|
|
344
|
+
if not res:
|
|
345
|
+
sys.exit(1)
|
|
346
|
+
res = f.module_run_phase_manifest(module, "preinst")
|
|
347
|
+
if not res:
|
|
348
|
+
sys.exit(1)
|
|
349
|
+
res = f.module_sync(module, backend=True, frontend=True, scripts=True)
|
|
350
|
+
if not res:
|
|
351
|
+
sys.exit(1)
|
|
352
|
+
res = f.module_run_phase_manifest(module, "postinst")
|
|
353
|
+
if not res:
|
|
354
|
+
sys.exit(1)
|
|
329
355
|
else:
|
|
330
356
|
res = f.module_sync(module)
|
|
331
357
|
if not res:
|
|
@@ -976,10 +1002,20 @@ def cimoddocpublish(module, version, ghtoken, ghowner, docfile):
|
|
|
976
1002
|
@ci.command(hidden=True)
|
|
977
1003
|
@click.pass_context
|
|
978
1004
|
@click.option('--nosync', is_flag=True, default=False, help='Sync mods.')
|
|
979
|
-
@click.option(
|
|
1005
|
+
@click.option(
|
|
1006
|
+
'--branch',
|
|
1007
|
+
default=None,
|
|
1008
|
+
help=(
|
|
1009
|
+
'Checkout this branch/ref for every mandatory module '
|
|
1010
|
+
'(overrides mandatory-modules-branches.json in the Cleep repo)'
|
|
1011
|
+
),
|
|
1012
|
+
)
|
|
980
1013
|
def cigetmods(ctx, nosync, branch):
|
|
981
1014
|
"""
|
|
982
|
-
Get all core modules from git repos
|
|
1015
|
+
Get all core modules from git repos.
|
|
1016
|
+
|
|
1017
|
+
Without --branch, each module uses the ref from
|
|
1018
|
+
mandatory-modules-branches.json at the Cleep repo root when present.
|
|
983
1019
|
"""
|
|
984
1020
|
if not get_core_mods(branch=branch):
|
|
985
1021
|
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)
|
|
@@ -311,21 +323,35 @@ def modssync(run_scripts):
|
|
|
311
323
|
logging.info('Synchronizing mandatory modules...')
|
|
312
324
|
f = File()
|
|
313
325
|
|
|
314
|
-
|
|
326
|
+
# Order: config.MANDATORY_MODULES_ORDER (update first — InstallManifest provider)
|
|
327
|
+
for module in config.MANDATORY_MODULES_ORDER:
|
|
315
328
|
if run_scripts:
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
+
if module == "update":
|
|
330
|
+
# Full sync before manifests so InstallManifest is importable
|
|
331
|
+
# (also for update's own JSON if added later).
|
|
332
|
+
res = f.module_sync(module)
|
|
333
|
+
if not res:
|
|
334
|
+
sys.exit(1)
|
|
335
|
+
res = f.module_run_phase_manifest(module, "preinst")
|
|
336
|
+
if not res:
|
|
337
|
+
sys.exit(1)
|
|
338
|
+
res = f.module_run_phase_manifest(module, "postinst")
|
|
339
|
+
if not res:
|
|
340
|
+
sys.exit(1)
|
|
341
|
+
else:
|
|
342
|
+
# Same order as package install: scripts + preinst, then files, then postinst
|
|
343
|
+
res = f.module_sync(module, backend=False, frontend=False, scripts=True)
|
|
344
|
+
if not res:
|
|
345
|
+
sys.exit(1)
|
|
346
|
+
res = f.module_run_phase_manifest(module, "preinst")
|
|
347
|
+
if not res:
|
|
348
|
+
sys.exit(1)
|
|
349
|
+
res = f.module_sync(module, backend=True, frontend=True, scripts=True)
|
|
350
|
+
if not res:
|
|
351
|
+
sys.exit(1)
|
|
352
|
+
res = f.module_run_phase_manifest(module, "postinst")
|
|
353
|
+
if not res:
|
|
354
|
+
sys.exit(1)
|
|
329
355
|
else:
|
|
330
356
|
res = f.module_sync(module)
|
|
331
357
|
if not res:
|
|
@@ -976,10 +1002,20 @@ def cimoddocpublish(module, version, ghtoken, ghowner, docfile):
|
|
|
976
1002
|
@ci.command(hidden=True)
|
|
977
1003
|
@click.pass_context
|
|
978
1004
|
@click.option('--nosync', is_flag=True, default=False, help='Sync mods.')
|
|
979
|
-
@click.option(
|
|
1005
|
+
@click.option(
|
|
1006
|
+
'--branch',
|
|
1007
|
+
default=None,
|
|
1008
|
+
help=(
|
|
1009
|
+
'Checkout this branch/ref for every mandatory module '
|
|
1010
|
+
'(overrides mandatory-modules-branches.json in the Cleep repo)'
|
|
1011
|
+
),
|
|
1012
|
+
)
|
|
980
1013
|
def cigetmods(ctx, nosync, branch):
|
|
981
1014
|
"""
|
|
982
|
-
Get all core modules from git repos
|
|
1015
|
+
Get all core modules from git repos.
|
|
1016
|
+
|
|
1017
|
+
Without --branch, each module uses the ref from
|
|
1018
|
+
mandatory-modules-branches.json at the Cleep repo root when present.
|
|
983
1019
|
"""
|
|
984
1020
|
if not get_core_mods(branch=branch):
|
|
985
1021
|
sys.exit(1)
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
from importlib.machinery import SourceFileLoader
|
|
8
|
+
try:
|
|
9
|
+
import cleep
|
|
10
|
+
except:
|
|
11
|
+
class cleep:
|
|
12
|
+
# fallback to supposed cleep installation path
|
|
13
|
+
__path__ = ['/usr/lib/python3/dist-packages/cleep']
|
|
14
|
+
|
|
15
|
+
def get_core_version_from_sources(repo_dir):
|
|
16
|
+
try:
|
|
17
|
+
cleep_sources = SourceFileLoader("cleep_sources", os.path.join(repo_dir, 'cleep', '__init__.py')).load_module()
|
|
18
|
+
return cleep_sources.__version__
|
|
19
|
+
except:
|
|
20
|
+
return None
|
|
21
|
+
|
|
22
|
+
# Mandatory apps sync/install order. `update` MUST stay first: every app's
|
|
23
|
+
# preinst/postinst JSON is executed by InstallManifest (lives in update).
|
|
24
|
+
# On a device update is already installed; in CI from an empty modules tree
|
|
25
|
+
# this order is what makes declarative installs importable.
|
|
26
|
+
MANDATORY_MODULES_ORDER = (
|
|
27
|
+
"update",
|
|
28
|
+
"system",
|
|
29
|
+
"parameters",
|
|
30
|
+
"cleepbus",
|
|
31
|
+
"audio",
|
|
32
|
+
"network",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
MODULES_REPO_URL = {
|
|
36
|
+
"update": "https://github.com/CleepDevice/cleepapp-update.git",
|
|
37
|
+
"system": "https://github.com/CleepDevice/cleepapp-system.git",
|
|
38
|
+
"parameters": "https://github.com/CleepDevice/cleepapp-parameters.git",
|
|
39
|
+
"cleepbus": "https://github.com/CleepDevice/cleepapp-cleepbus.git",
|
|
40
|
+
"audio": "https://github.com/CleepDevice/cleepapp-audio.git",
|
|
41
|
+
"network": "https://github.com/CleepDevice/cleepapp-network.git",
|
|
42
|
+
}
|
|
43
|
+
DEFAULT_MODULES = list(MANDATORY_MODULES_ORDER)
|
|
44
|
+
|
|
45
|
+
# Per-module git refs for cigetmods / core builds (in the Cleep core repo).
|
|
46
|
+
MANDATORY_MODULES_BRANCHES_FILENAME = "mandatory-modules-branches.json"
|
|
47
|
+
|
|
48
|
+
GITHUB_ORG = 'CleepDevice'
|
|
49
|
+
GITHUB_REPO = 'cleep'
|
|
50
|
+
GITHUB_REPO_DOCS = 'cleep-api-docs'
|
|
51
|
+
GITHUB_REPO_APP_DOCS = "cleep-app-docs"
|
|
52
|
+
|
|
53
|
+
REPO_URL = 'https://github.com/CleepDevice/cleep.git'
|
|
54
|
+
REPO_DIR = os.environ.get('REPO_DIR', '/root/cleep-dev')
|
|
55
|
+
|
|
56
|
+
CORE_SRC = '%s/cleep' % REPO_DIR
|
|
57
|
+
CORE_DST = cleep.__path__[0] if cleep.__path__ else None
|
|
58
|
+
|
|
59
|
+
HTML_SRC = '%s/html' % REPO_DIR
|
|
60
|
+
HTML_DST = '/opt/cleep/html'
|
|
61
|
+
|
|
62
|
+
MODULES_SRC = '%s/modules' % REPO_DIR
|
|
63
|
+
MODULES_DST = '/opt/cleep/modules'
|
|
64
|
+
MODULES_HTML_DST = '%s/js/modules' % HTML_DST
|
|
65
|
+
MODULES_SCRIPTS_DST = '/opt/cleep/scripts'
|
|
66
|
+
|
|
67
|
+
BIN_SRC = '%s/bin' % REPO_DIR
|
|
68
|
+
BIN_DST = '/usr/bin'
|
|
69
|
+
|
|
70
|
+
MEDIA_SRC = '%s/medias' % REPO_DIR
|
|
71
|
+
MEDIA_DST = '/opt/cleep'
|
|
72
|
+
|
|
73
|
+
DOCS_AUTHOR = 'CleepDevice'
|
|
74
|
+
DOCS_PROJECT_NAME = 'Cleep core'
|
|
75
|
+
|
|
76
|
+
CORE_VERSION = get_core_version_from_sources(REPO_DIR)
|
|
77
|
+
|
|
78
|
+
CONFIG_DIR = '/etc/cleep'
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def load_mandatory_module_branches(repo_dir=None):
|
|
82
|
+
"""
|
|
83
|
+
Load per-module branch/ref map from the Cleep core checkout.
|
|
84
|
+
|
|
85
|
+
File format (repo root)::
|
|
86
|
+
|
|
87
|
+
{
|
|
88
|
+
"audio": "master",
|
|
89
|
+
"cleepbus": "feature/foo",
|
|
90
|
+
...
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
repo_dir (str): Cleep core repo root (defaults to REPO_DIR)
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
dict: module name -> branch/ref string (only known mandatory modules)
|
|
98
|
+
"""
|
|
99
|
+
root = repo_dir if repo_dir is not None else REPO_DIR
|
|
100
|
+
path = os.path.join(root, MANDATORY_MODULES_BRANCHES_FILENAME)
|
|
101
|
+
if not os.path.isfile(path):
|
|
102
|
+
return {}
|
|
103
|
+
|
|
104
|
+
logger = logging.getLogger("cleepcli.config")
|
|
105
|
+
try:
|
|
106
|
+
with open(path, "r", encoding="utf-8") as handle:
|
|
107
|
+
data = json.load(handle)
|
|
108
|
+
except (OSError, ValueError) as error:
|
|
109
|
+
logger.error('Unable to read "%s": %s', path, error)
|
|
110
|
+
return {}
|
|
111
|
+
|
|
112
|
+
if not isinstance(data, dict):
|
|
113
|
+
logger.error(
|
|
114
|
+
'Invalid "%s": expected a JSON object of module -> branch', path
|
|
115
|
+
)
|
|
116
|
+
return {}
|
|
117
|
+
|
|
118
|
+
branches = {}
|
|
119
|
+
for key, value in data.items():
|
|
120
|
+
if key.startswith("$") or key.startswith("_"):
|
|
121
|
+
continue
|
|
122
|
+
if key not in MODULES_REPO_URL:
|
|
123
|
+
logger.warning(
|
|
124
|
+
'Ignoring unknown mandatory module "%s" in %s', key, path
|
|
125
|
+
)
|
|
126
|
+
continue
|
|
127
|
+
if not isinstance(value, str) or not value.strip():
|
|
128
|
+
logger.warning(
|
|
129
|
+
'Ignoring invalid branch for module "%s" in %s', key, path
|
|
130
|
+
)
|
|
131
|
+
continue
|
|
132
|
+
branches[key] = value.strip()
|
|
133
|
+
return branches
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
# Raspberry Pi Pico SDK (shared install for cleep-cli pico build)
|
|
137
|
+
PICO_SDK_DIR = '/var/opt/cleep/pico-sdk'
|
|
138
|
+
PICO_SDK_META = '/var/opt/cleep/pico-sdk.json'
|
|
139
|
+
PICO_SDK_REPO = 'https://github.com/raspberrypi/pico-sdk.git'
|
|
140
|
+
PICO_TOOLCHAIN_PACKAGES = (
|
|
141
|
+
'cmake',
|
|
142
|
+
'gcc-arm-none-eabi',
|
|
143
|
+
'libnewlib-arm-none-eabi',
|
|
144
|
+
'libstdc++-arm-none-eabi-newlib',
|
|
145
|
+
)
|
|
@@ -193,9 +193,10 @@ fi
|
|
|
193
193
|
MODE_INSTALL,
|
|
194
194
|
)
|
|
195
195
|
from cleep.libs.internals.cleepfilesystem import CleepFilesystem
|
|
196
|
-
except ImportError:
|
|
196
|
+
except ImportError as exc:
|
|
197
197
|
self.logger.error(
|
|
198
|
-
"Unable to import InstallManifest; is Cleep update module installed?"
|
|
198
|
+
"Unable to import InstallManifest; is Cleep update module installed? (%s)",
|
|
199
|
+
exc,
|
|
199
200
|
)
|
|
200
201
|
return False
|
|
201
202
|
|
|
@@ -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,71 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding: utf-8 -*-
|
|
3
|
-
|
|
4
|
-
import os
|
|
5
|
-
from importlib.machinery import SourceFileLoader
|
|
6
|
-
try:
|
|
7
|
-
import cleep
|
|
8
|
-
except:
|
|
9
|
-
class cleep:
|
|
10
|
-
# fallback to supposed cleep installation path
|
|
11
|
-
__path__ = ['/usr/lib/python3/dist-packages/cleep']
|
|
12
|
-
|
|
13
|
-
def get_core_version_from_sources(repo_dir):
|
|
14
|
-
try:
|
|
15
|
-
cleep_sources = SourceFileLoader("cleep_sources", os.path.join(repo_dir, 'cleep', '__init__.py')).load_module()
|
|
16
|
-
return cleep_sources.__version__
|
|
17
|
-
except:
|
|
18
|
-
return None
|
|
19
|
-
|
|
20
|
-
MODULES_REPO_URL = {
|
|
21
|
-
'system': 'https://github.com/CleepDevice/cleepapp-system.git',
|
|
22
|
-
'parameters': 'https://github.com/CleepDevice/cleepapp-parameters.git',
|
|
23
|
-
'cleepbus': 'https://github.com/CleepDevice/cleepapp-cleepbus.git',
|
|
24
|
-
'audio': 'https://github.com/CleepDevice/cleepapp-audio.git',
|
|
25
|
-
'network': 'https://github.com/CleepDevice/cleepapp-network.git',
|
|
26
|
-
'update': 'https://github.com/CleepDevice/cleepapp-update.git',
|
|
27
|
-
}
|
|
28
|
-
DEFAULT_MODULES = list(MODULES_REPO_URL.keys())
|
|
29
|
-
|
|
30
|
-
GITHUB_ORG = 'CleepDevice'
|
|
31
|
-
GITHUB_REPO = 'cleep'
|
|
32
|
-
GITHUB_REPO_DOCS = 'cleep-api-docs'
|
|
33
|
-
GITHUB_REPO_APP_DOCS = "cleep-app-docs"
|
|
34
|
-
|
|
35
|
-
REPO_URL = 'https://github.com/CleepDevice/cleep.git'
|
|
36
|
-
REPO_DIR = os.environ.get('REPO_DIR', '/root/cleep-dev')
|
|
37
|
-
|
|
38
|
-
CORE_SRC = '%s/cleep' % REPO_DIR
|
|
39
|
-
CORE_DST = cleep.__path__[0] if cleep.__path__ else None
|
|
40
|
-
|
|
41
|
-
HTML_SRC = '%s/html' % REPO_DIR
|
|
42
|
-
HTML_DST = '/opt/cleep/html'
|
|
43
|
-
|
|
44
|
-
MODULES_SRC = '%s/modules' % REPO_DIR
|
|
45
|
-
MODULES_DST = '/opt/cleep/modules'
|
|
46
|
-
MODULES_HTML_DST = '%s/js/modules' % HTML_DST
|
|
47
|
-
MODULES_SCRIPTS_DST = '/opt/cleep/scripts'
|
|
48
|
-
|
|
49
|
-
BIN_SRC = '%s/bin' % REPO_DIR
|
|
50
|
-
BIN_DST = '/usr/bin'
|
|
51
|
-
|
|
52
|
-
MEDIA_SRC = '%s/medias' % REPO_DIR
|
|
53
|
-
MEDIA_DST = '/opt/cleep'
|
|
54
|
-
|
|
55
|
-
DOCS_AUTHOR = 'CleepDevice'
|
|
56
|
-
DOCS_PROJECT_NAME = 'Cleep core'
|
|
57
|
-
|
|
58
|
-
CORE_VERSION = get_core_version_from_sources(REPO_DIR)
|
|
59
|
-
|
|
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
|
-
)
|
|
@@ -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
|