From 1f0c0c2bf26b4b6911f8edd5a2dda31bca8f05c2 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Thu, 16 Apr 2026 14:33:08 -0600 Subject: [PATCH] Fix #166 --- codexctl/device.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/codexctl/device.py b/codexctl/device.py index 97481e2..226ac93 100644 --- a/codexctl/device.py +++ b/codexctl/device.py @@ -502,6 +502,8 @@ def get_device_status(self) -> tuple[str | None, str, str, str, str]: tuple: Beta status, old_update_engine, current version, version_id, backup version (in that order) """ old_update_engine = True + version_id = "" + beta_contents = "" if self.client: self.logger.debug("Connecting to FTP") @@ -509,12 +511,20 @@ def get_device_status(self) -> tuple[str | None, str, str, str, str]: self.logger.debug("Connected") xochitl_version, old_update_engine = self._read_version_from_path(ftp) + def exists(path:str) -> bool: + try: + _ = ftp.stat(path) + return True + except (FileNotFoundError, IOError): + return False - with ftp.file("/etc/version") as file: - version_id = file.read().decode("utf-8").strip("\n") + if exists("/etc/version"): + with ftp.file("/etc/version") as file: + version_id = file.read().decode("utf-8").strip("\n") - with ftp.file("/home/root/.config/remarkable/xochitl.conf") as file: - beta_contents = file.read().decode("utf-8") + if exists("/home/root/.config/remarkable/xochitl.conf"): + with ftp.file("/home/root/.config/remarkable/xochitl.conf") as file: + beta_contents = file.read().decode("utf-8") else: xochitl_version, old_update_engine = self._read_version_from_path() @@ -522,14 +532,10 @@ def get_device_status(self) -> tuple[str | None, str, str, str, str]: if os.path.exists("/etc/version"): with open("/etc/version", encoding="utf-8") as file: version_id = file.read().rstrip() - else: - version_id = "" if os.path.exists("/home/root/.config/remarkable/xochitl.conf"): with open("/home/root/.config/remarkable/xochitl.conf", encoding="utf-8") as file: beta_contents = file.read().rstrip() - else: - beta_contents = "" beta_possible = re.search("(?<=GROUP=).*", beta_contents) beta = "Release"