From 3954af87bf0b529ea3de411cccfc83f0b2c2f3d9 Mon Sep 17 00:00:00 2001 From: Lukáš Růžička Date: May 29 2025 09:26:13 +0000 Subject: Catch termios errors on non-terminal The application uses termios to flush unwanted input that might have happened before the application got ready to accept users' choices. However, termios calls would end up with the error 25, if the application was not run in the terminal but in an IDE or similar tool. Previously, we have created an exception for this, but the caught error was an incorrect one, so termios would still complain. This should be the correct solution to catch the error. I tested it in IDLE and in Spyder and it works as expected by skipping the termios calls if the application does not run in a terminal session. Fixes: https://pagure.io/fedora-easy-karma/issue/57 --- diff --git a/fedora-easy-karma.py b/fedora-easy-karma.py index 7f4f0a8..13df029 100755 --- a/fedora-easy-karma.py +++ b/fedora-easy-karma.py @@ -417,8 +417,8 @@ class FedoraEasyKarma(object): # therefore we need to use the exception here. try: termios.tcflush(sys.stdin, termios.TCIFLUSH) - except io.UnsupportedOperation: - self.warning("We are not on a terminal, terminal flushing was skipped.") + except termios.error as e: + self.warning(f"Error: {e}. It seems that we are not on a terminal - skipping terminal flushing.") pkghelper = PkgHelper()