led-controller-version-3-effect-creation 3.0.2__py3-none-any.whl
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.
- led_controller_version_3_effect_creation-3.0.2.dist-info/METADATA +144 -0
- led_controller_version_3_effect_creation-3.0.2.dist-info/RECORD +25 -0
- led_controller_version_3_effect_creation-3.0.2.dist-info/WHEEL +4 -0
- led_controller_version_3_effect_creation-3.0.2.dist-info/entry_points.txt +3 -0
- lefx/effect_creation/__init__.py +54 -0
- lefx/effect_creation/build.py +217 -0
- lefx/effect_creation/cli.py +156 -0
- lefx/effect_creation/imports.py +143 -0
- lefx/effect_creation/scaffold.py +330 -0
- lefx/effect_creation/source.py +258 -0
- lefx/effect_creation/studio/__init__.py +95 -0
- lefx/effect_creation/studio/app.py +169 -0
- lefx/effect_creation/studio/authoring.py +196 -0
- lefx/effect_creation/studio/blueprint.py +759 -0
- lefx/effect_creation/studio/calibrate.py +185 -0
- lefx/effect_creation/studio/calibration_page.py +420 -0
- lefx/effect_creation/studio/catalogue.py +219 -0
- lefx/effect_creation/studio/parameters.py +730 -0
- lefx/effect_creation/studio/preset_dialog.py +188 -0
- lefx/effect_creation/studio/project.py +302 -0
- lefx/effect_creation/studio/ring.py +172 -0
- lefx/effect_creation/studio/session.py +307 -0
- lefx/effect_creation/studio/source_editor.py +902 -0
- lefx/effect_creation/studio/window.py +656 -0
- lefx/effect_creation/validate.py +263 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"""Reading an editable effect source directory.
|
|
2
|
+
|
|
3
|
+
A source is what an author edits; a package is what a build produces. Keeping
|
|
4
|
+
the two words apart matters, because almost every confusing failure in the
|
|
5
|
+
predecessor came from treating a directory and an archive as the same thing.
|
|
6
|
+
|
|
7
|
+
Title, description, schemas and form live in the Python class, not in the YAML
|
|
8
|
+
manifest. The manifest carries only what the class cannot know about itself:
|
|
9
|
+
which source namespace it belongs to and where its entry point is.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import json
|
|
15
|
+
from dataclasses import dataclass
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import Any, Mapping
|
|
18
|
+
|
|
19
|
+
import yaml
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class SourceError(ValueError):
|
|
23
|
+
"""A source directory does not satisfy the LEFX V3 layout or manifest rules."""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
EFFECT_MANIFEST_STEMS = ("effect.yaml", "effect.yml", "effect.json")
|
|
27
|
+
SET_MANIFEST_STEMS = ("set.yaml", "set.yml", "set.json")
|
|
28
|
+
|
|
29
|
+
_EFFECT_REQUIRED = ("source_id",)
|
|
30
|
+
_EFFECT_ALLOWED = frozenset(
|
|
31
|
+
_EFFECT_REQUIRED
|
|
32
|
+
+ (
|
|
33
|
+
"package_id",
|
|
34
|
+
"entry_file",
|
|
35
|
+
"entry_class",
|
|
36
|
+
"author",
|
|
37
|
+
"vendor",
|
|
38
|
+
"license",
|
|
39
|
+
"compatible_hardware",
|
|
40
|
+
"package_version",
|
|
41
|
+
"min_sdk_version",
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
_SET_REQUIRED = ("set_id", "source_id")
|
|
46
|
+
_SET_ALLOWED = frozenset(
|
|
47
|
+
_SET_REQUIRED
|
|
48
|
+
+ (
|
|
49
|
+
"title",
|
|
50
|
+
"description",
|
|
51
|
+
"version",
|
|
52
|
+
"min_sdk_version",
|
|
53
|
+
"effects",
|
|
54
|
+
"tags",
|
|
55
|
+
"author",
|
|
56
|
+
"vendor",
|
|
57
|
+
"license",
|
|
58
|
+
)
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# Names that carried meaning in older generations and must not be silently
|
|
62
|
+
# accepted now, because accepting them would mean ignoring what they said.
|
|
63
|
+
_RETIRED_KEYS = frozenset({"commands", "widgets", "common", "type", "overlay_mode", "title", "description"})
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _read_manifest(directory: Path, stems: tuple[str, ...], label: str) -> tuple[Path, Any]:
|
|
67
|
+
found = [directory / stem for stem in stems if (directory / stem).is_file()]
|
|
68
|
+
if not found:
|
|
69
|
+
raise SourceError(
|
|
70
|
+
f"{label} {directory} has no manifest; expected one of: {', '.join(stems)}"
|
|
71
|
+
)
|
|
72
|
+
if len(found) > 1:
|
|
73
|
+
names = ", ".join(path.name for path in found)
|
|
74
|
+
raise SourceError(f"{label} {directory} has several manifests: {names}")
|
|
75
|
+
|
|
76
|
+
path = found[0]
|
|
77
|
+
text = path.read_text(encoding="utf-8")
|
|
78
|
+
try:
|
|
79
|
+
payload = json.loads(text) if path.suffix == ".json" else yaml.safe_load(text)
|
|
80
|
+
except (json.JSONDecodeError, yaml.YAMLError) as exc:
|
|
81
|
+
raise SourceError(f"{path} is malformed: {exc}") from exc
|
|
82
|
+
if not isinstance(payload, Mapping):
|
|
83
|
+
raise SourceError(f"{path} must contain an object")
|
|
84
|
+
return path, dict(payload)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _check_keys(
|
|
88
|
+
payload: Mapping[str, Any], required: tuple[str, ...], allowed: frozenset[str], path: Path
|
|
89
|
+
) -> None:
|
|
90
|
+
missing = [key for key in required if not str(payload.get(key, "")).strip()]
|
|
91
|
+
if missing:
|
|
92
|
+
raise SourceError(f"{path} is missing: {', '.join(missing)}")
|
|
93
|
+
unknown = set(payload) - allowed
|
|
94
|
+
if not unknown:
|
|
95
|
+
return
|
|
96
|
+
retired = sorted(unknown & _RETIRED_KEYS)
|
|
97
|
+
if retired:
|
|
98
|
+
raise SourceError(
|
|
99
|
+
f"{path} declares {', '.join(retired)}, which V3 does not use. "
|
|
100
|
+
"The definition class is the single source of truth for the contract."
|
|
101
|
+
)
|
|
102
|
+
raise SourceError(f"{path} has unknown keys: {', '.join(sorted(unknown))}")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@dataclass(slots=True, frozen=True)
|
|
106
|
+
class EffectSource:
|
|
107
|
+
"""One editable definition directory."""
|
|
108
|
+
|
|
109
|
+
root: Path
|
|
110
|
+
manifest_path: Path
|
|
111
|
+
source_id: str
|
|
112
|
+
entry_file: str
|
|
113
|
+
entry_class: str | None
|
|
114
|
+
package_id: str | None
|
|
115
|
+
author: str | None = None
|
|
116
|
+
vendor: str | None = None
|
|
117
|
+
license_id: str | None = None
|
|
118
|
+
package_version: int = 1
|
|
119
|
+
min_sdk_version: str = "3.0.0"
|
|
120
|
+
compatible_hardware: tuple[str, ...] = ()
|
|
121
|
+
|
|
122
|
+
@property
|
|
123
|
+
def entry_path(self) -> Path:
|
|
124
|
+
return self.root / self.entry_file
|
|
125
|
+
|
|
126
|
+
@property
|
|
127
|
+
def entry_module(self) -> str:
|
|
128
|
+
return Path(self.entry_file).stem
|
|
129
|
+
|
|
130
|
+
@property
|
|
131
|
+
def presets_path(self) -> Path | None:
|
|
132
|
+
for name in ("presets.yaml", "presets.yml", "presets.json"):
|
|
133
|
+
candidate = self.root / name
|
|
134
|
+
if candidate.is_file():
|
|
135
|
+
return candidate
|
|
136
|
+
return None
|
|
137
|
+
|
|
138
|
+
def presets(self) -> dict[str, Any]:
|
|
139
|
+
path = self.presets_path
|
|
140
|
+
if path is None:
|
|
141
|
+
return {}
|
|
142
|
+
text = path.read_text(encoding="utf-8")
|
|
143
|
+
try:
|
|
144
|
+
payload = json.loads(text) if path.suffix == ".json" else yaml.safe_load(text)
|
|
145
|
+
except (json.JSONDecodeError, yaml.YAMLError) as exc:
|
|
146
|
+
raise SourceError(f"{path} is malformed: {exc}") from exc
|
|
147
|
+
if payload is None:
|
|
148
|
+
return {}
|
|
149
|
+
if not isinstance(payload, Mapping) or not isinstance(payload.get("presets"), Mapping):
|
|
150
|
+
raise SourceError(f"{path} must contain a 'presets' object")
|
|
151
|
+
return dict(payload["presets"])
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def load_effect_source(directory: str | Path) -> EffectSource:
|
|
155
|
+
root = Path(directory).expanduser().resolve()
|
|
156
|
+
if not root.is_dir():
|
|
157
|
+
raise SourceError(f"No source directory at {root}")
|
|
158
|
+
|
|
159
|
+
path, payload = _read_manifest(root, EFFECT_MANIFEST_STEMS, "Effect source")
|
|
160
|
+
_check_keys(payload, _EFFECT_REQUIRED, _EFFECT_ALLOWED, path)
|
|
161
|
+
|
|
162
|
+
entry_file = str(payload.get("entry_file") or "effect.py")
|
|
163
|
+
if not (root / entry_file).is_file():
|
|
164
|
+
raise SourceError(f"{path} points at {entry_file}, which does not exist")
|
|
165
|
+
|
|
166
|
+
hardware = payload.get("compatible_hardware", ())
|
|
167
|
+
if isinstance(hardware, str):
|
|
168
|
+
hardware = (hardware,)
|
|
169
|
+
|
|
170
|
+
return EffectSource(
|
|
171
|
+
root=root,
|
|
172
|
+
manifest_path=path,
|
|
173
|
+
source_id=str(payload["source_id"]).strip(),
|
|
174
|
+
entry_file=entry_file,
|
|
175
|
+
entry_class=(str(payload["entry_class"]).strip() if payload.get("entry_class") else None),
|
|
176
|
+
package_id=(str(payload["package_id"]).strip() if payload.get("package_id") else None),
|
|
177
|
+
author=payload.get("author"),
|
|
178
|
+
vendor=payload.get("vendor"),
|
|
179
|
+
license_id=payload.get("license"),
|
|
180
|
+
package_version=int(payload.get("package_version", 1)),
|
|
181
|
+
min_sdk_version=str(payload.get("min_sdk_version", "3.0.0")),
|
|
182
|
+
compatible_hardware=tuple(str(item) for item in hardware),
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
@dataclass(slots=True, frozen=True)
|
|
187
|
+
class EffectSetSource:
|
|
188
|
+
"""A directory collecting prebuilt packages into one distributable set."""
|
|
189
|
+
|
|
190
|
+
root: Path
|
|
191
|
+
manifest_path: Path
|
|
192
|
+
set_id: str
|
|
193
|
+
source_id: str
|
|
194
|
+
title: str
|
|
195
|
+
description: str = ""
|
|
196
|
+
version: int = 1
|
|
197
|
+
min_sdk_version: str = "3.0.0"
|
|
198
|
+
tags: tuple[str, ...] = ()
|
|
199
|
+
author: str | None = None
|
|
200
|
+
vendor: str | None = None
|
|
201
|
+
license_id: str | None = None
|
|
202
|
+
members: tuple[str, ...] = ()
|
|
203
|
+
|
|
204
|
+
@property
|
|
205
|
+
def effects_dir(self) -> Path:
|
|
206
|
+
return self.root / "effects"
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def load_effect_set_source(directory: str | Path) -> EffectSetSource:
|
|
210
|
+
root = Path(directory).expanduser().resolve()
|
|
211
|
+
if not root.is_dir():
|
|
212
|
+
raise SourceError(f"No set source directory at {root}")
|
|
213
|
+
|
|
214
|
+
path, payload = _read_manifest(root, SET_MANIFEST_STEMS, "Set source")
|
|
215
|
+
_check_keys(payload, _SET_REQUIRED, _SET_ALLOWED, path)
|
|
216
|
+
|
|
217
|
+
effects_dir = root / "effects"
|
|
218
|
+
if not effects_dir.is_dir():
|
|
219
|
+
raise SourceError(f"{root} has no effects/ directory")
|
|
220
|
+
|
|
221
|
+
declared = payload.get("effects")
|
|
222
|
+
if declared is None:
|
|
223
|
+
members = tuple(sorted(item.name for item in effects_dir.glob("*.lefx")))
|
|
224
|
+
else:
|
|
225
|
+
if not isinstance(declared, list) or not declared:
|
|
226
|
+
raise SourceError(f"{path} 'effects' must be a non-empty list")
|
|
227
|
+
members = tuple(str(item) for item in declared)
|
|
228
|
+
if not members:
|
|
229
|
+
raise SourceError(f"{effects_dir} contains no built .lefx packages")
|
|
230
|
+
|
|
231
|
+
for member in members:
|
|
232
|
+
if not (effects_dir / member).is_file():
|
|
233
|
+
raise SourceError(f"{path} lists {member!r}, which is not in {effects_dir}")
|
|
234
|
+
|
|
235
|
+
return EffectSetSource(
|
|
236
|
+
root=root,
|
|
237
|
+
manifest_path=path,
|
|
238
|
+
set_id=str(payload["set_id"]).strip(),
|
|
239
|
+
source_id=str(payload["source_id"]).strip(),
|
|
240
|
+
title=str(payload.get("title") or payload["set_id"]),
|
|
241
|
+
description=str(payload.get("description", "")),
|
|
242
|
+
version=int(payload.get("version", 1)),
|
|
243
|
+
min_sdk_version=str(payload.get("min_sdk_version", "3.0.0")),
|
|
244
|
+
tags=tuple(str(item) for item in payload.get("tags", ())),
|
|
245
|
+
author=payload.get("author"),
|
|
246
|
+
vendor=payload.get("vendor"),
|
|
247
|
+
license_id=payload.get("license"),
|
|
248
|
+
members=members,
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
__all__ = [
|
|
253
|
+
"EffectSetSource",
|
|
254
|
+
"EffectSource",
|
|
255
|
+
"SourceError",
|
|
256
|
+
"load_effect_set_source",
|
|
257
|
+
"load_effect_source",
|
|
258
|
+
]
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""LEFX V3 studio: a window for playing, tuning, calibrating and authoring effects.
|
|
2
|
+
|
|
3
|
+
Only the Qt-free half is re-exported here. ``window``, ``ring``, ``parameters``
|
|
4
|
+
and ``app`` import PySide6 and are reached through :func:`lefx.effect_creation.studio.app.main`
|
|
5
|
+
or imported directly — so that the pieces worth testing can be imported by a
|
|
6
|
+
test run that has no display, and so that importing this package does not build
|
|
7
|
+
a toolkit's worth of objects to answer a question about a catalogue.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from .authoring import (
|
|
13
|
+
PresetDraft,
|
|
14
|
+
check_draft,
|
|
15
|
+
find_source_dir,
|
|
16
|
+
slugify,
|
|
17
|
+
suggest_preset_id,
|
|
18
|
+
write_preset_checked,
|
|
19
|
+
)
|
|
20
|
+
from .calibrate import (
|
|
21
|
+
MIN_SAMPLES,
|
|
22
|
+
Fit,
|
|
23
|
+
Sample,
|
|
24
|
+
circular_mean,
|
|
25
|
+
circular_spread,
|
|
26
|
+
fit_calibration,
|
|
27
|
+
sector_angle,
|
|
28
|
+
suggested_sectors,
|
|
29
|
+
)
|
|
30
|
+
from .project import (
|
|
31
|
+
Project,
|
|
32
|
+
recalled,
|
|
33
|
+
remember,
|
|
34
|
+
resolve,
|
|
35
|
+
under_a_frozen_build,
|
|
36
|
+
)
|
|
37
|
+
from .catalogue import (
|
|
38
|
+
KIND_LABELS,
|
|
39
|
+
Entry,
|
|
40
|
+
Playback,
|
|
41
|
+
entries,
|
|
42
|
+
filtered,
|
|
43
|
+
playback_for,
|
|
44
|
+
pulls_a_provider,
|
|
45
|
+
starting_config,
|
|
46
|
+
starting_inputs,
|
|
47
|
+
)
|
|
48
|
+
from .session import (
|
|
49
|
+
NULL_OUTPUT,
|
|
50
|
+
STUDIO_CHANNEL,
|
|
51
|
+
StudioSession,
|
|
52
|
+
TappedSink,
|
|
53
|
+
available_outputs,
|
|
54
|
+
device_in_use,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
STUDIO_VERSION = "3.0.0"
|
|
58
|
+
|
|
59
|
+
__all__ = [
|
|
60
|
+
"KIND_LABELS",
|
|
61
|
+
"MIN_SAMPLES",
|
|
62
|
+
"NULL_OUTPUT",
|
|
63
|
+
"STUDIO_CHANNEL",
|
|
64
|
+
"STUDIO_VERSION",
|
|
65
|
+
"Entry",
|
|
66
|
+
"Fit",
|
|
67
|
+
"Playback",
|
|
68
|
+
"Project",
|
|
69
|
+
"PresetDraft",
|
|
70
|
+
"Sample",
|
|
71
|
+
"StudioSession",
|
|
72
|
+
"TappedSink",
|
|
73
|
+
"available_outputs",
|
|
74
|
+
"circular_mean",
|
|
75
|
+
"check_draft",
|
|
76
|
+
"circular_spread",
|
|
77
|
+
"device_in_use",
|
|
78
|
+
"entries",
|
|
79
|
+
"filtered",
|
|
80
|
+
"find_source_dir",
|
|
81
|
+
"fit_calibration",
|
|
82
|
+
"playback_for",
|
|
83
|
+
"pulls_a_provider",
|
|
84
|
+
"recalled",
|
|
85
|
+
"remember",
|
|
86
|
+
"resolve",
|
|
87
|
+
"sector_angle",
|
|
88
|
+
"slugify",
|
|
89
|
+
"starting_config",
|
|
90
|
+
"starting_inputs",
|
|
91
|
+
"suggest_preset_id",
|
|
92
|
+
"suggested_sectors",
|
|
93
|
+
"under_a_frozen_build",
|
|
94
|
+
"write_preset_checked",
|
|
95
|
+
]
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"""The ``lefx-studio`` console script.
|
|
2
|
+
|
|
3
|
+
Starts the window and hands it a session. Everything else is in the modules the
|
|
4
|
+
window pulls in; this file exists to have one obvious place where the process
|
|
5
|
+
begins and ends.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import logging
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
from .project import Project, iter_paths, remember, resolve, under_a_frozen_build
|
|
17
|
+
from .session import NULL_OUTPUT, StudioSession, available_outputs
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
21
|
+
parser = argparse.ArgumentParser(
|
|
22
|
+
prog="lefx-studio",
|
|
23
|
+
description="Play, tune, calibrate and author LEFX effects.",
|
|
24
|
+
)
|
|
25
|
+
parser.add_argument(
|
|
26
|
+
"--output",
|
|
27
|
+
default=NULL_OUTPUT,
|
|
28
|
+
help=(
|
|
29
|
+
"Which device to open at start. The studio can switch later; "
|
|
30
|
+
f"installed right now: {', '.join(available_outputs())}"
|
|
31
|
+
),
|
|
32
|
+
)
|
|
33
|
+
parser.add_argument("--led-count", type=int, default=12)
|
|
34
|
+
parser.add_argument("--fps", type=float, default=30.0)
|
|
35
|
+
parser.add_argument(
|
|
36
|
+
"--project",
|
|
37
|
+
default=None,
|
|
38
|
+
metavar="PATH",
|
|
39
|
+
help=(
|
|
40
|
+
"The checkout to work on. Everything is derived from it: where effects "
|
|
41
|
+
"are read from, where a calibration is kept, where a new source is "
|
|
42
|
+
"written. Defaults to the working directory, or the last one used."
|
|
43
|
+
),
|
|
44
|
+
)
|
|
45
|
+
parser.add_argument(
|
|
46
|
+
"--source",
|
|
47
|
+
action="append",
|
|
48
|
+
default=None,
|
|
49
|
+
dest="sources",
|
|
50
|
+
metavar="PATH",
|
|
51
|
+
help="Override where effect packages are looked for, repeatable",
|
|
52
|
+
)
|
|
53
|
+
parser.add_argument(
|
|
54
|
+
"--self-check",
|
|
55
|
+
action="store_true",
|
|
56
|
+
help=(
|
|
57
|
+
"Report what this build can reach and exit, without opening a window. "
|
|
58
|
+
"The way to find out whether a standalone build is complete."
|
|
59
|
+
),
|
|
60
|
+
)
|
|
61
|
+
parser.add_argument("--verbose", action="store_true")
|
|
62
|
+
return parser
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def self_check(project: Project) -> int:
|
|
66
|
+
"""Everything a frozen build can silently get wrong, asked out loud.
|
|
67
|
+
|
|
68
|
+
Two failures are invisible in a bundle: a device whose metadata was not
|
|
69
|
+
carried is simply not offered, and an effect that imports a standard library
|
|
70
|
+
module the bundle does not contain fails alone, at load time, on somebody
|
|
71
|
+
else's machine. Both are checked here by doing the thing rather than
|
|
72
|
+
inspecting the recipe — the outputs are discovered, the catalogue is loaded,
|
|
73
|
+
and every definition in it is rendered once.
|
|
74
|
+
"""
|
|
75
|
+
from lefx.sdk import RenderContext, initial_runtime_inputs, resolve_configuration
|
|
76
|
+
|
|
77
|
+
print(f"frozen build : {under_a_frozen_build()}")
|
|
78
|
+
for label, path in iter_paths(project):
|
|
79
|
+
marker = "ok " if Path(path).exists() else "-- "
|
|
80
|
+
print(f"{label:<13}: {marker}{path}")
|
|
81
|
+
|
|
82
|
+
outputs = available_outputs()
|
|
83
|
+
print(f"outputs : {', '.join(outputs)}")
|
|
84
|
+
if outputs == [NULL_OUTPUT]:
|
|
85
|
+
print(" ! no device package reachable — entry point metadata is missing")
|
|
86
|
+
|
|
87
|
+
session = StudioSession(project=project)
|
|
88
|
+
failures: list[str] = []
|
|
89
|
+
try:
|
|
90
|
+
session.open(NULL_OUTPUT)
|
|
91
|
+
effects = session.registry.list_effects()
|
|
92
|
+
print(f"catalogue : {len(effects)} Definitionen, "
|
|
93
|
+
f"{len(session.registry.list_presets())} Presets")
|
|
94
|
+
for entry in effects:
|
|
95
|
+
definition = entry.definition
|
|
96
|
+
try:
|
|
97
|
+
# Rendering is what pulls an effect's own imports in. A bundle
|
|
98
|
+
# missing one of them fails here rather than in front of a user.
|
|
99
|
+
entry.effect_class().render(
|
|
100
|
+
RenderContext(
|
|
101
|
+
now=1.0, started_at=0.0, led_count=12, definition=definition,
|
|
102
|
+
params=resolve_configuration(definition),
|
|
103
|
+
inputs=initial_runtime_inputs(definition),
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
except Exception as exc:
|
|
107
|
+
failures.append(f"{definition.id}: {exc}")
|
|
108
|
+
for source in session.service.library.sources():
|
|
109
|
+
if source["error"]:
|
|
110
|
+
failures.append(f"{source['path']}: {source['error']}")
|
|
111
|
+
finally:
|
|
112
|
+
session.close()
|
|
113
|
+
|
|
114
|
+
if failures:
|
|
115
|
+
print(f"\n{len(failures)} Problem(e):")
|
|
116
|
+
for line in failures:
|
|
117
|
+
print(f" - {line}")
|
|
118
|
+
return 1
|
|
119
|
+
print("rendering : alle Definitionen gerendert")
|
|
120
|
+
print("\nDieser Build ist vollständig.")
|
|
121
|
+
return 0
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def main(argv: list[str] | None = None) -> int:
|
|
125
|
+
args = build_parser().parse_args(argv)
|
|
126
|
+
logging.basicConfig(
|
|
127
|
+
level=logging.DEBUG if args.verbose else logging.INFO,
|
|
128
|
+
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
project = resolve(args.project)
|
|
132
|
+
logging.getLogger("lefx.effect_creation.studio").info("project: %s", project.root)
|
|
133
|
+
if args.self_check:
|
|
134
|
+
return self_check(project)
|
|
135
|
+
|
|
136
|
+
from PySide6.QtWidgets import QApplication
|
|
137
|
+
|
|
138
|
+
from .window import StudioWindow
|
|
139
|
+
if under_a_frozen_build() and not project.looks_like_a_project:
|
|
140
|
+
# A bundle started by double-clicking has no meaningful working
|
|
141
|
+
# directory, so guessing one would silently point the tool at the
|
|
142
|
+
# desktop. Say so instead; the window offers a picker.
|
|
143
|
+
logging.getLogger("lefx.effect_creation.studio").warning(
|
|
144
|
+
"no catalogue at %s — choose one with Projekt / Projekt öffnen", project.root
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
session = StudioSession(
|
|
148
|
+
led_count=args.led_count,
|
|
149
|
+
fps=args.fps,
|
|
150
|
+
search_paths=args.sources,
|
|
151
|
+
project=project,
|
|
152
|
+
)
|
|
153
|
+
remember(project)
|
|
154
|
+
|
|
155
|
+
application = QApplication(sys.argv[:1])
|
|
156
|
+
application.setApplicationName("LEFX Studio")
|
|
157
|
+
window = StudioWindow(session, initial_output=args.output)
|
|
158
|
+
window.setWindowTitle(f"LEFX Studio — {project.label}")
|
|
159
|
+
window.show()
|
|
160
|
+
try:
|
|
161
|
+
return int(application.exec())
|
|
162
|
+
finally:
|
|
163
|
+
# exec() returns on the last window closing, but a crash on the way out
|
|
164
|
+
# would otherwise leave a USB endpoint held by a process that is gone.
|
|
165
|
+
session.close()
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
if __name__ == "__main__": # pragma: no cover
|
|
169
|
+
raise SystemExit(main())
|