From 8daecde20ebcd20c77c4b4cc7cd900846a488919 Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Tue, 5 May 2026 11:24:53 +0800 Subject: [PATCH] touchy: tolerate missing nc_files directory in filechooser filechooser.reload() called os.listdir(self.dir) with no error handling, which crashes touchy at startup when the hardcoded $HOME/linuxcnc/nc_files path does not exist (e.g. a fresh install, a CI runner with a clean $HOME, or a sysadmin who keeps NGC programs elsewhere). The traceback aborted the whole GUI before any window appeared. Catch OSError, log the path that could not be read, and continue with an empty file list. Touchy still starts; the user can browse to programs through the regular file menu and the quick-pick list populates as soon as files appear. Surfaced by ui-smoke testing (#3999) on a clean GitHub Actions $HOME. Closes #4005. --- src/emc/usr_intf/touchy/filechooser.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/emc/usr_intf/touchy/filechooser.py b/src/emc/usr_intf/touchy/filechooser.py index c4fa79d2932..71f78ca88f7 100644 --- a/src/emc/usr_intf/touchy/filechooser.py +++ b/src/emc/usr_intf/touchy/filechooser.py @@ -86,8 +86,12 @@ def down(self, b): self.populate() def reload(self, b): - self.files = os.listdir(self.dir) - self.files = [i for i in self.files if i.endswith('.ngc') and + try: + entries = os.listdir(self.dir) + except OSError as e: + print("touchy: filechooser cannot read %s: %s" % (self.dir, e)) + entries = [] + self.files = [i for i in entries if i.endswith('.ngc') and os.path.isfile(os.path.join(self.dir, i))] self.files.sort() self.selected = -1