MCPcopy Create free account
hub / github.com/FastLED/FastLED / predownload_toolchains

Function predownload_toolchains

ci/util/toolchain_downloader.py:203–293  ·  view source on GitHub ↗

Pre-download all toolchains from a platformio.ini file. Args: platformio_ini_path: Path to platformio.ini file cache_dir: Cache directory (defaults to ~/.platformio/global_cache) max_workers: Maximum number of concurrent downloads Returns: Dictionary ma

(
    platformio_ini_path: Path,
    cache_dir: Optional[Path] = None,
    max_workers: int = 4,
)

Source from the content-addressed store, hash-verified

201
202
203def predownload_toolchains(
204 platformio_ini_path: Path,
205 cache_dir: Optional[Path] = None,
206 max_workers: int = 4,
207) -> dict[str, ToolchainDownloadResult]:
208 """
209 Pre-download all toolchains from a platformio.ini file.
210
211 Args:
212 platformio_ini_path: Path to platformio.ini file
213 cache_dir: Cache directory (defaults to ~/.platformio/global_cache)
214 max_workers: Maximum number of concurrent downloads
215
216 Returns:
217 Dictionary mapping package names to download results
218 """
219 if cache_dir is None:
220 cache_dir = Path.home() / ".platformio" / "global_cache"
221
222 cache_dir.mkdir(parents=True, exist_ok=True)
223
224 logger.info(f"🔍 Extracting toolchains from: {platformio_ini_path}")
225 logger.info(f"📁 Cache directory: {cache_dir}")
226
227 # Extract all packages
228 packages = extract_toolchains_from_platformio_ini(platformio_ini_path)
229
230 if not packages:
231 logger.warning("No packages found in platformio.ini")
232 return {}
233
234 logger.info(f"Found {len(packages)} total packages")
235
236 # Deduplicate by name and version
237 unique_packages: dict[str, PackageInfo] = {}
238 for package in packages:
239 key = f"{package.name}:{package.version or 'latest'}"
240 if key not in unique_packages:
241 unique_packages[key] = package
242
243 logger.info(f"Processing {len(unique_packages)} unique packages")
244
245 # Download toolchains concurrently
246 results: dict[str, ToolchainDownloadResult] = {}
247 downloader = ResumableDownloader(chunk_size=8192, max_retries=5)
248
249 with ThreadPoolExecutor(max_workers=max_workers) as executor:
250 futures = {
251 executor.submit(download_toolchain, package, cache_dir, downloader): package
252 for package in unique_packages.values()
253 }
254
255 for future in as_completed(futures):
256 package = futures[future]
257 try:
258 result = future.result()
259 results[package.name] = result
260

Callers 1

mainFunction · 0.85

Calls 10

ResumableDownloaderClass · 0.90
warningMethod · 0.80
valuesMethod · 0.80
printFunction · 0.50
infoMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected