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

Class PackageRequest

ci/util/pio_package_messages.py:54–104  ·  view source on GitHub ↗

Client → Daemon: Package installation request message. This message is written to the request file by the client to initiate a package installation. Attributes: project_dir: Absolute path to PlatformIO project directory environment: PlatformIO environment name (None = u

Source from the content-addressed store, hash-verified

52@typechecked
53@dataclass
54class PackageRequest:
55 """Client → Daemon: Package installation request message.
56
57 This message is written to the request file by the client to initiate
58 a package installation.
59
60 Attributes:
61 project_dir: Absolute path to PlatformIO project directory
62 environment: PlatformIO environment name (None = use default)
63 timestamp: Unix timestamp when request was created
64 caller_pid: Process ID of the requesting client
65 caller_cwd: Working directory of the requesting client
66 request_id: Unique identifier for this request
67 """
68
69 project_dir: str
70 environment: str | None
71 timestamp: float
72 caller_pid: int
73 caller_cwd: str
74 request_id: str = field(default_factory=lambda: f"req_{int(time.time() * 1000)}")
75
76 def to_dict(self) -> dict[str, Any]:
77 """Convert to dictionary for JSON serialization.
78
79 Returns:
80 Dictionary representation of the request
81 """
82 return asdict(self)
83
84 @classmethod
85 def from_dict(cls, data: dict[str, Any]) -> "PackageRequest":
86 """Create PackageRequest from dictionary.
87
88 Args:
89 data: Dictionary with request fields
90
91 Returns:
92 PackageRequest instance
93
94 Raises:
95 TypeError: If required fields are missing or have wrong types
96 """
97 return cls(
98 project_dir=data["project_dir"],
99 environment=data.get("environment"),
100 timestamp=data["timestamp"],
101 caller_pid=data["caller_pid"],
102 caller_cwd=data["caller_cwd"],
103 request_id=data.get("request_id", f"req_{int(time.time() * 1000)}"),
104 )
105
106
107@typechecked

Callers 5

test_create_requestMethod · 0.90
test_to_dictMethod · 0.90
test_roundtripMethod · 0.90

Calls 1

timeMethod · 0.80

Tested by 4

test_create_requestMethod · 0.72
test_to_dictMethod · 0.72
test_roundtripMethod · 0.72