Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.
Python adbadblockandroid-tvandroid-tv-launcherapple-tvbloatware-removalclaude-codedebloatfire-tvgoogle-tvlauncherprivacysmart-tvsony-braviatclvibe-codingxiaomi
tools: tv.py reads an indented screencap status line instead of crashing on "c=0"
unfoldcrod7c440778d86
diff --git a/tests/test_tv_screenshot.py b/tests/test_tv_screenshot.pyindex 2158656b6..83209dd82 100644--- a/tests/test_tv_screenshot.py+++ b/tests/test_tv_screenshot.py@@ -146,6 +146,23 @@ class ScreenshotTest(unittest.TestCase):self.assertNotIn("pull", [c[0] for c in device.calls])self.assertEqual(device.calls[-1], ("shell", f"rm -f {TV.SHOT_REMOTE}"))+ def test_an_indented_rc_line_is_parsed_not_crashed(self):+ # The match strips the status line (a CRLF firmware leaves a trailing "\r"), so the slice that+ # reads the number has to strip it too: on a line that comes back indented, `line[3:]` reads+ # "c=0" and int() raises before the capture is ever used. The strip keeps "rc=0" -> 0.+ with tempfile.TemporaryDirectory() as tmp:+ local = Path(tmp) / "home.png"+ code, _, err, _ = self.run_tv(["--screenshot", str(local)], screencap_says=" rc=0\n")+ self.assertEqual(code, 0, err)+ self.assertEqual(local.read_bytes(), PNG)++ def test_an_indented_failing_rc_is_read_as_the_failure_it_is(self):+ with tempfile.TemporaryDirectory() as tmp:+ code, _, err, _ = self.run_tv(["--screenshot", str(Path(tmp) / "x.png")],+ capture=b"", screencap_says=" rc=127\n")+ self.assertEqual(code, 1)+ self.assertIn("exit status 127", err)+def test_a_damaged_pull_is_not_passed_off_as_a_png(self):with tempfile.TemporaryDirectory() as tmp:code, _, err, _ = self.run_tv(["--screenshot", str(Path(tmp) / "home.png")], capture=b"garbage")diff --git a/tools/tv.py b/tools/tv.pyindex ea82810f4..ca22629d1 100644--- a/tools/tv.py+++ b/tools/tv.py@@ -204,7 +204,7 @@ def screenshot(dev, local, keys=(), wait=1.0):# The exit status tells a capture that failed (no file to pull) from one that came back empty: with# Netflix in front a TCL C755 exits 1 and leaves a 0-byte file, which is the empty case below.said = dev.shell(f"rm -f {SHOT_REMOTE}; screencap -p {SHOT_REMOTE}; echo rc=$?", read_timeout_s=120.0)- rc = next((int(line[3:]) for line in said.splitlines() if re.fullmatch(r"rc=-?\d+", line.strip())), None)+ rc = next((int(line.strip()[3:]) for line in said.splitlines() if re.fullmatch(r"rc=-?\d+", line.strip())), None)if rc not in (None, 0, 1):other = " ".join(line.strip() for line in said.splitlines() if line.strip() and not line.startswith("rc="))dev.shell(f"rm -f {SHOT_REMOTE}", read_timeout_s=60.0)