fastled 1.1.16__py2.py3-none-any.whl → 1.1.17__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.16"
3
+ __version__ = "1.1.17"
fastled/app.py CHANGED
@@ -104,16 +104,32 @@ def parse_args() -> argparse.Namespace:
104
104
  action="store_true",
105
105
  help="Run the server in the current directory, volume mapping fastled if we are in the repo",
106
106
  )
107
-
108
- build_mode.add_argument(
107
+ parser.add_argument(
109
108
  "--force-compile",
110
109
  action="store_true",
111
110
  help="Skips the test to see if the current directory is a valid FastLED sketch directory",
112
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
+ "--update",
119
+ action="store_true",
120
+ help="Update the wasm compiler (if necessary) before running",
121
+ )
113
122
 
114
123
  cwd_is_fastled = looks_like_fastled_repo(Path(os.getcwd()))
115
124
 
116
125
  args = parser.parse_args()
126
+ if args.update:
127
+ args.auto_update = True
128
+ elif args.no_auto_updates:
129
+ args.auto_update = False
130
+ else:
131
+ args.auto_update = None
132
+
117
133
  if not cwd_is_fastled and not args.localhost and not args.web and not args.server:
118
134
  print(f"Using web compiler at {DEFAULT_URL}")
119
135
  args.web = DEFAULT_URL
@@ -199,8 +215,8 @@ def run_web_compiler(
199
215
 
200
216
 
201
217
  def _try_start_server_or_get_url(args: argparse.Namespace) -> str | CompileServer:
218
+ auto_update = args.auto_update
202
219
  is_local_host = "localhost" in args.web or "127.0.0.1" in args.web or args.localhost
203
-
204
220
  # test to see if there is already a local host server
205
221
  local_host_needs_server = False
206
222
  if is_local_host:
@@ -225,7 +241,7 @@ def _try_start_server_or_get_url(args: argparse.Namespace) -> str | CompileServe
225
241
  else:
226
242
  try:
227
243
  print("No local server found, starting one...")
228
- compile_server = CompileServer()
244
+ compile_server = CompileServer(auto_updates=auto_update)
229
245
  print("Waiting for the local compiler to start...")
230
246
  if not compile_server.wait_for_startup():
231
247
  print("Failed to start local compiler.")
@@ -397,7 +413,8 @@ def run_client(args: argparse.Namespace) -> int:
397
413
 
398
414
  def run_server(args: argparse.Namespace) -> int:
399
415
  interactive = args.interactive
400
- compile_server = CompileServer(interactive=interactive)
416
+ auto_update = args.auto_update
417
+ compile_server = CompileServer(interactive=interactive, auto_updates=auto_update)
401
418
  if not interactive:
402
419
  print(f"Server started at {compile_server.url()}")
403
420
  compile_server.wait_for_startup()
fastled/compile_server.py CHANGED
@@ -1,5 +1,6 @@
1
1
  import subprocess
2
2
  import time
3
+ from datetime import datetime, timezone
3
4
  from pathlib import Path
4
5
 
5
6
  import httpx
@@ -20,6 +21,7 @@ class CompileServer:
20
21
  self,
21
22
  container_name=_DEFAULT_CONTAINER_NAME,
22
23
  interactive: bool = False,
24
+ auto_updates: bool | None = None,
23
25
  ) -> None:
24
26
 
25
27
  cwd = Path(".").resolve()
@@ -35,6 +37,7 @@ class CompileServer:
35
37
  self.fastled_src_dir: Path | None = fastled_src_dir
36
38
  self.interactive = interactive
37
39
  self.running_container: RunningContainer | None = None
40
+ self.auto_updates = auto_updates
38
41
  self._port = self._start()
39
42
  # fancy print
40
43
  if not interactive:
@@ -90,26 +93,25 @@ class CompileServer:
90
93
  print("Compiling server starting")
91
94
 
92
95
  # Ensure Docker is running
93
- with self.docker.get_lock():
94
- if not self.docker.is_running():
95
- if not self.docker.start():
96
- print("Docker could not be started. Exiting.")
97
- raise RuntimeError("Docker could not be started. Exiting.")
98
- from datetime import datetime, timezone
99
-
100
- now = datetime.now(timezone.utc)
101
- now_str = now.strftime("%Y-%m-%d %H %Z")
96
+ if not self.docker.is_running():
97
+ if not self.docker.start():
98
+ print("Docker could not be started. Exiting.")
99
+ raise RuntimeError("Docker could not be started. Exiting.")
100
+ now = datetime.now(timezone.utc)
101
+ now_str = now.strftime("%Y-%m-%d %H %Z")
102
+
103
+ upgrade = False
104
+ if self.auto_updates is None:
102
105
  prev_date_str = DISK_CACHE.get("last-update")
103
-
104
- upgrade = False
105
106
  if prev_date_str != now_str:
106
- print("New day, upgrading Docker image")
107
+ print("One hour has passed, checking docker for updates")
107
108
  upgrade = True
108
-
109
- self.docker.validate_or_download_image(
110
- image_name=_IMAGE_NAME, tag="main", upgrade=upgrade
111
- )
112
- DISK_CACHE.put("last-update", now_str)
109
+ else:
110
+ upgrade = self.auto_updates
111
+ self.docker.validate_or_download_image(
112
+ image_name=_IMAGE_NAME, tag="main", upgrade=upgrade
113
+ )
114
+ DISK_CACHE.put("last-update", now_str)
113
115
 
114
116
  print("Docker image now validated")
115
117
  port = SERVER_PORT
fastled/docker_manager.py CHANGED
@@ -45,8 +45,10 @@ def _win32_docker_location() -> str | None:
45
45
  return None
46
46
 
47
47
 
48
- _HERE = Path(__file__).parent
49
- _FILE_LOCK = FileLock(str(_HERE / "fled.lock"))
48
+ def get_lock(image_name: str) -> FileLock:
49
+ """Get the file lock for this DockerManager instance."""
50
+ lock_file = CONFIG_DIR / f"{image_name}.lock"
51
+ return FileLock(str(lock_file))
50
52
 
51
53
 
52
54
  class RunningContainer:
@@ -90,10 +92,6 @@ class DockerManager:
90
92
  self.client: DockerClient = docker.from_env()
91
93
  self.first_run = False
92
94
 
93
- def get_lock(self) -> FileLock:
94
- """Get the file lock for this DockerManager instance."""
95
- return _FILE_LOCK
96
-
97
95
  @staticmethod
98
96
  def is_docker_installed() -> bool:
99
97
  """Check if Docker is installed on the system."""
@@ -179,52 +177,56 @@ class DockerManager:
179
177
  """
180
178
  print(f"Validating image {image_name}:{tag}...")
181
179
 
182
- try:
183
- local_image = self.client.images.get(f"{image_name}:{tag}")
184
- print(f"Image {image_name}:{tag} is already available.")
185
-
186
- if upgrade:
187
- remote_image = self.client.images.get_registry_data(
188
- f"{image_name}:{tag}"
189
- )
190
- remote_image_hash = remote_image.id
191
- try:
192
- remote_image_hash_from_local_image = DISK_CACHE.get(local_image.id)
193
- except KeyboardInterrupt:
194
- raise
195
- except Exception:
196
- remote_image_hash_from_local_image = None
197
- import traceback
198
- import warnings
180
+ with get_lock(f"{image_name}-{tag}"):
181
+ try:
182
+ local_image = self.client.images.get(f"{image_name}:{tag}")
183
+ print(f"Image {image_name}:{tag} is already available.")
199
184
 
200
- stack = traceback.format_exc()
201
- warnings.warn(
202
- f"Error getting remote image hash from local image: {stack}"
185
+ if upgrade:
186
+ remote_image = self.client.images.get_registry_data(
187
+ f"{image_name}:{tag}"
203
188
  )
204
- if remote_image_hash_from_local_image == remote_image_hash:
205
- print(f"Local image {image_name}:{tag} is up to date.")
206
- return
189
+ remote_image_hash = remote_image.id
190
+ remote_image_hash_from_local_image: str | None = None
191
+ try:
192
+ remote_image_hash_from_local_image = DISK_CACHE.get(
193
+ local_image.id
194
+ )
195
+ except KeyboardInterrupt:
196
+ raise
197
+ except Exception:
198
+ remote_image_hash_from_local_image = None
199
+ import traceback
200
+ import warnings
201
+
202
+ stack = traceback.format_exc()
203
+ warnings.warn(
204
+ f"Error getting remote image hash from local image: {stack}"
205
+ )
206
+ if remote_image_hash_from_local_image == remote_image_hash:
207
+ print(f"Local image {image_name}:{tag} is up to date.")
208
+ return
207
209
 
208
- # Quick check for latest version
210
+ # Quick check for latest version
209
211
 
210
- print(f"Pulling newer version of {image_name}:{tag}...")
211
- _ = self.client.images.pull(image_name, tag=tag)
212
- print(f"Updated to newer version of {image_name}:{tag}")
213
- local_image_hash = self.client.images.get(f"{image_name}:{tag}").id
214
- DISK_CACHE.put(local_image_hash, remote_image_hash)
212
+ print(f"Pulling newer version of {image_name}:{tag}...")
213
+ _ = self.client.images.pull(image_name, tag=tag)
214
+ print(f"Updated to newer version of {image_name}:{tag}")
215
+ local_image_hash = self.client.images.get(f"{image_name}:{tag}").id
216
+ DISK_CACHE.put(local_image_hash, remote_image_hash)
215
217
 
216
- except docker.errors.ImageNotFound:
217
- print(f"Image {image_name}:{tag} not found. Downloading...")
218
- self.client.images.pull(image_name, tag=tag)
219
- try:
220
- local_image = self.client.images.get(f"{image_name}:{tag}")
221
- local_image_hash = local_image.id
222
- DISK_CACHE.put(local_image_hash, remote_image_hash)
223
- print(f"Image {image_name}:{tag} downloaded successfully.")
224
218
  except docker.errors.ImageNotFound:
225
- import warnings
219
+ print(f"Image {image_name}:{tag} not found. Downloading...")
220
+ self.client.images.pull(image_name, tag=tag)
221
+ try:
222
+ local_image = self.client.images.get(f"{image_name}:{tag}")
223
+ local_image_hash = local_image.id
224
+ DISK_CACHE.put(local_image_hash, remote_image_hash)
225
+ print(f"Image {image_name}:{tag} downloaded successfully.")
226
+ except docker.errors.ImageNotFound:
227
+ import warnings
226
228
 
227
- warnings.warn(f"Image {image_name}:{tag} not found after download.")
229
+ warnings.warn(f"Image {image_name}:{tag} not found after download.")
228
230
 
229
231
  def tag_image(self, image_name: str, old_tag: str, new_tag: str) -> None:
230
232
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastled
3
- Version: 1.1.16
3
+ Version: 1.1.17
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -161,6 +161,7 @@ A: A big chunk of space is being used by unnecessary javascript `emscripten` is
161
161
 
162
162
  # Revisions
163
163
 
164
+ * 1.1.17 - Added `--update` and `--no-auto-update` to control whether the compiler in docker mode will try to update.
164
165
  * 1.1.16 - Rewrote docker logic to use container suspension and resumption. Much much faster.
165
166
  * 1.1.15 - Fixed logic for considering ipv6 addresses. Auto selection of ipv6 is now restored.
166
167
  * 1.1.14 - Fixes for regression in using --server and --localhost as two instances, this is now under test.
@@ -1,9 +1,9 @@
1
- fastled/__init__.py,sha256=lSQZ1Dcii_FVM8VSJksjq9KpLmMsNl8jlUnsYp7Ko7I,64
2
- fastled/app.py,sha256=5ZKCN8XwcK6wfbp7hQRg-hUkZOSMJgmiTksQ8oX2rME,15094
1
+ fastled/__init__.py,sha256=eYxLUpPhHXARLnRFwdJgoCDIx4kVkzNiZ_--PzqMApE,64
2
+ fastled/app.py,sha256=xgMl-9s3dy2TurnSusVdIAr3ZbSi5oyEAofHsa7hZho,15695
3
3
  fastled/build_mode.py,sha256=joMwsV4K1y_LijT4gEAcjx69RZBoe_KmFmHZdPYbL_4,631
4
4
  fastled/cli.py,sha256=CNR_pQR0sNVPNuv8e_nmm-0PI8sU-eUBUgnWgWkzW9c,237
5
- fastled/compile_server.py,sha256=IKdW82dswZSWrp8oCH4khAMYqz6Vf_65m1ad8m2aSHA,5304
6
- fastled/docker_manager.py,sha256=m09qpT5GnmofPGkPIV6KDJWYduRdRZhQAntBpJoV-24,19722
5
+ fastled/compile_server.py,sha256=aBdpILSRrDsCJ5e9g5uwIqt9bcqE_8FrSddCV2ygtrI,5401
6
+ fastled/docker_manager.py,sha256=dj6s1mT-ecURqYJH-JpZZWuFHr-dGkQIOuFm845Nz40,20042
7
7
  fastled/filewatcher.py,sha256=fJNMQRDCpihSL4nQeYPqbD4m1Jzjcz_-YRAo-wlPW6k,6518
8
8
  fastled/keyboard.py,sha256=rqndglWYzRy6oiqHgsmx1peLd0Yrpci01zGENlCzh_s,2576
9
9
  fastled/open_browser.py,sha256=RRHcsZ5Vzsw1AuZUEYuSfjKmf_9j3NGMDUR-FndHmqs,1483
@@ -12,9 +12,9 @@ fastled/sketch.py,sha256=KhhPFqlFVlBk8YrzFy7-ioe7zEzecgrVLhyFbLpBp7k,1845
12
12
  fastled/util.py,sha256=t4M3NFMhnCzfYbLvIyJi0RdFssZqbTN_vVIaej1WV-U,265
13
13
  fastled/web_compile.py,sha256=KuvKGdX6SSUUqC7YgX4T9SMSP5wdcPUhpg9-K9zPoTI,10378
14
14
  fastled/assets/example.txt,sha256=lTBovRjiz0_TgtAtbA1C5hNi2ffbqnNPqkKg6UiKCT8,54
15
- fastled-1.1.16.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
16
- fastled-1.1.16.dist-info/METADATA,sha256=a7SXnewYqDzmkJF6sUkgfn0IwYH_yByh3HbUfxnhDYg,13375
17
- fastled-1.1.16.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
18
- fastled-1.1.16.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
19
- fastled-1.1.16.dist-info/top_level.txt,sha256=xfG6Z_ol9V5YmBROkZq2QTRwjbS2ouCUxaTJsOwfkOo,14
20
- fastled-1.1.16.dist-info/RECORD,,
15
+ fastled-1.1.17.dist-info/LICENSE,sha256=b6pOoifSXiUaz_lDS84vWlG3fr4yUKwB8fzkrH9R8bQ,1064
16
+ fastled-1.1.17.dist-info/METADATA,sha256=IX_gRsLWHvl9Fk7sbMWTmVoLqRGuDcAW_88tbfLAKuA,13496
17
+ fastled-1.1.17.dist-info/WHEEL,sha256=0VNUDWQJzfRahYI3neAhz2UVbRCtztpN5dPHAGvmGXc,109
18
+ fastled-1.1.17.dist-info/entry_points.txt,sha256=RCwmzCSOS4-C2i9EziANq7Z2Zb4KFnEMR1FQC0bBwAw,101
19
+ fastled-1.1.17.dist-info/top_level.txt,sha256=xfG6Z_ol9V5YmBROkZq2QTRwjbS2ouCUxaTJsOwfkOo,14
20
+ fastled-1.1.17.dist-info/RECORD,,