From 76bea74a08700fd4f9889252e6ae6fba3f17de9c Mon Sep 17 00:00:00 2001 From: Ryein Goddard Date: Mon, 7 Oct 2024 01:29:49 -0700 Subject: [PATCH] Handle situations where terminalsize cannot be found --- fetch-macOS-v2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fetch-macOS-v2.py b/fetch-macOS-v2.py index 2d71189..5ef14a7 100755 --- a/fetch-macOS-v2.py +++ b/fetch-macOS-v2.py @@ -234,7 +234,10 @@ def save_image(url, sess, filename='', directory=''): break fh.write(chunk) size += len(chunk) - terminalsize = max(os.get_terminal_size().columns - TERMINAL_MARGIN, 0) + try: + terminalsize = max(os.get_terminal_size().columns - TERMINAL_MARGIN, 0) + except OSError: + terminalsize = 80 if oldterminalsize != terminalsize: print(f'\r{"":<{terminalsize}}', end='') oldterminalsize = terminalsize