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

Method process_line

ci/util/json_rpc_handler.py:29–54  ·  view source on GitHub ↗

Process a line of output, extracting JSON-RPC responses. Args: line: Line of text from serial output Returns: Parsed JSON object if line contains valid RPC response, None otherwise

(self, line: str)

Source from the content-addressed store, hash-verified

27 self.raw_lines: list[str] = []
28
29 def process_line(self, line: str) -> dict[str, Any] | None:
30 """Process a line of output, extracting JSON-RPC responses.
31
32 Args:
33 line: Line of text from serial output
34
35 Returns:
36 Parsed JSON object if line contains valid RPC response, None otherwise
37 """
38 # Check if line starts with REMOTE: prefix
39 if not line.startswith(self.REMOTE_PREFIX):
40 return None
41
42 # Extract JSON portion (everything after prefix)
43 json_str = line[len(self.REMOTE_PREFIX) :].strip()
44 self.raw_lines.append(json_str)
45
46 # Parse JSON
47 try:
48 response = json.loads(json_str)
49 self.responses.append(response)
50 return response
51 except json.JSONDecodeError as e:
52 print(f"⚠️ Warning: Failed to parse REMOTE JSON: {e}")
53 print(f" Raw line: {json_str}")
54 return None
55
56 def get_responses(self) -> list[dict[str, Any]]:
57 """Get all parsed JSON-RPC responses.

Callers 3

run_monitorFunction · 0.95
send_and_matchMethod · 0.45
_wait_for_responseMethod · 0.45

Calls 2

printFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected