From 68a38c39f7d620ff6e02e0ac08bd17faae095a82 Mon Sep 17 00:00:00 2001 From: Chuck <33324927+ChuckBuilds@users.noreply.github.com> Date: Sun, 19 Apr 2026 11:56:05 -0400 Subject: [PATCH] fix(web-ui-info): syntax error and init order crash on fresh install (#312) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two bugs that prevented the web-ui-info default plugin from loading: 1. Orphaned `except Exception` at line 203 with no matching `try` — caused a SyntaxError preventing the module from importing at all. Removed the orphan; the outer try/except already covers the block. 2. `_get_local_ip()` called in __init__ before `_ap_mode_cache_time` was initialized, causing AttributeError. Moved AP mode cache field initialization above the `_get_local_ip()` call. Co-authored-by: Chuck Co-authored-by: Claude Opus 4.6 (1M context) --- plugin-repos/web-ui-info/manager.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/plugin-repos/web-ui-info/manager.py b/plugin-repos/web-ui-info/manager.py index 7e434b61..24add05a 100644 --- a/plugin-repos/web-ui-info/manager.py +++ b/plugin-repos/web-ui-info/manager.py @@ -35,24 +35,24 @@ class WebUIInfoPlugin(BasePlugin): """Initialize the Web UI Info plugin.""" super().__init__(plugin_id, config, display_manager, cache_manager, plugin_manager) + # AP mode cache (must be initialized before _get_local_ip) + self._ap_mode_cached = False + self._ap_mode_cache_time = 0.0 + self._ap_mode_cache_ttl = 60.0 + # Get device hostname try: self.device_id = socket.gethostname() except Exception as e: self.logger.warning(f"Could not get hostname: {e}, using 'localhost'") self.device_id = "localhost" - + # Get device IP address self.device_ip = self._get_local_ip() - + # IP refresh tracking self.last_ip_refresh = time.time() - self.ip_refresh_interval = 300.0 # Refresh IP every 5 minutes - - # AP mode cache - self._ap_mode_cached = False - self._ap_mode_cache_time = 0.0 - self._ap_mode_cache_ttl = 60.0 # Cache AP mode check for 60 seconds + self.ip_refresh_interval = 300.0 # Rotation state self.current_display_mode = "hostname" # "hostname" or "ip" @@ -200,9 +200,7 @@ class WebUIInfoPlugin(BasePlugin): elif current_interface == "wlan0": self.logger.debug(f"Found WiFi IP: {ip} on {current_interface}") return ip - except Exception: - pass - + # Last resort: try hostname resolution (often returns 127.0.0.1) try: ip = socket.gethostbyname(socket.gethostname())