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: manage.py set refuses a --theme folder that is not there, instead of making it and pushing it
xbsheng3dba40cffe95
diff --git a/tests/test_manage_set.py b/tests/test_manage_set.pyindex db31043e3..efacf38fe 100644--- a/tests/test_manage_set.py+++ b/tests/test_manage_set.py@@ -296,6 +296,29 @@ class SetThemeFolderTest(unittest.TestCase):self.assertIn(f"{afile} is a file, not a folder", refusal)self.push.assert_not_called()+ def test_a_theme_folder_that_is_not_there_is_named_and_not_made(self):+ # --theme with a typo used to be mkdir -p'd, given a one-key config.json and pushed: the push replaces+ # the theme on the TV and empties the wallpapers/ it pushed before, so the theme the owner had was gone+ # and the TV showed one key's worth of it. Resolved first, as manage resolves the path it is given.+ missing = (Path(self.tmp.name) / "my-them").resolve()+ with mock.patch("sys.stdout"):+ with self.assertRaises(SystemExit, msg="a folder that is not there was accepted") as stop:+ manage.cmd_set("dock_band", "true", str(missing))+ refusal = str(stop.exception.code)+ self.assertIn(f"{missing} is not there", refusal)+ self.assertIn("--theme", refusal)+ self.assertIn("Nothing was written or pushed", refusal)+ self.assertFalse(missing.exists(), "a folder that is not there must not be made")+ self.push.assert_not_called()++ def test_an_empty_folder_of_their_own_is_still_started(self):+ # The other half: a folder that exists with no config.json yet is where set starts the file.+ mine = Path(self.tmp.name) / "fresh-theme"+ mine.mkdir()+ self.assertIsNone(self.set_key(folder=mine))+ self.assertIs(json.loads((mine / "config.json").read_text(encoding="utf-8"))["dock_band"], True)+ self.push.assert_called_once()+def test_a_write_it_cannot_make_is_named(self):# A file in the middle of the path: mkdir cannot create a folder under one.afile = Path(self.tmp.name) / "not-a-folder"diff --git a/themes/README.md b/themes/README.mdindex 8bed449ed..622869672 100644--- a/themes/README.md+++ b/themes/README.md@@ -15,7 +15,10 @@ powershell -ExecutionPolicy Bypass -File tools\theme.ps1 -TvHost 192.168.1.50 th`tools/venv/bin/python -I tools/manage.py list themes` and `list switches` list them from this file, `show <name>` gives one with itsscreenshot, and `manage.py set <switch> <value> --theme <your folder>` writes a key into a theme folder of your ownand pushes it with `theme.sh`. The folder has to be outside this checkout: one under `themes/` or `examples/` is-refused (copy a theme first), and a `config.json` it cannot read is named before anything is written or pushed.+refused (copy a theme first), a `config.json` it cannot read is named before anything is written or pushed, and a+folder that is not there is refused too rather than made - an empty folder of your own is fine, `set` starts the+`config.json` in it. Pushing replaces the theme on the TV and empties the pictures it pushed before, so a mistyped+path would leave a one-key theme behind.| Theme | What it does | Screenshot ||---|---|---|diff --git a/tools/manage.py b/tools/manage.pyindex 354a6c9bc..b613d5295 100644--- a/tools/manage.py+++ b/tools/manage.py@@ -21,7 +21,9 @@ JSON object is named before the key is written, and a write it cannot make saysset's own arguments are read first: a switch without a value, a --theme without the folder behind it, and a wordleft over are answered with the usage line and exit 2 before a theme folder is read or written. list, status,show, install and remove read their own words the same way, before anything is read from this checkout or asked-of the TV.+of the TV. A --theme folder that is not there is refused by name, not made: set starts a config.json in a folder+of your own that exists, and the push it ends with replaces the theme on the TV and empties that theme's+wallpapers, so a mistyped path would leave a one-key theme behind.Exit status: 0 the command ran, 1 a command on the TV or a script this checkout runs failed, 2 the command lineasked for something this script does not do - a command it does not have, or a word the command would drop - which@@ -254,7 +256,8 @@ def json_kind(value):def own_folder_problem(folder):- """Why set may not write into `folder`, or None: it is one of the folders this checkout ships, or a file."""+ """Why set may not write into `folder`, or None: it is one of the folders this checkout ships, a file, or+ not there at all."""for name in PROJECT_FOLDERS:project = ROOT / nameif folder == project or project in folder.parents:@@ -262,6 +265,21 @@ def own_folder_problem(folder):f"so copy one somewhere else first. Nothing was written or pushed.")if folder.exists() and not folder.is_dir():return f"{folder} is a file, not a folder: --theme takes a theme folder of your own."+ if not folder.exists():+ # A path with a file in the middle of it cannot be made at all, which is not a typo to point at the+ # folder for: name the file that is in the way, as the write used to.+ for parent in folder.parents:+ if parent.exists() and not parent.is_dir():+ return f"cannot write {folder / 'config.json'}: {parent} is a file, not a folder. Nothing was pushed."+ # mkdir(parents=True) used to make whatever a typo named, write one key into it and push it: the push+ # replaces the theme on the TV and empties the wallpapers/ collection it pushed last time, so a+ # mistyped path left a one-key theme on a TV whose theme and pictures were gone. A folder of their own+ # that exists is still started (no config.json yet is fine); a path that is not there is not.+ return (f"{folder} is not there: --theme takes a theme folder of your own, and set writes into one that "+ f"exists - an empty folder is fine, it starts the config.json. A path that is not there is "+ f"usually a typo, and the push set ends with replaces the theme on the TV and empties its "+ f"wallpapers, so a mistyped path would leave a one-key theme there. "+ f"Nothing was written or pushed.")return None