fastled 1.1.30__py2.py3-none-any.whl → 1.1.32__py2.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/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """FastLED Wasm Compiler package."""
2
2
 
3
- __version__ = "1.1.30"
3
+ __version__ = "1.1.32"
fastled/app.py CHANGED
@@ -1,217 +1,64 @@
1
- """
2
- Uses the latest wasm compiler image to compile the FastLED sketch.
3
- """
4
-
5
- import argparse
6
- import os
7
- import sys
8
- import time
9
- from pathlib import Path
10
-
11
- from fastled import __version__
12
- from fastled.client_server import run_client_server
13
- from fastled.compile_server import CompileServer
14
- from fastled.env import DEFAULT_URL
15
- from fastled.project_init import project_init
16
- from fastled.select_sketch_directory import select_sketch_directory
17
- from fastled.sketch import (
18
- find_sketch_directories,
19
- looks_like_fastled_repo,
20
- looks_like_sketch_directory,
21
- )
22
-
23
-
24
- def parse_args() -> argparse.Namespace:
25
- """Parse command-line arguments."""
26
- parser = argparse.ArgumentParser(description=f"FastLED WASM Compiler {__version__}")
27
- parser.add_argument(
28
- "--version", action="version", version=f"%(prog)s {__version__}"
29
- )
30
- parser.add_argument(
31
- "directory",
32
- type=str,
33
- nargs="?",
34
- default=None,
35
- help="Directory containing the FastLED sketch to compile",
36
- )
37
- parser.add_argument(
38
- "--init",
39
- action="store_true",
40
- help="Initialize the FastLED sketch in the current directory",
41
- )
42
- parser.add_argument(
43
- "--just-compile",
44
- action="store_true",
45
- help="Just compile, skip opening the browser and watching for changes.",
46
- )
47
- parser.add_argument(
48
- "--web",
49
- "-w",
50
- type=str,
51
- nargs="?",
52
- # const does not seem to be working as expected
53
- const=DEFAULT_URL, # Default value when --web is specified without value
54
- help="Use web compiler. Optional URL can be provided (default: https://fastled.onrender.com)",
55
- )
56
- parser.add_argument(
57
- "-i",
58
- "--interactive",
59
- action="store_true",
60
- help="Run in interactive mode (Not available with --web)",
61
- )
62
- parser.add_argument(
63
- "--profile",
64
- action="store_true",
65
- help="Enable profiling for web compilation",
66
- )
67
- parser.add_argument(
68
- "--force-compile",
69
- action="store_true",
70
- help="Skips the test to see if the current directory is a valid FastLED sketch directory",
71
- )
72
- parser.add_argument(
73
- "--no-auto-updates",
74
- action="store_true",
75
- help="Disable automatic updates of the wasm compiler image when using docker.",
76
- )
77
- parser.add_argument(
78
- "--update",
79
- "--upgrade",
80
- action="store_true",
81
- help="Update the wasm compiler (if necessary) before running",
82
- )
83
- parser.add_argument(
84
- "--localhost",
85
- "--local",
86
- "-l",
87
- action="store_true",
88
- help="Use localhost for web compilation from an instance of fastled --server, creating it if necessary",
89
- )
90
- parser.add_argument(
91
- "--server",
92
- "-s",
93
- action="store_true",
94
- help="Run the server in the current directory, volume mapping fastled if we are in the repo",
95
- )
96
-
97
- build_mode = parser.add_mutually_exclusive_group()
98
- build_mode.add_argument("--debug", action="store_true", help="Build in debug mode")
99
- build_mode.add_argument(
100
- "--quick",
101
- action="store_true",
102
- default=True,
103
- help="Build in quick mode (default)",
104
- )
105
- build_mode.add_argument(
106
- "--release", action="store_true", help="Build in release mode"
107
- )
108
-
109
- cwd_is_fastled = looks_like_fastled_repo(Path(os.getcwd()))
110
-
111
- args = parser.parse_args()
112
-
113
- if args.init:
114
- args.directory = project_init()
115
-
116
- if not args.update:
117
- if args.no_auto_updates:
118
- args.auto_update = False
119
- else:
120
- args.auto_update = None
121
-
122
- if (
123
- not cwd_is_fastled
124
- and not args.localhost
125
- and not args.web
126
- and not args.server
127
- ):
128
- print(f"Using web compiler at {DEFAULT_URL}")
129
- args.web = DEFAULT_URL
130
- if cwd_is_fastled and not args.web and not args.server:
131
- print("Forcing --local mode because we are in the FastLED repo")
132
- args.localhost = True
133
- if args.localhost:
134
- args.web = "localhost"
135
- if args.interactive and not args.server:
136
- print("--interactive forces --server mode")
137
- args.server = True
138
- if args.directory is None and not args.server:
139
- # does current directory look like a sketch?
140
- maybe_sketch_dir = Path(os.getcwd())
141
- if looks_like_sketch_directory(maybe_sketch_dir):
142
- args.directory = str(maybe_sketch_dir)
143
- else:
144
- sketch_directories = find_sketch_directories(maybe_sketch_dir)
145
- selected_dir = select_sketch_directory(
146
- sketch_directories, cwd_is_fastled
147
- )
148
- if selected_dir:
149
- print(f"Using sketch directory: {selected_dir}")
150
- args.directory = selected_dir
151
- else:
152
- print(
153
- "\nYou either need to specify a sketch directory or run in --server mode."
154
- )
155
- sys.exit(1)
156
- elif args.directory is not None and os.path.isfile(args.directory):
157
- dir_path = Path(args.directory).parent
158
- if looks_like_sketch_directory(dir_path):
159
- print(f"Using sketch directory: {dir_path}")
160
- args.directory = str(dir_path)
161
-
162
- return args
163
-
164
-
165
- def run_server(args: argparse.Namespace) -> int:
166
- interactive = args.interactive
167
- auto_update = args.auto_update
168
- mapped_dir = Path(args.directory).absolute() if args.directory else None
169
- compile_server = CompileServer(
170
- interactive=interactive, auto_updates=auto_update, mapped_dir=mapped_dir
171
- )
172
- if not interactive:
173
- print(f"Server started at {compile_server.url()}")
174
- compile_server.wait_for_startup()
175
- try:
176
- while True:
177
- if not compile_server.proceess_running():
178
- print("Server process is not running. Exiting...")
179
- return 1
180
- time.sleep(1)
181
- except KeyboardInterrupt:
182
- print("\nExiting from server...")
183
- return 1
184
- finally:
185
- compile_server.stop()
186
- return 0
187
-
188
-
189
- def main() -> int:
190
- args = parse_args()
191
- if args.update:
192
- # Force auto_update to ensure update check happens
193
- compile_server = CompileServer(interactive=False, auto_updates=True)
194
- compile_server.stop()
195
- print("Finished updating.")
196
- return 0
197
-
198
- if args.server:
199
- print("Running in server only mode.")
200
- return run_server(args)
201
- else:
202
- print("Running in client/server mode.")
203
- return run_client_server(args)
204
-
205
-
206
- if __name__ == "__main__":
207
- try:
208
- os.chdir("../fastled")
209
- sys.argv.append("--interactive")
210
- sys.argv.append("examples/NoiseRing")
211
- sys.exit(main())
212
- except KeyboardInterrupt:
213
- print("\nExiting from main...")
214
- sys.exit(1)
215
- except Exception as e:
216
- print(f"Error: {e}")
217
- sys.exit(1)
1
+ """
2
+ Uses the latest wasm compiler image to compile the FastLED sketch.
3
+ """
4
+
5
+ import argparse
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.parse_args import parse_args
13
+
14
+
15
+ def run_server(args: argparse.Namespace) -> int:
16
+ interactive = args.interactive
17
+ auto_update = args.auto_update
18
+ mapped_dir = Path(args.directory).absolute() if args.directory else None
19
+ compile_server = CompileServer(
20
+ interactive=interactive, auto_updates=auto_update, mapped_dir=mapped_dir
21
+ )
22
+ if not interactive:
23
+ print(f"Server started at {compile_server.url()}")
24
+ compile_server.wait_for_startup()
25
+ try:
26
+ while True:
27
+ if not compile_server.proceess_running():
28
+ print("Server process is not running. Exiting...")
29
+ return 1
30
+ time.sleep(0.1)
31
+ except KeyboardInterrupt:
32
+ print("\nExiting from server...")
33
+ return 1
34
+ finally:
35
+ compile_server.stop()
36
+ return 0
37
+
38
+
39
+ def main() -> int:
40
+ args = parse_args()
41
+ if args.update:
42
+ # Force auto_update to ensure update check happens
43
+ compile_server = CompileServer(interactive=False, auto_updates=True)
44
+ compile_server.stop()
45
+ print("Finished updating.")
46
+ return 0
47
+
48
+ if args.server:
49
+ print("Running in server only mode.")
50
+ return run_server(args)
51
+ else:
52
+ print("Running in client/server mode.")
53
+ return run_client_server(args)
54
+
55
+
56
+ if __name__ == "__main__":
57
+ try:
58
+ sys.exit(main())
59
+ except KeyboardInterrupt:
60
+ print("\nExiting from main...")
61
+ sys.exit(1)
62
+ except Exception as e:
63
+ print(f"Error: {e}")
64
+ sys.exit(1)