fastled 1.3.11__py3-none-any.whl → 1.3.12__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.
fastled/__version__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # IMPORTANT! There's a bug in github which will REJECT any version update
2
2
  # that has any other change in the repo. Please bump the version as the
3
3
  # ONLY change in a commit, or else the pypi update and the release will fail.
4
- __version__ = "1.3.11"
4
+ __version__ = "1.3.12"
5
5
 
6
6
  __version_url_latest__ = "https://raw.githubusercontent.com/zackees/fastled-wasm/refs/heads/main/src/fastled/__version__.py"
fastled/app.py CHANGED
@@ -1,183 +1,177 @@
1
- """
2
- Uses the latest wasm compiler image to compile the FastLED sketch.
3
- """
4
-
5
- import os
6
- import sys
7
- import time
8
- from pathlib import Path
9
-
10
- from fastled.client_server import run_client_server
11
- from fastled.compile_server import CompileServer
12
- from fastled.filewatcher import file_watcher_set
13
- from fastled.parse_args import Args, parse_args
14
- from fastled.sketch import find_sketch_directories, looks_like_fastled_repo
15
-
16
- # from fastled.sketch import (
17
- # find_sketch_directories,
18
- # looks_like_fastled_repo,
19
- # looks_like_sketch_directory,
20
- # )
21
-
22
-
23
- def run_server(args: Args) -> int:
24
- interactive = args.interactive
25
- auto_update = args.auto_update
26
- mapped_dir = Path(args.directory).absolute() if args.directory else None
27
- if interactive and mapped_dir is None:
28
- print("Select a sketch when you enter interactive mode.")
29
- return 1
30
- compile_server = CompileServer(
31
- interactive=interactive,
32
- auto_updates=auto_update,
33
- mapped_dir=mapped_dir,
34
- auto_start=True,
35
- remove_previous=args.clear,
36
- )
37
-
38
- if not interactive:
39
- print(f"Server started at {compile_server.url()}")
40
- try:
41
- while True:
42
- if not compile_server.process_running():
43
- print("Server process is not running. Exiting...")
44
- return 1
45
- time.sleep(0.1)
46
- except KeyboardInterrupt:
47
- print("\nExiting from server...")
48
- return 1
49
- finally:
50
- compile_server.stop()
51
- return 0
52
-
53
-
54
- def main() -> int:
55
- from fastled import __version__
56
- from fastled.select_sketch_directory import select_sketch_directory
57
-
58
- args = parse_args()
59
- interactive: bool = args.interactive
60
- has_server = args.server
61
- update: bool = args.update
62
- build: bool = args.build
63
- just_compile: bool = args.just_compile
64
- # directory: Path | None = Path(args.directory).absolute() if args.directory else None
65
- directory: Path | None = Path(args.directory) if args.directory else None
66
- cwd_looks_like_fastled_repo = looks_like_fastled_repo()
67
-
68
- # now it is safe to print out the version
69
- print(f"FastLED version: {__version__}")
70
-
71
- # Resolve some of the last interactive arguments
72
- # 1. If interactive is set and the sketch directory is not given,
73
- # then prompt the user for a sketch directory.
74
- # 2. Tell the user they can use --server --interactive to
75
- # skip this prompt.
76
- if interactive and cwd_looks_like_fastled_repo and directory is None:
77
- answer = input(
78
- "No sketch directory selected, would you like to select one? (y/n): "
79
- )
80
- if answer.lower()[:1] == "y" or answer.lower() == "":
81
- sketch_list: list[Path] = find_sketch_directories()
82
- if sketch_list:
83
- maybe_dir: str | None = select_sketch_directory(
84
- sketch_list, cwd_looks_like_fastled_repo
85
- )
86
- if maybe_dir is not None:
87
- directory = Path(maybe_dir)
88
- if not directory.exists():
89
- print(
90
- f"Directory {directory} does not exist, entering interactive mode without project mapped in."
91
- )
92
- directory = None
93
-
94
- if update:
95
- # Force auto_update to ensure update check happens
96
- compile_server = CompileServer(interactive=False, auto_updates=True)
97
- compile_server.stop()
98
- print("Finished updating.")
99
- return 0
100
-
101
- if build:
102
- print("Building is disabled")
103
- build = False
104
-
105
- if interactive:
106
- # raise NotImplementedError("Building is not yet supported.")
107
- file_watcher_set(False)
108
- # project_root = Path(".").absolute()
109
- # print(f"Building Docker image at {project_root}")
110
- from fastled import Api
111
-
112
- server: CompileServer = CompileServer(
113
- interactive=interactive,
114
- auto_updates=False,
115
- mapped_dir=directory,
116
- auto_start=False,
117
- remove_previous=args.clear,
118
- )
119
-
120
- server.start(wait_for_startup=False)
121
-
122
- try:
123
- while server.process_running():
124
- # wait for ctrl-c
125
- time.sleep(0.1)
126
- except KeyboardInterrupt:
127
- print("\nExiting from server...")
128
- server.stop()
129
- return 0
130
-
131
- try:
132
- if interactive:
133
- server.stop()
134
- return 0
135
- print(f"Built Docker image: {server.name}")
136
- if not directory:
137
- if not directory:
138
- print("No directory specified")
139
- server.stop()
140
- return 0
141
-
142
- print("Running server")
143
-
144
- with Api.live_client(
145
- auto_updates=False,
146
- sketch_directory=directory,
147
- host=server,
148
- auto_start=True,
149
- keep_running=not just_compile,
150
- ) as _:
151
- while True:
152
- time.sleep(0.2) # wait for user to exit
153
- except KeyboardInterrupt:
154
- print("\nExiting from client...")
155
- server.stop()
156
- return 1
157
-
158
- if has_server:
159
- print("Running in server only mode.")
160
- return run_server(args)
161
- else:
162
- print("Running in client/server mode.")
163
- return run_client_server(args)
164
-
165
-
166
- if __name__ == "__main__":
167
- # Note that the entry point for the exe is in cli.py
168
- try:
169
- # sys.argv.append("-i")
170
- # sys.argv.append("-b")
171
- # sys.argv.append("examples/wasm")
172
- # sys.argv.append()
173
- import os
174
-
175
- os.chdir("../fastled")
176
- sys.argv.append("examples/FxWave2d")
177
- sys.exit(main())
178
- except KeyboardInterrupt:
179
- print("\nExiting from main...")
180
- sys.exit(1)
181
- except Exception as e:
182
- print(f"Error: {e}")
183
- sys.exit(1)
1
+ """
2
+ Uses the latest wasm compiler image to compile the FastLED sketch.
3
+ """
4
+
5
+ import os
6
+ import sys
7
+ import time
8
+ from pathlib import Path
9
+
10
+ from fastled.client_server import run_client_server
11
+ from fastled.compile_server import CompileServer
12
+ from fastled.filewatcher import file_watcher_set
13
+ from fastled.parse_args import Args, parse_args
14
+ from fastled.sketch import find_sketch_directories, looks_like_fastled_repo
15
+
16
+
17
+ def run_server(args: Args) -> int:
18
+ interactive = args.interactive
19
+ auto_update = args.auto_update
20
+ mapped_dir = Path(args.directory).absolute() if args.directory else None
21
+ if interactive and mapped_dir is None:
22
+ print("Select a sketch when you enter interactive mode.")
23
+ return 1
24
+ compile_server = CompileServer(
25
+ interactive=interactive,
26
+ auto_updates=auto_update,
27
+ mapped_dir=mapped_dir,
28
+ auto_start=True,
29
+ remove_previous=args.clear,
30
+ )
31
+
32
+ if not interactive:
33
+ print(f"Server started at {compile_server.url()}")
34
+ try:
35
+ while True:
36
+ if not compile_server.process_running():
37
+ print("Server process is not running. Exiting...")
38
+ return 1
39
+ time.sleep(0.1)
40
+ except KeyboardInterrupt:
41
+ print("\nExiting from server...")
42
+ return 1
43
+ finally:
44
+ compile_server.stop()
45
+ return 0
46
+
47
+
48
+ def main() -> int:
49
+ from fastled import __version__
50
+ from fastled.select_sketch_directory import select_sketch_directory
51
+
52
+ args = parse_args()
53
+ interactive: bool = args.interactive
54
+ has_server = args.server
55
+ update: bool = args.update
56
+ build: bool = args.build
57
+ just_compile: bool = args.just_compile
58
+ # directory: Path | None = Path(args.directory).absolute() if args.directory else None
59
+ directory: Path | None = Path(args.directory) if args.directory else None
60
+ cwd_looks_like_fastled_repo = looks_like_fastled_repo()
61
+
62
+ # now it is safe to print out the version
63
+ print(f"FastLED version: {__version__}")
64
+
65
+ # Resolve some of the last interactive arguments
66
+ # 1. If interactive is set and the sketch directory is not given,
67
+ # then prompt the user for a sketch directory.
68
+ # 2. Tell the user they can use --server --interactive to
69
+ # skip this prompt.
70
+ if interactive and cwd_looks_like_fastled_repo and directory is None:
71
+ answer = input(
72
+ "No sketch directory selected, would you like to select one? (y/n): "
73
+ )
74
+ if answer.lower()[:1] == "y" or answer.lower() == "":
75
+ sketch_list: list[Path] = find_sketch_directories()
76
+ if sketch_list:
77
+ maybe_dir: str | None = select_sketch_directory(
78
+ sketch_list, cwd_looks_like_fastled_repo
79
+ )
80
+ if maybe_dir is not None:
81
+ directory = Path(maybe_dir)
82
+ if not directory.exists():
83
+ print(
84
+ f"Directory {directory} does not exist, entering interactive mode without project mapped in."
85
+ )
86
+ directory = None
87
+
88
+ if update:
89
+ # Force auto_update to ensure update check happens
90
+ compile_server = CompileServer(interactive=False, auto_updates=True)
91
+ compile_server.stop()
92
+ print("Finished updating.")
93
+ return 0
94
+
95
+ if build:
96
+ print("Building is disabled")
97
+ build = False
98
+
99
+ if interactive:
100
+ # raise NotImplementedError("Building is not yet supported.")
101
+ file_watcher_set(False)
102
+ # project_root = Path(".").absolute()
103
+ # print(f"Building Docker image at {project_root}")
104
+ from fastled import Api
105
+
106
+ server: CompileServer = CompileServer(
107
+ interactive=interactive,
108
+ auto_updates=False,
109
+ mapped_dir=directory,
110
+ auto_start=False,
111
+ remove_previous=args.clear,
112
+ )
113
+
114
+ server.start(wait_for_startup=False)
115
+
116
+ try:
117
+ while server.process_running():
118
+ # wait for ctrl-c
119
+ time.sleep(0.1)
120
+ except KeyboardInterrupt:
121
+ print("\nExiting from server...")
122
+ server.stop()
123
+ return 0
124
+
125
+ try:
126
+ if interactive:
127
+ server.stop()
128
+ return 0
129
+ print(f"Built Docker image: {server.name}")
130
+ if not directory:
131
+ if not directory:
132
+ print("No directory specified")
133
+ server.stop()
134
+ return 0
135
+
136
+ print("Running server")
137
+
138
+ with Api.live_client(
139
+ auto_updates=False,
140
+ sketch_directory=directory,
141
+ host=server,
142
+ auto_start=True,
143
+ keep_running=not just_compile,
144
+ ) as _:
145
+ while True:
146
+ time.sleep(0.2) # wait for user to exit
147
+ except KeyboardInterrupt:
148
+ print("\nExiting from client...")
149
+ server.stop()
150
+ return 1
151
+
152
+ if has_server:
153
+ print("Running in server only mode.")
154
+ return run_server(args)
155
+ else:
156
+ print("Running in client/server mode.")
157
+ return run_client_server(args)
158
+
159
+
160
+ if __name__ == "__main__":
161
+ # Note that the entry point for the exe is in cli.py
162
+ try:
163
+ # sys.argv.append("-i")
164
+ # sys.argv.append("-b")
165
+ # sys.argv.append("examples/wasm")
166
+ # sys.argv.append()
167
+ import os
168
+
169
+ os.chdir("../fastled")
170
+ sys.argv.append("examples/FxWave2d")
171
+ sys.exit(main())
172
+ except KeyboardInterrupt:
173
+ print("\nExiting from main...")
174
+ sys.exit(1)
175
+ except Exception as e:
176
+ print(f"Error: {e}")
177
+ sys.exit(1)