fastled 1.3.14__py3-none-any.whl → 1.3.15__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 +1 -1
- fastled/app.py +177 -177
- fastled/client_server.py +519 -519
- fastled/docker_manager.py +1068 -1068
- fastled/open_browser.py +137 -137
- fastled/parse_args.py +301 -301
- fastled/print_filter.py +247 -247
- fastled/project_init.py +129 -129
- fastled/site/build.py +449 -449
- fastled/string_diff.py +82 -82
- fastled/version.py +41 -41
- {fastled-1.3.14.dist-info → fastled-1.3.15.dist-info}/METADATA +477 -477
- {fastled-1.3.14.dist-info → fastled-1.3.15.dist-info}/RECORD +17 -17
- {fastled-1.3.14.dist-info → fastled-1.3.15.dist-info}/WHEEL +0 -0
- {fastled-1.3.14.dist-info → fastled-1.3.15.dist-info}/entry_points.txt +0 -0
- {fastled-1.3.14.dist-info → fastled-1.3.15.dist-info}/licenses/LICENSE +0 -0
- {fastled-1.3.14.dist-info → fastled-1.3.15.dist-info}/top_level.txt +0 -0
fastled/parse_args.py
CHANGED
@@ -1,301 +1,301 @@
|
|
1
|
-
import argparse
|
2
|
-
import os
|
3
|
-
import sys
|
4
|
-
from pathlib import Path
|
5
|
-
|
6
|
-
from fastled.args import Args
|
7
|
-
from fastled.project_init import project_init
|
8
|
-
from fastled.select_sketch_directory import select_sketch_directory
|
9
|
-
from fastled.settings import DEFAULT_URL, IMAGE_NAME
|
10
|
-
from fastled.sketch import (
|
11
|
-
find_sketch_directories,
|
12
|
-
looks_like_fastled_repo,
|
13
|
-
looks_like_sketch_directory,
|
14
|
-
)
|
15
|
-
|
16
|
-
|
17
|
-
def _find_fastled_repo(start: Path) -> Path | None:
|
18
|
-
"""Find the FastLED repo directory by searching upwards from the current directory."""
|
19
|
-
current = start
|
20
|
-
while current != current.parent:
|
21
|
-
if looks_like_fastled_repo(current):
|
22
|
-
return current
|
23
|
-
current = current.parent
|
24
|
-
return None
|
25
|
-
|
26
|
-
|
27
|
-
_DEFAULT_HELP_TEXT = """
|
28
|
-
FastLED WASM Compiler - Useful options:
|
29
|
-
<directory> Directory containing the FastLED sketch to compile
|
30
|
-
--init [example] Initialize one of the top tier WASM examples
|
31
|
-
--web [url] Use web compiler
|
32
|
-
--server Run the compiler server
|
33
|
-
--quick Build in quick mode (default)
|
34
|
-
--profile Enable profiling the C++ build system
|
35
|
-
--update Update the docker image for the wasm compiler
|
36
|
-
--purge Remove all FastLED containers and images
|
37
|
-
--version Show version information
|
38
|
-
--help Show detailed help
|
39
|
-
Examples:
|
40
|
-
fastled (will auto detect the sketch directory and prompt you)
|
41
|
-
fastled my_sketch
|
42
|
-
fastled my_sketch --web (compiles using the web compiler only)
|
43
|
-
fastled --init Blink (initializes a new sketch directory with the Blink example)
|
44
|
-
fastled --server (runs the compiler server in the current directory)
|
45
|
-
|
46
|
-
For those using Docker:
|
47
|
-
--debug Build with debug symbols for dev-tools debugging
|
48
|
-
|
49
|
-
--release Build in optimized release mode
|
50
|
-
"""
|
51
|
-
|
52
|
-
|
53
|
-
def parse_args() -> Args:
|
54
|
-
"""Parse command-line arguments."""
|
55
|
-
from fastled import __version__
|
56
|
-
|
57
|
-
# Check if no arguments were provided
|
58
|
-
if len(sys.argv) == 1:
|
59
|
-
print(_DEFAULT_HELP_TEXT)
|
60
|
-
|
61
|
-
parser = argparse.ArgumentParser(description=f"FastLED WASM Compiler {__version__}")
|
62
|
-
parser.add_argument("--version", action="version", version=f"{__version__}")
|
63
|
-
parser.add_argument(
|
64
|
-
"directory",
|
65
|
-
type=str,
|
66
|
-
nargs="?",
|
67
|
-
default=None,
|
68
|
-
help="Directory containing the FastLED sketch to compile",
|
69
|
-
)
|
70
|
-
parser.add_argument(
|
71
|
-
"--init",
|
72
|
-
nargs="?",
|
73
|
-
const=True,
|
74
|
-
help="Initialize the FastLED sketch in the current directory. Optional name can be provided",
|
75
|
-
)
|
76
|
-
parser.add_argument(
|
77
|
-
"--just-compile",
|
78
|
-
action="store_true",
|
79
|
-
help="Just compile, skip opening the browser and watching for changes.",
|
80
|
-
)
|
81
|
-
parser.add_argument(
|
82
|
-
"--ram-disk-size",
|
83
|
-
type=str,
|
84
|
-
default="0",
|
85
|
-
help="Set the size of the ramdisk for the docker container. Use suffixes like '25mb' or '1gb'.",
|
86
|
-
)
|
87
|
-
parser.add_argument(
|
88
|
-
"--web",
|
89
|
-
"-w",
|
90
|
-
type=str,
|
91
|
-
nargs="?",
|
92
|
-
# const does not seem to be working as expected
|
93
|
-
const=DEFAULT_URL, # Default value when --web is specified without value
|
94
|
-
help="Use web compiler. Optional URL can be provided (default: https://fastled.onrender.com)",
|
95
|
-
)
|
96
|
-
parser.add_argument(
|
97
|
-
"-i",
|
98
|
-
"--interactive",
|
99
|
-
action="store_true",
|
100
|
-
help="Run in interactive mode (Not available with --web)",
|
101
|
-
)
|
102
|
-
parser.add_argument(
|
103
|
-
"--profile",
|
104
|
-
action="store_true",
|
105
|
-
help="Enable profiling of the C++ build system used for wasm compilation.",
|
106
|
-
)
|
107
|
-
parser.add_argument(
|
108
|
-
"--force-compile",
|
109
|
-
action="store_true",
|
110
|
-
help="Skips the test to see if the current directory is a valid FastLED sketch directory",
|
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
|
-
"-u",
|
119
|
-
"--update",
|
120
|
-
"--upgrade",
|
121
|
-
action="store_true",
|
122
|
-
help="Update the wasm compiler (if necessary) before running",
|
123
|
-
)
|
124
|
-
parser.add_argument(
|
125
|
-
"--localhost",
|
126
|
-
"--local",
|
127
|
-
"-l",
|
128
|
-
action="store_true",
|
129
|
-
help="(Default): Use localhost for web compilation from an instance of fastled --server, creating it if necessary",
|
130
|
-
)
|
131
|
-
parser.add_argument(
|
132
|
-
"--build",
|
133
|
-
"-b",
|
134
|
-
action="store_true",
|
135
|
-
help="Build the wasm compiler image from the FastLED repo",
|
136
|
-
)
|
137
|
-
parser.add_argument(
|
138
|
-
"--server",
|
139
|
-
"-s",
|
140
|
-
action="store_true",
|
141
|
-
help="Run the server in the current directory, volume mapping fastled if we are in the repo",
|
142
|
-
)
|
143
|
-
parser.add_argument(
|
144
|
-
"--purge",
|
145
|
-
action="store_true",
|
146
|
-
help="Remove all FastLED containers and images",
|
147
|
-
)
|
148
|
-
|
149
|
-
parser.add_argument(
|
150
|
-
"--clear",
|
151
|
-
action="store_true",
|
152
|
-
help="Remove all FastLED containers and images",
|
153
|
-
)
|
154
|
-
|
155
|
-
build_mode = parser.add_mutually_exclusive_group()
|
156
|
-
build_mode.add_argument("--debug", action="store_true", help="Build in debug mode")
|
157
|
-
build_mode.add_argument(
|
158
|
-
"--quick",
|
159
|
-
action="store_true",
|
160
|
-
help="Build in quick mode (default)",
|
161
|
-
)
|
162
|
-
build_mode.add_argument(
|
163
|
-
"--release", action="store_true", help="Build in release mode"
|
164
|
-
)
|
165
|
-
|
166
|
-
cwd_is_fastled = looks_like_fastled_repo(Path(os.getcwd()))
|
167
|
-
|
168
|
-
args = parser.parse_args()
|
169
|
-
|
170
|
-
# TODO: propagate the library.
|
171
|
-
# from fastled.docker_manager import force_remove_previous
|
172
|
-
|
173
|
-
# if force_remove_previous():
|
174
|
-
# print("Removing previous containers...")
|
175
|
-
# do itinfront he camer
|
176
|
-
# nonw invoke via the
|
177
|
-
#
|
178
|
-
# Work in progress.
|
179
|
-
# set_ramdisk_size("50mb")
|
180
|
-
|
181
|
-
# if args.ram_disk_size != "0":
|
182
|
-
# from fastled.docker_manager import set_ramdisk_size
|
183
|
-
# from fastled.util import banner_string
|
184
|
-
|
185
|
-
# msg = banner_string(f"Setting tmpfs size to {args.ram_disk_size}")
|
186
|
-
# print(msg)
|
187
|
-
# set_ramdisk_size(args.ram_disk_size)
|
188
|
-
|
189
|
-
if args.purge:
|
190
|
-
from fastled.docker_manager import DockerManager
|
191
|
-
|
192
|
-
docker = DockerManager()
|
193
|
-
docker.purge(IMAGE_NAME)
|
194
|
-
sys.exit(0)
|
195
|
-
|
196
|
-
if args.init:
|
197
|
-
example = args.init if args.init is not True else None
|
198
|
-
try:
|
199
|
-
args.directory = project_init(example, args.directory)
|
200
|
-
except Exception as e:
|
201
|
-
print(f"Failed to initialize project: {e}")
|
202
|
-
sys.exit(1)
|
203
|
-
print("\nInitialized FastLED project in", args.directory)
|
204
|
-
print(f"Use 'fastled {args.directory}' to compile the project.")
|
205
|
-
sys.exit(0)
|
206
|
-
|
207
|
-
cwd: Path = Path(os.getcwd())
|
208
|
-
fastled_dir: Path | None = _find_fastled_repo(cwd)
|
209
|
-
is_fastled_dir: bool = fastled_dir is not None
|
210
|
-
|
211
|
-
if not (args.debug or args.quick or args.release):
|
212
|
-
if is_fastled_dir:
|
213
|
-
# if --quick, --debug, --release are not specified then default to --debug
|
214
|
-
args.quick = True
|
215
|
-
print("Defaulting to --quick mode in fastled repo")
|
216
|
-
else:
|
217
|
-
args.quick = True
|
218
|
-
print("Defaulting to --quick mode")
|
219
|
-
|
220
|
-
if args.build or args.interactive:
|
221
|
-
if args.directory is not None:
|
222
|
-
args.directory = str(Path(args.directory).absolute())
|
223
|
-
if not is_fastled_dir:
|
224
|
-
print("This command must be run from within the FastLED repo. Exiting...")
|
225
|
-
sys.exit(1)
|
226
|
-
if cwd != fastled_dir and fastled_dir is not None:
|
227
|
-
print(f"Switching to FastLED repo at {fastled_dir}")
|
228
|
-
os.chdir(fastled_dir)
|
229
|
-
if args.directory is None:
|
230
|
-
args.directory = str(Path("examples/wasm").absolute())
|
231
|
-
if args.interactive:
|
232
|
-
if not args.build:
|
233
|
-
print("Adding --build flag when using --interactive")
|
234
|
-
args.build = True
|
235
|
-
user_wants_update = args.update
|
236
|
-
if user_wants_update is not True:
|
237
|
-
args.no_auto_updates = True
|
238
|
-
return Args.from_namespace(args)
|
239
|
-
|
240
|
-
if not args.update:
|
241
|
-
if args.no_auto_updates:
|
242
|
-
args.auto_update = False
|
243
|
-
else:
|
244
|
-
args.auto_update = None
|
245
|
-
|
246
|
-
if (
|
247
|
-
not cwd_is_fastled
|
248
|
-
and not args.localhost
|
249
|
-
and not args.web
|
250
|
-
and not args.server
|
251
|
-
):
|
252
|
-
from fastled.docker_manager import DockerManager
|
253
|
-
|
254
|
-
if DockerManager.is_docker_installed():
|
255
|
-
if not DockerManager.ensure_linux_containers_for_windows():
|
256
|
-
print(
|
257
|
-
f"Windows must be in linux containers mode, but is in Windows container mode, Using web compiler at {DEFAULT_URL}."
|
258
|
-
)
|
259
|
-
args.web = DEFAULT_URL
|
260
|
-
else:
|
261
|
-
print(
|
262
|
-
"Docker is installed. Defaulting to --local mode, use --web to override and use the web compiler instead."
|
263
|
-
)
|
264
|
-
args.localhost = True
|
265
|
-
else:
|
266
|
-
print(f"Docker is not installed. Using web compiler at {DEFAULT_URL}.")
|
267
|
-
args.web = DEFAULT_URL
|
268
|
-
if cwd_is_fastled and not args.web and not args.server:
|
269
|
-
print("Forcing --local mode because we are in the FastLED repo")
|
270
|
-
args.localhost = True
|
271
|
-
if args.localhost:
|
272
|
-
args.web = "localhost"
|
273
|
-
if args.interactive and not args.server:
|
274
|
-
print("--interactive forces --server mode")
|
275
|
-
args.server = True
|
276
|
-
if args.directory is None and not args.server:
|
277
|
-
# does current directory look like a sketch?
|
278
|
-
maybe_sketch_dir = Path(os.getcwd())
|
279
|
-
if looks_like_sketch_directory(maybe_sketch_dir):
|
280
|
-
args.directory = str(maybe_sketch_dir)
|
281
|
-
else:
|
282
|
-
print("Searching for sketch directories...")
|
283
|
-
sketch_directories = find_sketch_directories(maybe_sketch_dir)
|
284
|
-
selected_dir = select_sketch_directory(
|
285
|
-
sketch_directories, cwd_is_fastled
|
286
|
-
)
|
287
|
-
if selected_dir:
|
288
|
-
print(f"Using sketch directory: {selected_dir}")
|
289
|
-
args.directory = selected_dir
|
290
|
-
else:
|
291
|
-
print(
|
292
|
-
"\nYou either need to specify a sketch directory or run in --server mode."
|
293
|
-
)
|
294
|
-
sys.exit(1)
|
295
|
-
elif args.directory is not None and os.path.isfile(args.directory):
|
296
|
-
dir_path = Path(args.directory).parent
|
297
|
-
if looks_like_sketch_directory(dir_path):
|
298
|
-
print(f"Using sketch directory: {dir_path}")
|
299
|
-
args.directory = str(dir_path)
|
300
|
-
|
301
|
-
return Args.from_namespace(args)
|
1
|
+
import argparse
|
2
|
+
import os
|
3
|
+
import sys
|
4
|
+
from pathlib import Path
|
5
|
+
|
6
|
+
from fastled.args import Args
|
7
|
+
from fastled.project_init import project_init
|
8
|
+
from fastled.select_sketch_directory import select_sketch_directory
|
9
|
+
from fastled.settings import DEFAULT_URL, IMAGE_NAME
|
10
|
+
from fastled.sketch import (
|
11
|
+
find_sketch_directories,
|
12
|
+
looks_like_fastled_repo,
|
13
|
+
looks_like_sketch_directory,
|
14
|
+
)
|
15
|
+
|
16
|
+
|
17
|
+
def _find_fastled_repo(start: Path) -> Path | None:
|
18
|
+
"""Find the FastLED repo directory by searching upwards from the current directory."""
|
19
|
+
current = start
|
20
|
+
while current != current.parent:
|
21
|
+
if looks_like_fastled_repo(current):
|
22
|
+
return current
|
23
|
+
current = current.parent
|
24
|
+
return None
|
25
|
+
|
26
|
+
|
27
|
+
_DEFAULT_HELP_TEXT = """
|
28
|
+
FastLED WASM Compiler - Useful options:
|
29
|
+
<directory> Directory containing the FastLED sketch to compile
|
30
|
+
--init [example] Initialize one of the top tier WASM examples
|
31
|
+
--web [url] Use web compiler
|
32
|
+
--server Run the compiler server
|
33
|
+
--quick Build in quick mode (default)
|
34
|
+
--profile Enable profiling the C++ build system
|
35
|
+
--update Update the docker image for the wasm compiler
|
36
|
+
--purge Remove all FastLED containers and images
|
37
|
+
--version Show version information
|
38
|
+
--help Show detailed help
|
39
|
+
Examples:
|
40
|
+
fastled (will auto detect the sketch directory and prompt you)
|
41
|
+
fastled my_sketch
|
42
|
+
fastled my_sketch --web (compiles using the web compiler only)
|
43
|
+
fastled --init Blink (initializes a new sketch directory with the Blink example)
|
44
|
+
fastled --server (runs the compiler server in the current directory)
|
45
|
+
|
46
|
+
For those using Docker:
|
47
|
+
--debug Build with debug symbols for dev-tools debugging
|
48
|
+
|
49
|
+
--release Build in optimized release mode
|
50
|
+
"""
|
51
|
+
|
52
|
+
|
53
|
+
def parse_args() -> Args:
|
54
|
+
"""Parse command-line arguments."""
|
55
|
+
from fastled import __version__
|
56
|
+
|
57
|
+
# Check if no arguments were provided
|
58
|
+
if len(sys.argv) == 1:
|
59
|
+
print(_DEFAULT_HELP_TEXT)
|
60
|
+
|
61
|
+
parser = argparse.ArgumentParser(description=f"FastLED WASM Compiler {__version__}")
|
62
|
+
parser.add_argument("--version", action="version", version=f"{__version__}")
|
63
|
+
parser.add_argument(
|
64
|
+
"directory",
|
65
|
+
type=str,
|
66
|
+
nargs="?",
|
67
|
+
default=None,
|
68
|
+
help="Directory containing the FastLED sketch to compile",
|
69
|
+
)
|
70
|
+
parser.add_argument(
|
71
|
+
"--init",
|
72
|
+
nargs="?",
|
73
|
+
const=True,
|
74
|
+
help="Initialize the FastLED sketch in the current directory. Optional name can be provided",
|
75
|
+
)
|
76
|
+
parser.add_argument(
|
77
|
+
"--just-compile",
|
78
|
+
action="store_true",
|
79
|
+
help="Just compile, skip opening the browser and watching for changes.",
|
80
|
+
)
|
81
|
+
parser.add_argument(
|
82
|
+
"--ram-disk-size",
|
83
|
+
type=str,
|
84
|
+
default="0",
|
85
|
+
help="Set the size of the ramdisk for the docker container. Use suffixes like '25mb' or '1gb'.",
|
86
|
+
)
|
87
|
+
parser.add_argument(
|
88
|
+
"--web",
|
89
|
+
"-w",
|
90
|
+
type=str,
|
91
|
+
nargs="?",
|
92
|
+
# const does not seem to be working as expected
|
93
|
+
const=DEFAULT_URL, # Default value when --web is specified without value
|
94
|
+
help="Use web compiler. Optional URL can be provided (default: https://fastled.onrender.com)",
|
95
|
+
)
|
96
|
+
parser.add_argument(
|
97
|
+
"-i",
|
98
|
+
"--interactive",
|
99
|
+
action="store_true",
|
100
|
+
help="Run in interactive mode (Not available with --web)",
|
101
|
+
)
|
102
|
+
parser.add_argument(
|
103
|
+
"--profile",
|
104
|
+
action="store_true",
|
105
|
+
help="Enable profiling of the C++ build system used for wasm compilation.",
|
106
|
+
)
|
107
|
+
parser.add_argument(
|
108
|
+
"--force-compile",
|
109
|
+
action="store_true",
|
110
|
+
help="Skips the test to see if the current directory is a valid FastLED sketch directory",
|
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
|
+
"-u",
|
119
|
+
"--update",
|
120
|
+
"--upgrade",
|
121
|
+
action="store_true",
|
122
|
+
help="Update the wasm compiler (if necessary) before running",
|
123
|
+
)
|
124
|
+
parser.add_argument(
|
125
|
+
"--localhost",
|
126
|
+
"--local",
|
127
|
+
"-l",
|
128
|
+
action="store_true",
|
129
|
+
help="(Default): Use localhost for web compilation from an instance of fastled --server, creating it if necessary",
|
130
|
+
)
|
131
|
+
parser.add_argument(
|
132
|
+
"--build",
|
133
|
+
"-b",
|
134
|
+
action="store_true",
|
135
|
+
help="Build the wasm compiler image from the FastLED repo",
|
136
|
+
)
|
137
|
+
parser.add_argument(
|
138
|
+
"--server",
|
139
|
+
"-s",
|
140
|
+
action="store_true",
|
141
|
+
help="Run the server in the current directory, volume mapping fastled if we are in the repo",
|
142
|
+
)
|
143
|
+
parser.add_argument(
|
144
|
+
"--purge",
|
145
|
+
action="store_true",
|
146
|
+
help="Remove all FastLED containers and images",
|
147
|
+
)
|
148
|
+
|
149
|
+
parser.add_argument(
|
150
|
+
"--clear",
|
151
|
+
action="store_true",
|
152
|
+
help="Remove all FastLED containers and images",
|
153
|
+
)
|
154
|
+
|
155
|
+
build_mode = parser.add_mutually_exclusive_group()
|
156
|
+
build_mode.add_argument("--debug", action="store_true", help="Build in debug mode")
|
157
|
+
build_mode.add_argument(
|
158
|
+
"--quick",
|
159
|
+
action="store_true",
|
160
|
+
help="Build in quick mode (default)",
|
161
|
+
)
|
162
|
+
build_mode.add_argument(
|
163
|
+
"--release", action="store_true", help="Build in release mode"
|
164
|
+
)
|
165
|
+
|
166
|
+
cwd_is_fastled = looks_like_fastled_repo(Path(os.getcwd()))
|
167
|
+
|
168
|
+
args = parser.parse_args()
|
169
|
+
|
170
|
+
# TODO: propagate the library.
|
171
|
+
# from fastled.docker_manager import force_remove_previous
|
172
|
+
|
173
|
+
# if force_remove_previous():
|
174
|
+
# print("Removing previous containers...")
|
175
|
+
# do itinfront he camer
|
176
|
+
# nonw invoke via the
|
177
|
+
#
|
178
|
+
# Work in progress.
|
179
|
+
# set_ramdisk_size("50mb")
|
180
|
+
|
181
|
+
# if args.ram_disk_size != "0":
|
182
|
+
# from fastled.docker_manager import set_ramdisk_size
|
183
|
+
# from fastled.util import banner_string
|
184
|
+
|
185
|
+
# msg = banner_string(f"Setting tmpfs size to {args.ram_disk_size}")
|
186
|
+
# print(msg)
|
187
|
+
# set_ramdisk_size(args.ram_disk_size)
|
188
|
+
|
189
|
+
if args.purge:
|
190
|
+
from fastled.docker_manager import DockerManager
|
191
|
+
|
192
|
+
docker = DockerManager()
|
193
|
+
docker.purge(IMAGE_NAME)
|
194
|
+
sys.exit(0)
|
195
|
+
|
196
|
+
if args.init:
|
197
|
+
example = args.init if args.init is not True else None
|
198
|
+
try:
|
199
|
+
args.directory = project_init(example, args.directory)
|
200
|
+
except Exception as e:
|
201
|
+
print(f"Failed to initialize project: {e}")
|
202
|
+
sys.exit(1)
|
203
|
+
print("\nInitialized FastLED project in", args.directory)
|
204
|
+
print(f"Use 'fastled {args.directory}' to compile the project.")
|
205
|
+
sys.exit(0)
|
206
|
+
|
207
|
+
cwd: Path = Path(os.getcwd())
|
208
|
+
fastled_dir: Path | None = _find_fastled_repo(cwd)
|
209
|
+
is_fastled_dir: bool = fastled_dir is not None
|
210
|
+
|
211
|
+
if not (args.debug or args.quick or args.release):
|
212
|
+
if is_fastled_dir:
|
213
|
+
# if --quick, --debug, --release are not specified then default to --debug
|
214
|
+
args.quick = True
|
215
|
+
print("Defaulting to --quick mode in fastled repo")
|
216
|
+
else:
|
217
|
+
args.quick = True
|
218
|
+
print("Defaulting to --quick mode")
|
219
|
+
|
220
|
+
if args.build or args.interactive:
|
221
|
+
if args.directory is not None:
|
222
|
+
args.directory = str(Path(args.directory).absolute())
|
223
|
+
if not is_fastled_dir:
|
224
|
+
print("This command must be run from within the FastLED repo. Exiting...")
|
225
|
+
sys.exit(1)
|
226
|
+
if cwd != fastled_dir and fastled_dir is not None:
|
227
|
+
print(f"Switching to FastLED repo at {fastled_dir}")
|
228
|
+
os.chdir(fastled_dir)
|
229
|
+
if args.directory is None:
|
230
|
+
args.directory = str(Path("examples/wasm").absolute())
|
231
|
+
if args.interactive:
|
232
|
+
if not args.build:
|
233
|
+
print("Adding --build flag when using --interactive")
|
234
|
+
args.build = True
|
235
|
+
user_wants_update = args.update
|
236
|
+
if user_wants_update is not True:
|
237
|
+
args.no_auto_updates = True
|
238
|
+
return Args.from_namespace(args)
|
239
|
+
|
240
|
+
if not args.update:
|
241
|
+
if args.no_auto_updates:
|
242
|
+
args.auto_update = False
|
243
|
+
else:
|
244
|
+
args.auto_update = None
|
245
|
+
|
246
|
+
if (
|
247
|
+
not cwd_is_fastled
|
248
|
+
and not args.localhost
|
249
|
+
and not args.web
|
250
|
+
and not args.server
|
251
|
+
):
|
252
|
+
from fastled.docker_manager import DockerManager
|
253
|
+
|
254
|
+
if DockerManager.is_docker_installed():
|
255
|
+
if not DockerManager.ensure_linux_containers_for_windows():
|
256
|
+
print(
|
257
|
+
f"Windows must be in linux containers mode, but is in Windows container mode, Using web compiler at {DEFAULT_URL}."
|
258
|
+
)
|
259
|
+
args.web = DEFAULT_URL
|
260
|
+
else:
|
261
|
+
print(
|
262
|
+
"Docker is installed. Defaulting to --local mode, use --web to override and use the web compiler instead."
|
263
|
+
)
|
264
|
+
args.localhost = True
|
265
|
+
else:
|
266
|
+
print(f"Docker is not installed. Using web compiler at {DEFAULT_URL}.")
|
267
|
+
args.web = DEFAULT_URL
|
268
|
+
if cwd_is_fastled and not args.web and not args.server:
|
269
|
+
print("Forcing --local mode because we are in the FastLED repo")
|
270
|
+
args.localhost = True
|
271
|
+
if args.localhost:
|
272
|
+
args.web = "localhost"
|
273
|
+
if args.interactive and not args.server:
|
274
|
+
print("--interactive forces --server mode")
|
275
|
+
args.server = True
|
276
|
+
if args.directory is None and not args.server:
|
277
|
+
# does current directory look like a sketch?
|
278
|
+
maybe_sketch_dir = Path(os.getcwd())
|
279
|
+
if looks_like_sketch_directory(maybe_sketch_dir):
|
280
|
+
args.directory = str(maybe_sketch_dir)
|
281
|
+
else:
|
282
|
+
print("Searching for sketch directories...")
|
283
|
+
sketch_directories = find_sketch_directories(maybe_sketch_dir)
|
284
|
+
selected_dir = select_sketch_directory(
|
285
|
+
sketch_directories, cwd_is_fastled
|
286
|
+
)
|
287
|
+
if selected_dir:
|
288
|
+
print(f"Using sketch directory: {selected_dir}")
|
289
|
+
args.directory = selected_dir
|
290
|
+
else:
|
291
|
+
print(
|
292
|
+
"\nYou either need to specify a sketch directory or run in --server mode."
|
293
|
+
)
|
294
|
+
sys.exit(1)
|
295
|
+
elif args.directory is not None and os.path.isfile(args.directory):
|
296
|
+
dir_path = Path(args.directory).parent
|
297
|
+
if looks_like_sketch_directory(dir_path):
|
298
|
+
print(f"Using sketch directory: {dir_path}")
|
299
|
+
args.directory = str(dir_path)
|
300
|
+
|
301
|
+
return Args.from_namespace(args)
|