fastled 1.2.14__tar.gz → 1.2.16__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.
Files changed (84) hide show
  1. {fastled-1.2.14 → fastled-1.2.16}/PKG-INFO +5 -2
  2. {fastled-1.2.14 → fastled-1.2.16}/README.md +3 -0
  3. {fastled-1.2.14 → fastled-1.2.16}/pyproject.toml +1 -1
  4. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/__init__.py +5 -4
  5. fastled-1.2.16/src/fastled/open_browser.py +63 -0
  6. fastled-1.2.16/src/fastled/open_browser2.py +114 -0
  7. {fastled-1.2.14 → fastled-1.2.16}/src/fastled.egg-info/PKG-INFO +5 -2
  8. {fastled-1.2.14 → fastled-1.2.16}/src/fastled.egg-info/SOURCES.txt +1 -0
  9. {fastled-1.2.14 → fastled-1.2.16}/src/fastled.egg-info/requires.txt +1 -1
  10. {fastled-1.2.14 → fastled-1.2.16}/tests/test_http_server.py +0 -7
  11. fastled-1.2.14/src/fastled/open_browser.py +0 -93
  12. {fastled-1.2.14 → fastled-1.2.16}/.aiderignore +0 -0
  13. {fastled-1.2.14 → fastled-1.2.16}/.github/workflows/build_multi_docker_image.yml +0 -0
  14. {fastled-1.2.14 → fastled-1.2.16}/.github/workflows/build_webpage.yml +0 -0
  15. {fastled-1.2.14 → fastled-1.2.16}/.github/workflows/lint.yml +0 -0
  16. {fastled-1.2.14 → fastled-1.2.16}/.github/workflows/publish_release.yml +0 -0
  17. {fastled-1.2.14 → fastled-1.2.16}/.github/workflows/test_build_exe.yml +0 -0
  18. {fastled-1.2.14 → fastled-1.2.16}/.github/workflows/test_macos.yml +0 -0
  19. {fastled-1.2.14 → fastled-1.2.16}/.github/workflows/test_ubuntu.yml +0 -0
  20. {fastled-1.2.14 → fastled-1.2.16}/.github/workflows/test_win.yml +0 -0
  21. {fastled-1.2.14 → fastled-1.2.16}/.gitignore +0 -0
  22. {fastled-1.2.14 → fastled-1.2.16}/.pylintrc +0 -0
  23. {fastled-1.2.14 → fastled-1.2.16}/.vscode/launch.json +0 -0
  24. {fastled-1.2.14 → fastled-1.2.16}/.vscode/settings.json +0 -0
  25. {fastled-1.2.14 → fastled-1.2.16}/.vscode/tasks.json +0 -0
  26. {fastled-1.2.14 → fastled-1.2.16}/LICENSE +0 -0
  27. {fastled-1.2.14 → fastled-1.2.16}/MANIFEST.in +0 -0
  28. {fastled-1.2.14 → fastled-1.2.16}/RELEASE.md +0 -0
  29. {fastled-1.2.14 → fastled-1.2.16}/TODO.md +0 -0
  30. {fastled-1.2.14 → fastled-1.2.16}/build_exe.py +0 -0
  31. {fastled-1.2.14 → fastled-1.2.16}/build_site.py +0 -0
  32. {fastled-1.2.14 → fastled-1.2.16}/clean +0 -0
  33. {fastled-1.2.14 → fastled-1.2.16}/install +0 -0
  34. {fastled-1.2.14 → fastled-1.2.16}/lint +0 -0
  35. {fastled-1.2.14 → fastled-1.2.16}/requirements.testing.txt +0 -0
  36. {fastled-1.2.14 → fastled-1.2.16}/setup.cfg +0 -0
  37. {fastled-1.2.14 → fastled-1.2.16}/setup.py +0 -0
  38. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/app.py +0 -0
  39. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/assets/example.txt +0 -0
  40. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/cli.py +0 -0
  41. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/client_server.py +0 -0
  42. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/compile_server.py +0 -0
  43. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/compile_server_impl.py +0 -0
  44. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/docker_manager.py +0 -0
  45. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/filewatcher.py +0 -0
  46. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/keyboard.py +0 -0
  47. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/live_client.py +0 -0
  48. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/parse_args.py +0 -0
  49. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/paths.py +0 -0
  50. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/project_init.py +0 -0
  51. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/select_sketch_directory.py +0 -0
  52. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/settings.py +0 -0
  53. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/site/build.py +0 -0
  54. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/sketch.py +0 -0
  55. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/spinner.py +0 -0
  56. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/string_diff.py +0 -0
  57. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/test/can_run_local_docker_tests.py +0 -0
  58. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/test/examples.py +0 -0
  59. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/types.py +0 -0
  60. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/util.py +0 -0
  61. {fastled-1.2.14 → fastled-1.2.16}/src/fastled/web_compile.py +0 -0
  62. {fastled-1.2.14 → fastled-1.2.16}/src/fastled.egg-info/dependency_links.txt +0 -0
  63. {fastled-1.2.14 → fastled-1.2.16}/src/fastled.egg-info/entry_points.txt +0 -0
  64. {fastled-1.2.14 → fastled-1.2.16}/src/fastled.egg-info/top_level.txt +0 -0
  65. {fastled-1.2.14 → fastled-1.2.16}/test +0 -0
  66. {fastled-1.2.14 → fastled-1.2.16}/tests/html/index.html +0 -0
  67. {fastled-1.2.14 → fastled-1.2.16}/tests/test_api.py +0 -0
  68. {fastled-1.2.14 → fastled-1.2.16}/tests/test_bad_ino.py +0 -0
  69. {fastled-1.2.14 → fastled-1.2.16}/tests/test_build.py +0 -0
  70. {fastled-1.2.14 → fastled-1.2.16}/tests/test_build_examples.py +0 -0
  71. {fastled-1.2.14 → fastled-1.2.16}/tests/test_cli.py +0 -0
  72. {fastled-1.2.14 → fastled-1.2.16}/tests/test_compile_server.py +0 -0
  73. {fastled-1.2.14 → fastled-1.2.16}/tests/test_docker_linux_on_windows.py +0 -0
  74. {fastled-1.2.14 → fastled-1.2.16}/tests/test_embedded_data.py +0 -0
  75. {fastled-1.2.14 → fastled-1.2.16}/tests/test_examples.py +0 -0
  76. {fastled-1.2.14 → fastled-1.2.16}/tests/test_filechanger.py +0 -0
  77. {fastled-1.2.14 → fastled-1.2.16}/tests/test_ino/bad/bad.ino +0 -0
  78. {fastled-1.2.14 → fastled-1.2.16}/tests/test_ino/embedded/data/bigdata.dat +0 -0
  79. {fastled-1.2.14 → fastled-1.2.16}/tests/test_ino/embedded/wasm.ino +0 -0
  80. {fastled-1.2.14 → fastled-1.2.16}/tests/test_ino/wasm/wasm.ino +0 -0
  81. {fastled-1.2.14 → fastled-1.2.16}/tests/test_project_init.py +0 -0
  82. {fastled-1.2.14 → fastled-1.2.16}/tests/test_server_and_client_seperatly.py +0 -0
  83. {fastled-1.2.14 → fastled-1.2.16}/tests/test_webcompile.py +0 -0
  84. {fastled-1.2.14 → fastled-1.2.16}/upload_package.sh +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastled
3
- Version: 1.2.14
3
+ Version: 1.2.16
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -19,7 +19,7 @@ Requires-Dist: disklru>=2.0.1
19
19
  Requires-Dist: appdirs>=1.4.4
20
20
  Requires-Dist: rapidfuzz>=3.10.1
21
21
  Requires-Dist: progress>=1.6
22
- Requires-Dist: static-npm>=1.0.6
22
+ Requires-Dist: Flask>=3.0.0
23
23
 
24
24
  # FastLED Wasm compiler
25
25
 
@@ -282,8 +282,11 @@ A: `delay()` will block `loop()` which blocks the main thread of the browser. Th
282
282
  Q: How can I get the compiled size of my FastLED sketch smaller?
283
283
  A: A big chunk of space is being used by unnecessary javascript `emscripten` bundling. The wasm_compiler_settings.py file in the FastLED repo can tweak this.
284
284
 
285
+
285
286
  # Revisions
286
287
 
288
+ * 1.2.16 - Force mime types in web browser as some users may not have it correct in their registry.
289
+ * 1.2.15 - Rewrote http server using flask. Reduced install size significantly.
287
290
  * 1.2.13 - More fixes for npm live-server, now uses `static-npm` to launch it.
288
291
  * 1.2.12 - Fixes for python npm for launching live-server
289
292
  * 1.2.10 - `fastled.Test` now allows you to spawn the http webserver on a folder with an index.html in it.
@@ -259,8 +259,11 @@ A: `delay()` will block `loop()` which blocks the main thread of the browser. Th
259
259
  Q: How can I get the compiled size of my FastLED sketch smaller?
260
260
  A: A big chunk of space is being used by unnecessary javascript `emscripten` bundling. The wasm_compiler_settings.py file in the FastLED repo can tweak this.
261
261
 
262
+
262
263
  # Revisions
263
264
 
265
+ * 1.2.16 - Force mime types in web browser as some users may not have it correct in their registry.
266
+ * 1.2.15 - Rewrote http server using flask. Reduced install size significantly.
264
267
  * 1.2.13 - More fixes for npm live-server, now uses `static-npm` to launch it.
265
268
  * 1.2.12 - Fixes for python npm for launching live-server
266
269
  * 1.2.10 - `fastled.Test` now allows you to spawn the http webserver on a folder with an index.html in it.
@@ -20,7 +20,7 @@ dependencies = [
20
20
  "appdirs>=1.4.4",
21
21
  "rapidfuzz>=3.10.1",
22
22
  "progress>=1.6",
23
- "static-npm>=1.0.6",
23
+ "Flask>=3.0.0",
24
24
  ]
25
25
 
26
26
  dynamic = ["version"]
@@ -3,6 +3,7 @@
3
3
  # context
4
4
  import subprocess
5
5
  from contextlib import contextmanager
6
+ from multiprocessing import Process
6
7
  from pathlib import Path
7
8
  from typing import Generator
8
9
 
@@ -14,7 +15,7 @@ from .types import BuildMode, CompileResult, CompileServerError
14
15
  # IMPORTANT! There's a bug in github which will REJECT any version update
15
16
  # that has any other change in the repo. Please bump the version as the
16
17
  # ONLY change in a commit, or else the pypi update and the release will fail.
17
- __version__ = "1.2.14"
18
+ __version__ = "1.2.16"
18
19
 
19
20
 
20
21
  class Api:
@@ -318,12 +319,12 @@ class Test:
318
319
  directory: Path | str = Path("."),
319
320
  port: int = 8000,
320
321
  open_browser: bool = True,
321
- ) -> subprocess.Popen:
322
- from fastled.open_browser import open_http_server
322
+ ) -> Process:
323
+ from fastled.open_browser import open_browser_process
323
324
 
324
325
  if isinstance(directory, str):
325
326
  directory = Path(directory)
326
- proc: subprocess.Popen = open_http_server(
327
+ proc: Process = open_browser_process(
327
328
  directory, port=port, open_browser=open_browser
328
329
  )
329
330
  return proc
@@ -0,0 +1,63 @@
1
+ import subprocess
2
+ import sys
3
+ from multiprocessing import Process
4
+ from pathlib import Path
5
+
6
+ DEFAULT_PORT = 8081
7
+
8
+ PYTHON_EXE = sys.executable
9
+
10
+
11
+ def open_http_server_subprocess(
12
+ fastled_js: Path, port: int, open_browser: bool
13
+ ) -> None:
14
+ """Start livereload server in the fastled_js directory and return the process"""
15
+
16
+ cmd = [
17
+ PYTHON_EXE,
18
+ "-m",
19
+ "fastled.open_browser2",
20
+ str(fastled_js),
21
+ "--port",
22
+ str(port),
23
+ ]
24
+ if not open_browser:
25
+ cmd.append("--no-browser")
26
+ # return subprocess.Popen(cmd) # type ignore
27
+ subprocess.run(cmd) # type ignore
28
+
29
+
30
+ def open_browser_process(
31
+ fastled_js: Path, port: int = DEFAULT_PORT, open_browser: bool = True
32
+ ) -> Process:
33
+ """Start livereload server in the fastled_js directory and return the process"""
34
+ out: Process = Process(
35
+ target=open_http_server_subprocess,
36
+ args=(fastled_js, port, open_browser),
37
+ daemon=True,
38
+ )
39
+ out.start()
40
+ return out
41
+
42
+
43
+ if __name__ == "__main__":
44
+ import argparse
45
+
46
+ parser = argparse.ArgumentParser(
47
+ description="Open a browser to the fastled_js directory"
48
+ )
49
+ parser.add_argument(
50
+ "fastled_js",
51
+ type=Path,
52
+ help="Path to the fastled_js directory",
53
+ )
54
+ parser.add_argument(
55
+ "--port",
56
+ type=int,
57
+ default=DEFAULT_PORT,
58
+ help=f"Port to run the server on (default: {DEFAULT_PORT})",
59
+ )
60
+ args = parser.parse_args()
61
+
62
+ proc = open_browser_process(args.fastled_js, args.port, open_browser=True)
63
+ proc.join()
@@ -0,0 +1,114 @@
1
+ import argparse
2
+ import socket
3
+ import time
4
+ from pathlib import Path
5
+ from threading import Thread
6
+
7
+
8
+ def _run_flask_server(fastled_js: Path, port: int) -> None:
9
+ """Run Flask server with live reload in a subprocess"""
10
+ try:
11
+ from flask import Flask, send_from_directory
12
+
13
+ app = Flask(__name__)
14
+
15
+ @app.route("/")
16
+ def serve_index():
17
+ return send_from_directory(fastled_js, "index.html")
18
+
19
+ @app.route("/<path:path>")
20
+ def serve_files(path):
21
+ response = send_from_directory(fastled_js, path)
22
+ # Some servers don't set the Content-Type header for a bunch of files.
23
+ if path.endswith(".js"):
24
+ response.headers["Content-Type"] = "application/javascript"
25
+ if path.endswith(".css"):
26
+ response.headers["Content-Type"] = "text/css"
27
+ if path.endswith(".wasm"):
28
+ response.headers["Content-Type"] = "application/wasm"
29
+ if path.endswith(".json"):
30
+ response.headers["Content-Type"] = "application/json"
31
+ if path.endswith(".png"):
32
+ response.headers["Content-Type"] = "image/png"
33
+ if path.endswith(".jpg"):
34
+ response.headers["Content-Type"] = "image/jpeg"
35
+ if path.endswith(".jpeg"):
36
+ response.headers["Content-Type"] = "image/jpeg"
37
+ if path.endswith(".gif"):
38
+ response.headers["Content-Type"] = "image/gif"
39
+ if path.endswith(".svg"):
40
+ response.headers["Content-Type"] = "image/svg+xml"
41
+ if path.endswith(".ico"):
42
+ response.headers["Content-Type"] = "image/x-icon"
43
+ if path.endswith(".html"):
44
+ response.headers["Content-Type"] = "text/html"
45
+ return response
46
+
47
+ app.run(port=port, debug=True)
48
+ except Exception as e:
49
+ print(f"Failed to run Flask server: {e}")
50
+ import _thread
51
+
52
+ _thread.interrupt_main()
53
+
54
+
55
+ def wait_for_server(port: int, timeout: int = 10) -> None:
56
+ """Wait for the server to start."""
57
+ future_time = time.time() + timeout
58
+ while future_time > time.time():
59
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
60
+ if sock.connect_ex(("localhost", port)) == 0:
61
+ return
62
+ raise TimeoutError("Could not connect to server")
63
+
64
+
65
+ def wait_for_server_then_launch_browser(port: int) -> None:
66
+ """Wait for the server to start, then launch the browser."""
67
+ wait_for_server(port)
68
+ import webbrowser
69
+
70
+ webbrowser.open(f"http://localhost:{port}")
71
+
72
+
73
+ def run(path: Path, port: int, open_browser: bool) -> None:
74
+ """Run the Flask server."""
75
+ if open_browser:
76
+ browser_thread = Thread(
77
+ target=wait_for_server_then_launch_browser, args=(port,), daemon=True
78
+ )
79
+ browser_thread.start()
80
+ _run_flask_server(path, port)
81
+
82
+
83
+ def parse_args() -> argparse.Namespace:
84
+ """Parse the command line arguments."""
85
+ parser = argparse.ArgumentParser(
86
+ description="Open a browser to the fastled_js directory"
87
+ )
88
+ parser.add_argument(
89
+ "fastled_js", type=Path, help="Path to the fastled_js directory"
90
+ )
91
+ parser.add_argument(
92
+ "--port",
93
+ "-p",
94
+ type=int,
95
+ required=True,
96
+ help="Port to run the server on (default: %(default)s)",
97
+ )
98
+ parser.add_argument(
99
+ "--no-browser",
100
+ action="store_true",
101
+ help="Do not open the browser",
102
+ )
103
+ return parser.parse_args()
104
+
105
+
106
+ def main() -> None:
107
+ """Main function."""
108
+ args = parse_args()
109
+ open_browser = not args.no_browser
110
+ run(args.fastled_js, args.port, open_browser)
111
+
112
+
113
+ if __name__ == "__main__":
114
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastled
3
- Version: 1.2.14
3
+ Version: 1.2.16
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -19,7 +19,7 @@ Requires-Dist: disklru>=2.0.1
19
19
  Requires-Dist: appdirs>=1.4.4
20
20
  Requires-Dist: rapidfuzz>=3.10.1
21
21
  Requires-Dist: progress>=1.6
22
- Requires-Dist: static-npm>=1.0.6
22
+ Requires-Dist: Flask>=3.0.0
23
23
 
24
24
  # FastLED Wasm compiler
25
25
 
@@ -282,8 +282,11 @@ A: `delay()` will block `loop()` which blocks the main thread of the browser. Th
282
282
  Q: How can I get the compiled size of my FastLED sketch smaller?
283
283
  A: A big chunk of space is being used by unnecessary javascript `emscripten` bundling. The wasm_compiler_settings.py file in the FastLED repo can tweak this.
284
284
 
285
+
285
286
  # Revisions
286
287
 
288
+ * 1.2.16 - Force mime types in web browser as some users may not have it correct in their registry.
289
+ * 1.2.15 - Rewrote http server using flask. Reduced install size significantly.
287
290
  * 1.2.13 - More fixes for npm live-server, now uses `static-npm` to launch it.
288
291
  * 1.2.12 - Fixes for python npm for launching live-server
289
292
  * 1.2.10 - `fastled.Test` now allows you to spawn the http webserver on a folder with an index.html in it.
@@ -38,6 +38,7 @@ src/fastled/filewatcher.py
38
38
  src/fastled/keyboard.py
39
39
  src/fastled/live_client.py
40
40
  src/fastled/open_browser.py
41
+ src/fastled/open_browser2.py
41
42
  src/fastled/parse_args.py
42
43
  src/fastled/paths.py
43
44
  src/fastled/project_init.py
@@ -7,4 +7,4 @@ disklru>=2.0.1
7
7
  appdirs>=1.4.4
8
8
  rapidfuzz>=3.10.1
9
9
  progress>=1.6
10
- static-npm>=1.0.6
10
+ Flask>=3.0.0
@@ -16,12 +16,6 @@ TIMEOUT = 120
16
16
 
17
17
  assert INDEX_HTML.exists()
18
18
 
19
- # def override(url) -> None:
20
- # """Override the server url."""
21
- # assert isinstance(url, str) and "localhost" in url
22
-
23
- # client_server.TEST_BEFORE_COMPILE = override
24
-
25
19
 
26
20
  class HttpServerTester(unittest.TestCase):
27
21
  """Main tester class."""
@@ -42,7 +36,6 @@ class HttpServerTester(unittest.TestCase):
42
36
  response = httpx.get("http://localhost:8081", timeout=5)
43
37
  self.assertEqual(response.status_code, 200)
44
38
  proc.kill()
45
- proc.wait()
46
39
 
47
40
 
48
41
  if __name__ == "__main__":
@@ -1,93 +0,0 @@
1
- import shutil
2
- import socket
3
- import subprocess
4
- from multiprocessing import Process
5
- from pathlib import Path
6
-
7
- from static_npm import Npm, Npx
8
- from static_npm.paths import CACHE_DIR
9
- from static_npm.running_process import RunningProcess
10
-
11
- DEFAULT_PORT = 8081
12
-
13
-
14
- def open_http_server(
15
- fastled_js: Path, port: int | None = None, open_browser=True
16
- ) -> subprocess.Popen | RunningProcess:
17
- """Start livereload server in the fastled_js directory using API"""
18
- cmd_list: list[str]
19
- print(f"\nStarting livereload server in {fastled_js}")
20
-
21
- cmd_list = ["live-server"]
22
- if port is not None:
23
- cmd_list.extend([f"--port={port}"])
24
- if not open_browser:
25
- cmd_list.append("--no-browser")
26
-
27
- live_server_where = shutil.which("live-server")
28
- if live_server_where is None:
29
- print("live-server not found. Installing it with the embedded npm...")
30
- # cmd_list = [sys.executable, "-m", "nodejs.npm", "install", "-g", "live-server"]
31
- # npm.call("install -g live-server --force --legacy-peer-deps")
32
- tool_dir = CACHE_DIR / "live-server"
33
- tool_dir.mkdir(parents=True, exist_ok=True)
34
- npm = Npm()
35
- npx = Npx()
36
- npm.run(["install", "live-server", "--prefix", tool_dir])
37
- # npm.run(["install", "live-server", "--prefix", str(tool_dir)])
38
- cmd_str = subprocess.list2cmdline(
39
- ["npx"] + ["--prefix", str(tool_dir)] + cmd_list
40
- )
41
- print(f"Running: {cmd_str}")
42
- proc = npx.run(["--prefix", str(tool_dir)] + cmd_list, cwd=fastled_js)
43
- return proc # type ignore
44
- else:
45
- # npx.run("live-server", check=False)
46
- # subprocess.run(cmd_list)
47
- live_server_where = shutil.which("live-server")
48
- print(f"Using live-server from {live_server_where}")
49
- cmd_list = ["live-server"]
50
- if port is not None:
51
- cmd_list.extend([f"--port={port}"])
52
- if not open_browser:
53
- cmd_list.append("--no-browser")
54
- # subprocess.run(["cd", str(fastled_js), "&&"] + cmd_list)
55
- return subprocess.Popen(cmd_list, cwd=str(fastled_js), shell=True)
56
-
57
-
58
- def _open_browser_python(fastled_js: Path) -> None:
59
- """Start livereload server in the fastled_js directory using API"""
60
- proc = open_http_server(fastled_js)
61
- proc.wait()
62
-
63
-
64
- def _find_open_port(start_port: int) -> int:
65
- """Find an open port starting from start_port."""
66
- port = start_port
67
- while True:
68
- with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
69
- if sock.connect_ex(("localhost", port)) != 0:
70
- return port
71
- port += 1
72
-
73
-
74
- def _run_server(fastled_js: Path) -> None:
75
- """Function to run in separate process that starts the livereload server"""
76
-
77
- try:
78
- # Keep the process running
79
- _open_browser_python(fastled_js)
80
- except KeyboardInterrupt:
81
- print("\nShutting down livereload server...")
82
-
83
-
84
- def open_browser_process(fastled_js: Path) -> Process:
85
- """Start livereload server in the fastled_js directory and return the process"""
86
-
87
- process = Process(
88
- target=_run_server,
89
- args=(fastled_js,),
90
- daemon=True,
91
- )
92
- process.start()
93
- return process
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