From bdd0222a1cec451fe3bf37e721cca7409877bf61 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Sun, 24 Jul 2022 17:16:34 -0400 Subject: [PATCH] machine: handle exception if iwgetid fails Signed-off-by: Eric Callahan --- moonraker/components/machine.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/moonraker/components/machine.py b/moonraker/components/machine.py index 526643c..87231a2 100644 --- a/moonraker/components/machine.py +++ b/moonraker/components/machine.py @@ -115,7 +115,10 @@ class Machine: shell_cmd: SCMDComp = self.server.load_component( config, 'shell_command') self.addr_cmd = shell_cmd.build_shell_command("ip -json address") - self.iwgetid_cmd = shell_cmd.build_shell_command("iwgetid") + iwgetbin = "/sbin/iwgetid" + if not pathlib.Path(iwgetbin).exists(): + iwgetbin = "iwgetid" + self.iwgetid_cmd = shell_cmd.build_shell_command(iwgetbin) self.init_evt = asyncio.Event() def _update_log_rollover(self, log: bool = False) -> None: @@ -448,8 +451,13 @@ class Machine: async def _get_wifi_interfaces(self) -> Dict[str, Any]: # get wifi interfaces + shell_cmd: SCMDComp = self.server.lookup_component('shell_command') wifi_intfs: Dict[str, Any] = {} - resp = await self.iwgetid_cmd.run_with_response(log_complete=False) + try: + resp = await self.iwgetid_cmd.run_with_response(log_complete=False) + except shell_cmd.error: + logging.exception("Failed to run 'iwgetid' command") + return {} if resp: for line in resp.split("\n"): parts = line.strip().split(maxsplit=1)