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