touchy: don't crash on startup when nc_files dir is missing#4006
Open
grandixximo wants to merge 1 commit intoLinuxCNC:masterfrom
Open
touchy: don't crash on startup when nc_files dir is missing#4006grandixximo wants to merge 1 commit intoLinuxCNC:masterfrom
grandixximo wants to merge 1 commit intoLinuxCNC:masterfrom
Conversation
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 (LinuxCNC#3999) on a clean GitHub Actions $HOME. Closes LinuxCNC#4005.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lib/python/touchy/filechooser.py:reload() calls
os.listdir(self.dir)with no error handling, whereself.diris hardcoded to$HOME/linuxcnc/nc_files. If that directory does not exist (fresh install, clean$HOME, sysadmin keeping NGC programs elsewhere) theFileNotFoundErrorpropagates up and aborts touchy startup before any window appears.Catch
OSError, log the path that could not be read, continue with an empty file list. Touchy still starts; the user reaches programs through the normal file menu, and the quick-pick list populates the next timereload()is called once files exist.Closes #4005.
Test plan
HOME=/tmp/x linuxcnc -r configs/sim/touchy/touchy.ininow launches touchy with an empty quick-pick list and a stderr linetouchy: filechooser cannot read /tmp/x/linuxcnc/nc_files: ...mkdir -p $HOME/linuxcnc/nc_files); the workaround can be removed once this landsNotes
src/emc/usr_intf/touchy/filechooser.py. The build copies this intolib/python/touchy/; that copy is gitignored.