fastled 1.1.15__tar.gz → 1.1.17__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.
- {fastled-1.1.15 → fastled-1.1.17}/PKG-INFO +6 -2
- {fastled-1.1.15 → fastled-1.1.17}/README.md +2 -0
- {fastled-1.1.15 → fastled-1.1.17}/pyproject.toml +3 -1
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled/__init__.py +1 -1
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled/app.py +26 -15
- fastled-1.1.17/src/fastled/compile_server.py +158 -0
- fastled-1.1.17/src/fastled/docker_manager.py +515 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled/web_compile.py +3 -8
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled.egg-info/PKG-INFO +6 -2
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled.egg-info/requires.txt +2 -0
- {fastled-1.1.15 → fastled-1.1.17}/tests/test_compile_server.py +0 -1
- {fastled-1.1.15 → fastled-1.1.17}/tests/test_embedded_data.py +0 -1
- fastled-1.1.15/src/fastled/compile_server.py +0 -221
- fastled-1.1.15/src/fastled/docker_manager.py +0 -261
- {fastled-1.1.15 → fastled-1.1.17}/.aiderignore +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/.github/workflows/build_multi_docker_image.yml +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/.github/workflows/lint.yml +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/.github/workflows/test_macos.yml +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/.github/workflows/test_ubuntu.yml +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/.github/workflows/test_win.yml +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/.gitignore +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/.pylintrc +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/.vscode/launch.json +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/.vscode/settings.json +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/.vscode/tasks.json +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/LICENSE +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/MANIFEST.in +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/clean +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/docs/fastled.js +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/docs/fastled.wasm +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/docs/index.css +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/docs/index.html +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/docs/index.js +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Blink/Blink.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Chromancer/Chromancer.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Chromancer/detail.h +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Chromancer/gary_woos_wled_port/gary_woos_wled_ledmap.h +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Chromancer/gary_woos_wled_port/presets.json +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Chromancer/gary_woos_wled_port/presets.min.json +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Chromancer/gen.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Chromancer/mapping.h +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Chromancer/net.h +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Chromancer/output.json +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Chromancer/ripple.h +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Chromancer/screenmap.json.h +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/ColorPalette/ColorPalette.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/ColorTemperature/ColorTemperature.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Cylon/Cylon.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/DemoReel100/DemoReel100.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Esp32Rmt51/Esp32Rmt51.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/EspI2SDemo/EspI2SDemo.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Fire2012/Fire2012.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Fire2012WithPalette/Fire2012WithPalette.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/FirstLight/FirstLight.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/FxEngine/FxEngine.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Noise/Noise.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/NoisePlayground/NoisePlayground.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/NoisePlusPalette/NoisePlusPalette.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/OctoWS2811/OctoWS2811.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Pacifica/Pacifica.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Pride2015/Pride2015.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/SdCard/SdCard.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/SdCard/screenmap.json.h +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/TwinkleFox/TwinkleFox.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Video/Gfx2Video/Gfx2Video.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/WasmScreenCoords/WasmScreenCoords.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/Water/Water.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/XYMatrix/XYMatrix.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/examples/wasm/wasm.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/install +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/lint +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/requirements.testing.txt +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/setup.cfg +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/setup.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled/assets/example.txt +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled/build_mode.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled/cli.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled/filewatcher.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled/keyboard.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled/open_browser.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled/paths.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled/sketch.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled/util.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled.egg-info/SOURCES.txt +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled.egg-info/dependency_links.txt +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled.egg-info/entry_points.txt +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/src/fastled.egg-info/top_level.txt +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/test +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/tests/test_bad_ino.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/tests/test_cli.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/tests/test_filechanger.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/tests/test_ino/bad/bad.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/tests/test_ino/embedded/data/bigdata.dat +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/tests/test_ino/embedded/wasm.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/tests/test_ino/wasm/wasm.ino +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/tests/test_server_and_client_seperatly.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/tests/test_webcompile.py +0 -0
- {fastled-1.1.15 → fastled-1.1.17}/upload_package.sh +0 -0
@@ -1,13 +1,13 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: fastled
|
3
|
-
Version: 1.1.
|
3
|
+
Version: 1.1.17
|
4
4
|
Summary: FastLED Wasm Compiler
|
5
5
|
Home-page: https://github.com/zackees/fastled-wasm
|
6
6
|
Maintainer: Zachary Vorhies
|
7
7
|
License: BSD 3-Clause License
|
8
8
|
Keywords: template-python-cmd
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
10
|
-
Requires-Python: >=3.
|
10
|
+
Requires-Python: >=3.9
|
11
11
|
Description-Content-Type: text/markdown
|
12
12
|
License-File: LICENSE
|
13
13
|
Requires-Dist: docker
|
@@ -16,6 +16,8 @@ Requires-Dist: watchdog
|
|
16
16
|
Requires-Dist: livereload
|
17
17
|
Requires-Dist: download
|
18
18
|
Requires-Dist: filelock
|
19
|
+
Requires-Dist: disklru>=2.0.1
|
20
|
+
Requires-Dist: appdirs
|
19
21
|
|
20
22
|
# FastLED Wasm compiler
|
21
23
|
|
@@ -159,6 +161,8 @@ A: A big chunk of space is being used by unnecessary javascript `emscripten` is
|
|
159
161
|
|
160
162
|
# Revisions
|
161
163
|
|
164
|
+
* 1.1.17 - Added `--update` and `--no-auto-update` to control whether the compiler in docker mode will try to update.
|
165
|
+
* 1.1.16 - Rewrote docker logic to use container suspension and resumption. Much much faster.
|
162
166
|
* 1.1.15 - Fixed logic for considering ipv6 addresses. Auto selection of ipv6 is now restored.
|
163
167
|
* 1.1.14 - Fixes for regression in using --server and --localhost as two instances, this is now under test.
|
164
168
|
* 1.1.13 - Disable the use of ipv6. It produces random timeouts on the onrender server we are using for the web compiler.
|
@@ -140,6 +140,8 @@ A: A big chunk of space is being used by unnecessary javascript `emscripten` is
|
|
140
140
|
|
141
141
|
# Revisions
|
142
142
|
|
143
|
+
* 1.1.17 - Added `--update` and `--no-auto-update` to control whether the compiler in docker mode will try to update.
|
144
|
+
* 1.1.16 - Rewrote docker logic to use container suspension and resumption. Much much faster.
|
143
145
|
* 1.1.15 - Fixed logic for considering ipv6 addresses. Auto selection of ipv6 is now restored.
|
144
146
|
* 1.1.14 - Fixes for regression in using --server and --localhost as two instances, this is now under test.
|
145
147
|
* 1.1.13 - Disable the use of ipv6. It produces random timeouts on the onrender server we are using for the web compiler.
|
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
|
|
6
6
|
name = "fastled"
|
7
7
|
readme = "README.md"
|
8
8
|
description = "FastLED Wasm Compiler"
|
9
|
-
requires-python = ">=3.
|
9
|
+
requires-python = ">=3.9"
|
10
10
|
keywords = ["template-python-cmd"]
|
11
11
|
license = { text = "BSD 3-Clause License" }
|
12
12
|
classifiers = ["Programming Language :: Python :: 3"]
|
@@ -17,6 +17,8 @@ dependencies = [
|
|
17
17
|
"livereload",
|
18
18
|
"download",
|
19
19
|
"filelock",
|
20
|
+
"disklru>=2.0.1",
|
21
|
+
"appdirs",
|
20
22
|
]
|
21
23
|
|
22
24
|
dynamic = ["version"]
|
@@ -44,9 +44,6 @@ class CompiledResult:
|
|
44
44
|
hash_value: str | None
|
45
45
|
|
46
46
|
|
47
|
-
DOCKER = DockerManager(container_name=CONTAINER_NAME)
|
48
|
-
|
49
|
-
|
50
47
|
def parse_args() -> argparse.Namespace:
|
51
48
|
"""Parse command-line arguments."""
|
52
49
|
parser = argparse.ArgumentParser(description=f"FastLED WASM Compiler {__version__}")
|
@@ -107,16 +104,32 @@ def parse_args() -> argparse.Namespace:
|
|
107
104
|
action="store_true",
|
108
105
|
help="Run the server in the current directory, volume mapping fastled if we are in the repo",
|
109
106
|
)
|
110
|
-
|
111
|
-
build_mode.add_argument(
|
107
|
+
parser.add_argument(
|
112
108
|
"--force-compile",
|
113
109
|
action="store_true",
|
114
110
|
help="Skips the test to see if the current directory is a valid FastLED sketch directory",
|
115
111
|
)
|
112
|
+
parser.add_argument(
|
113
|
+
"--no-auto-updates",
|
114
|
+
action="store_true",
|
115
|
+
help="Disable automatic updates of the wasm compiler image when using docker.",
|
116
|
+
)
|
117
|
+
parser.add_argument(
|
118
|
+
"--update",
|
119
|
+
action="store_true",
|
120
|
+
help="Update the wasm compiler (if necessary) before running",
|
121
|
+
)
|
116
122
|
|
117
123
|
cwd_is_fastled = looks_like_fastled_repo(Path(os.getcwd()))
|
118
124
|
|
119
125
|
args = parser.parse_args()
|
126
|
+
if args.update:
|
127
|
+
args.auto_update = True
|
128
|
+
elif args.no_auto_updates:
|
129
|
+
args.auto_update = False
|
130
|
+
else:
|
131
|
+
args.auto_update = None
|
132
|
+
|
120
133
|
if not cwd_is_fastled and not args.localhost and not args.web and not args.server:
|
121
134
|
print(f"Using web compiler at {DEFAULT_URL}")
|
122
135
|
args.web = DEFAULT_URL
|
@@ -202,8 +215,8 @@ def run_web_compiler(
|
|
202
215
|
|
203
216
|
|
204
217
|
def _try_start_server_or_get_url(args: argparse.Namespace) -> str | CompileServer:
|
218
|
+
auto_update = args.auto_update
|
205
219
|
is_local_host = "localhost" in args.web or "127.0.0.1" in args.web or args.localhost
|
206
|
-
|
207
220
|
# test to see if there is already a local host server
|
208
221
|
local_host_needs_server = False
|
209
222
|
if is_local_host:
|
@@ -228,7 +241,7 @@ def _try_start_server_or_get_url(args: argparse.Namespace) -> str | CompileServe
|
|
228
241
|
else:
|
229
242
|
try:
|
230
243
|
print("No local server found, starting one...")
|
231
|
-
compile_server = CompileServer()
|
244
|
+
compile_server = CompileServer(auto_updates=auto_update)
|
232
245
|
print("Waiting for the local compiler to start...")
|
233
246
|
if not compile_server.wait_for_startup():
|
234
247
|
print("Failed to start local compiler.")
|
@@ -252,7 +265,7 @@ def run_client(args: argparse.Namespace) -> int:
|
|
252
265
|
return 1
|
253
266
|
|
254
267
|
# If not explicitly using web compiler, check Docker installation
|
255
|
-
if not args.web and not
|
268
|
+
if not args.web and not DockerManager.is_docker_installed():
|
256
269
|
print(
|
257
270
|
"\nDocker is not installed on this system - switching to web compiler instead."
|
258
271
|
)
|
@@ -304,9 +317,7 @@ def run_client(args: argparse.Namespace) -> int:
|
|
304
317
|
if open_web_browser:
|
305
318
|
browser_proc = open_browser_thread(Path(args.directory) / "fastled_js")
|
306
319
|
else:
|
307
|
-
print(
|
308
|
-
"\nCompilation successful. Run without --just-compile to open in browser and watch for changes."
|
309
|
-
)
|
320
|
+
print("\nCompilation successful.")
|
310
321
|
if compile_server:
|
311
322
|
print("Shutting down compile server...")
|
312
323
|
compile_server.stop()
|
@@ -402,7 +413,8 @@ def run_client(args: argparse.Namespace) -> int:
|
|
402
413
|
|
403
414
|
def run_server(args: argparse.Namespace) -> int:
|
404
415
|
interactive = args.interactive
|
405
|
-
|
416
|
+
auto_update = args.auto_update
|
417
|
+
compile_server = CompileServer(interactive=interactive, auto_updates=auto_update)
|
406
418
|
if not interactive:
|
407
419
|
print(f"Server started at {compile_server.url()}")
|
408
420
|
compile_server.wait_for_startup()
|
@@ -432,9 +444,8 @@ def main() -> int:
|
|
432
444
|
|
433
445
|
if __name__ == "__main__":
|
434
446
|
try:
|
435
|
-
|
436
|
-
sys.argv.append("
|
437
|
-
sys.argv.append("--localhost")
|
447
|
+
os.chdir("../fastled")
|
448
|
+
sys.argv.append("--server")
|
438
449
|
sys.exit(main())
|
439
450
|
except KeyboardInterrupt:
|
440
451
|
print("\nExiting from main...")
|
@@ -0,0 +1,158 @@
|
|
1
|
+
import subprocess
|
2
|
+
import time
|
3
|
+
from datetime import datetime, timezone
|
4
|
+
from pathlib import Path
|
5
|
+
|
6
|
+
import httpx
|
7
|
+
|
8
|
+
from fastled.docker_manager import DISK_CACHE, DockerManager, RunningContainer
|
9
|
+
from fastled.sketch import looks_like_fastled_repo
|
10
|
+
|
11
|
+
_IMAGE_NAME = "niteris/fastled-wasm"
|
12
|
+
_DEFAULT_CONTAINER_NAME = "fastled-wasm-compiler"
|
13
|
+
|
14
|
+
SERVER_PORT = 9021
|
15
|
+
|
16
|
+
SERVER_OPTIONS = ["--allow-shutdown", "--no-auto-update"]
|
17
|
+
|
18
|
+
|
19
|
+
class CompileServer:
|
20
|
+
def __init__(
|
21
|
+
self,
|
22
|
+
container_name=_DEFAULT_CONTAINER_NAME,
|
23
|
+
interactive: bool = False,
|
24
|
+
auto_updates: bool | None = None,
|
25
|
+
) -> None:
|
26
|
+
|
27
|
+
cwd = Path(".").resolve()
|
28
|
+
fastled_src_dir: Path | None = None
|
29
|
+
if looks_like_fastled_repo(cwd):
|
30
|
+
print(
|
31
|
+
"Looks like a FastLED repo, using it as the source directory and mapping it into the server."
|
32
|
+
)
|
33
|
+
fastled_src_dir = cwd / "src"
|
34
|
+
|
35
|
+
self.container_name = container_name
|
36
|
+
self.docker = DockerManager()
|
37
|
+
self.fastled_src_dir: Path | None = fastled_src_dir
|
38
|
+
self.interactive = interactive
|
39
|
+
self.running_container: RunningContainer | None = None
|
40
|
+
self.auto_updates = auto_updates
|
41
|
+
self._port = self._start()
|
42
|
+
# fancy print
|
43
|
+
if not interactive:
|
44
|
+
msg = f"# FastLED Compile Server started at {self.url()} #"
|
45
|
+
print("\n" + "#" * len(msg))
|
46
|
+
print(msg)
|
47
|
+
print("#" * len(msg) + "\n")
|
48
|
+
|
49
|
+
@property
|
50
|
+
def running(self) -> bool:
|
51
|
+
if not self._port:
|
52
|
+
return False
|
53
|
+
if not DockerManager.is_docker_installed():
|
54
|
+
return False
|
55
|
+
if not DockerManager.is_running():
|
56
|
+
return False
|
57
|
+
return self.docker.is_container_running(self.container_name)
|
58
|
+
|
59
|
+
def using_fastled_src_dir_volume(self) -> bool:
|
60
|
+
return self.fastled_src_dir is not None
|
61
|
+
|
62
|
+
def port(self) -> int:
|
63
|
+
return self._port
|
64
|
+
|
65
|
+
def url(self) -> str:
|
66
|
+
return f"http://localhost:{self._port}"
|
67
|
+
|
68
|
+
def wait_for_startup(self, timeout: int = 100) -> bool:
|
69
|
+
"""Wait for the server to start up."""
|
70
|
+
start_time = time.time()
|
71
|
+
while time.time() - start_time < timeout:
|
72
|
+
# ping the server to see if it's up
|
73
|
+
if not self._port:
|
74
|
+
return False
|
75
|
+
# use httpx to ping the server
|
76
|
+
# if successful, return True
|
77
|
+
try:
|
78
|
+
response = httpx.get(
|
79
|
+
f"http://localhost:{self._port}", follow_redirects=True
|
80
|
+
)
|
81
|
+
if response.status_code < 400:
|
82
|
+
return True
|
83
|
+
except KeyboardInterrupt:
|
84
|
+
raise
|
85
|
+
except Exception:
|
86
|
+
pass
|
87
|
+
time.sleep(0.1)
|
88
|
+
if not self.docker.is_container_running(self.container_name):
|
89
|
+
return False
|
90
|
+
return False
|
91
|
+
|
92
|
+
def _start(self) -> int:
|
93
|
+
print("Compiling server starting")
|
94
|
+
|
95
|
+
# Ensure Docker is running
|
96
|
+
if not self.docker.is_running():
|
97
|
+
if not self.docker.start():
|
98
|
+
print("Docker could not be started. Exiting.")
|
99
|
+
raise RuntimeError("Docker could not be started. Exiting.")
|
100
|
+
now = datetime.now(timezone.utc)
|
101
|
+
now_str = now.strftime("%Y-%m-%d %H %Z")
|
102
|
+
|
103
|
+
upgrade = False
|
104
|
+
if self.auto_updates is None:
|
105
|
+
prev_date_str = DISK_CACHE.get("last-update")
|
106
|
+
if prev_date_str != now_str:
|
107
|
+
print("One hour has passed, checking docker for updates")
|
108
|
+
upgrade = True
|
109
|
+
else:
|
110
|
+
upgrade = self.auto_updates
|
111
|
+
self.docker.validate_or_download_image(
|
112
|
+
image_name=_IMAGE_NAME, tag="main", upgrade=upgrade
|
113
|
+
)
|
114
|
+
DISK_CACHE.put("last-update", now_str)
|
115
|
+
|
116
|
+
print("Docker image now validated")
|
117
|
+
port = SERVER_PORT
|
118
|
+
if self.interactive:
|
119
|
+
server_command = ["/bin/bash"]
|
120
|
+
else:
|
121
|
+
server_command = ["python", "/js/run.py", "server"] + SERVER_OPTIONS
|
122
|
+
server_cmd_str = subprocess.list2cmdline(server_command)
|
123
|
+
print(f"Started Docker container with command: {server_cmd_str}")
|
124
|
+
ports = {80: port}
|
125
|
+
volumes = None
|
126
|
+
if self.fastled_src_dir:
|
127
|
+
print(
|
128
|
+
f"Mounting FastLED source directory {self.fastled_src_dir} into container /host/fastled/src"
|
129
|
+
)
|
130
|
+
volumes = {
|
131
|
+
str(self.fastled_src_dir): {"bind": "/host/fastled/src", "mode": "ro"}
|
132
|
+
}
|
133
|
+
|
134
|
+
cmd_str = subprocess.list2cmdline(server_command)
|
135
|
+
|
136
|
+
self.docker.run_container(
|
137
|
+
image_name=_IMAGE_NAME,
|
138
|
+
tag="main",
|
139
|
+
container_name=self.container_name,
|
140
|
+
command=cmd_str,
|
141
|
+
ports=ports,
|
142
|
+
volumes=volumes,
|
143
|
+
)
|
144
|
+
self.running_container = self.docker.attach_and_run(self.container_name)
|
145
|
+
assert self.running_container is not None, "Container should be running"
|
146
|
+
|
147
|
+
print("Compile server starting")
|
148
|
+
return port
|
149
|
+
|
150
|
+
def proceess_running(self) -> bool:
|
151
|
+
return self.docker.is_container_running(self.container_name)
|
152
|
+
|
153
|
+
def stop(self) -> None:
|
154
|
+
# print(f"Stopping server on port {self._port}")
|
155
|
+
if self.running_container:
|
156
|
+
self.running_container.stop()
|
157
|
+
self.docker.suspend_container(self.container_name)
|
158
|
+
print("Compile server stopped")
|