Validate package installation request. Args: request: PackageRequest object Returns: True if request is valid, False otherwise
(request: PackageRequest)
| 359 | |
| 360 | |
| 361 | def validate_request(request: PackageRequest) -> bool: |
| 362 | """Validate package installation request. |
| 363 | |
| 364 | Args: |
| 365 | request: PackageRequest object |
| 366 | |
| 367 | Returns: |
| 368 | True if request is valid, False otherwise |
| 369 | """ |
| 370 | project_dir = Path(request.project_dir) |
| 371 | |
| 372 | # Verify project directory exists |
| 373 | if not project_dir.exists() or not project_dir.is_dir(): |
| 374 | logging.error(f"Project directory does not exist: {project_dir}") |
| 375 | return False |
| 376 | |
| 377 | # Verify platformio.ini exists |
| 378 | if not (project_dir / "platformio.ini").exists(): |
| 379 | logging.error(f"platformio.ini not found in {project_dir}") |
| 380 | return False |
| 381 | |
| 382 | # Verify environment is valid (if provided) |
| 383 | env = request.environment |
| 384 | if env is not None and (not isinstance(env, str) or not env): |
| 385 | logging.error(f"Invalid environment: {env}") |
| 386 | return False |
| 387 | |
| 388 | return True |
| 389 | |
| 390 | |
| 391 | def run_package_install_with_retry( |
no test coverage detected