From eb6474fc75b932807aee0b86ab21d9289fa70f67 Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Wed, 27 Dec 2017 07:42:18 +0100 Subject: [PATCH] handle termios failure --- spotify_ripper/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spotify_ripper/main.py b/spotify_ripper/main.py index fd8a22d..c03c952 100644 --- a/spotify_ripper/main.py +++ b/spotify_ripper/main.py @@ -591,9 +591,12 @@ def check_uri_args(): # wait for ripping thread to finish if not args.has_log: - stdin_settings = termios.tcgetattr(sys.stdin) + try: + stdin_settings = termios.tcgetattr(sys.stdin) + except termios.error: + stdin_settings = None try: - if not args.has_log: + if not args.has_log and stdin_settings: tty.setcbreak(sys.stdin.fileno()) while ripper.isAlive(): @@ -611,7 +614,7 @@ def check_uri_args(): print("\n" + Fore.RED + "Aborting..." + Fore.RESET) abort() finally: - if not args.has_log: + if not args.has_log and stdin_settings: termios.tcsetattr(sys.stdin, termios.TCSADRAIN, stdin_settings) if __name__ == '__main__':