Execute package installation request. Args: request: PackageRequest object with project_dir and optional environment Returns: True if installation successful, False otherwise
(request: PackageRequest)
| 569 | |
| 570 | |
| 571 | def process_package_request(request: PackageRequest) -> bool: |
| 572 | """Execute package installation request. |
| 573 | |
| 574 | Args: |
| 575 | request: PackageRequest object with project_dir and optional environment |
| 576 | |
| 577 | Returns: |
| 578 | True if installation successful, False otherwise |
| 579 | """ |
| 580 | project_dir = request.project_dir |
| 581 | environment = request.environment |
| 582 | caller_pid = request.caller_pid |
| 583 | caller_cwd = request.caller_cwd |
| 584 | |
| 585 | # If no environment specified, use default_envs from platformio.ini |
| 586 | # This prevents PlatformIO from installing packages for ALL environments |
| 587 | if not environment: |
| 588 | environment = get_default_environment(project_dir) |
| 589 | if environment: |
| 590 | logging.info( |
| 591 | f"Using default environment from platformio.ini: {environment}" |
| 592 | ) |
| 593 | else: |
| 594 | logging.warning( |
| 595 | "No default_envs found in platformio.ini, will install for all environments" |
| 596 | ) |
| 597 | |
| 598 | env_desc = environment if environment else "all environments" |
| 599 | logging.info(f"Processing package install request: {env_desc} in {project_dir}") |
| 600 | |
| 601 | # Check disk space before installation |
| 602 | pio_packages_dir = Path.home() / ".platformio" |
| 603 | has_space, error_msg = check_disk_space(pio_packages_dir, required_mb=1000) |
| 604 | if not has_space: |
| 605 | logging.error(f"Disk space check failed: {error_msg}") |
| 606 | update_status(DaemonState.FAILED, error_msg) |
| 607 | return False |
| 608 | |
| 609 | update_status( |
| 610 | DaemonState.INSTALLING, |
| 611 | f"Installing packages for {env_desc}", |
| 612 | environment=environment, |
| 613 | project_dir=project_dir, |
| 614 | request_started_at=time.time(), |
| 615 | caller_pid=caller_pid, |
| 616 | caller_cwd=caller_cwd, |
| 617 | ) |
| 618 | |
| 619 | # Build command - omit --environment if None to use PlatformIO default |
| 620 | cmd = [ |
| 621 | "pio", |
| 622 | "pkg", |
| 623 | "install", |
| 624 | "--project-dir", |
| 625 | project_dir, |
| 626 | ] |
| 627 | |
| 628 | if environment: |
no test coverage detected