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

Method _run_pio_command

ci/compiler/platformio_ini.py:1561–1611  ·  view source on GitHub ↗

Run a PlatformIO CLI command and return JSON output.

(
        self, args: list[str]
    )

Source from the content-addressed store, hash-verified

1559 return age < timedelta(hours=resolution.ttl_hours)
1560
1561 def _run_pio_command(
1562 self, args: list[str]
1563 ) -> Optional[dict[str, Any] | list[dict[str, Any]]]:
1564 """Run a PlatformIO CLI command and return JSON output."""
1565 try:
1566 cmd = ["pio"] + args
1567 logger.debug(f"Running PlatformIO command: {' '.join(cmd)}")
1568
1569 result = subprocess.run(
1570 cmd,
1571 capture_output=True,
1572 text=True,
1573 timeout=60,
1574 check=True,
1575 )
1576
1577 if result.stdout:
1578 try:
1579 parsed_output = json.loads(result.stdout)
1580 # Return parsed output if it's a dict or list
1581 if isinstance(parsed_output, dict):
1582 return cast(dict[str, Any], parsed_output)
1583 elif isinstance(parsed_output, list):
1584 return cast(list[dict[str, Any]], parsed_output)
1585 else:
1586 logger.warning(f"Unexpected JSON type: {type(parsed_output)}")
1587 return None
1588 except json.JSONDecodeError as e:
1589 logger.error(f"Failed to parse PlatformIO JSON output: {e}")
1590 logger.debug(f"Raw output: {result.stdout[:500]}")
1591 return None
1592
1593 return None
1594
1595 except subprocess.TimeoutExpired:
1596 cmd_str = " ".join(["pio"] + args)
1597 logger.error(f"PlatformIO command timed out: {cmd_str}")
1598 except subprocess.CalledProcessError as e:
1599 cmd_str = " ".join(["pio"] + args)
1600 logger.error(f"PlatformIO command failed: {e}")
1601 logger.debug(f"Command output: {e.stdout}, Error: {e.stderr}")
1602 except FileNotFoundError:
1603 logger.error("PlatformIO CLI not found. Is it installed and in PATH?")
1604 except KeyboardInterrupt as ki:
1605 handle_keyboard_interrupt(ki)
1606 raise
1607 except Exception as e:
1608 cmd_str = " ".join(["pio"] + args)
1609 logger.error(f"Unexpected error running PlatformIO command: {e}")
1610
1611 return None
1612
1613 def _get_platform_show_typed(
1614 self, platform_name: str

Callers 3

resolve_platform_urlMethod · 0.95

Calls 5

debugMethod · 0.80
warningMethod · 0.80
runMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected