Skip to content

Commit 860352e

Browse files
committed
use subprocess for stty reset
1 parent fe2b1d3 commit 860352e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

upload.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import traceback
1414
import time
1515
import gc
16+
import subprocess
1617
from src.trackersetup import tracker_class_map, api_trackers, other_api_trackers, http_trackers
1718
from src.trackerhandle import process_trackers
1819
from src.queuemanage import handle_queue
@@ -289,12 +290,14 @@ async def save_processed_file(log_file, file_path):
289290

290291
def reset_terminal():
291292
"""Reset the terminal to a sane state."""
292-
if os.name == "posix":
293+
if os.name == "posix" and sys.stdin.isatty():
293294
try:
294-
if sys.stdin and sys.stdin.fileno() >= 0 and sys.stdin.isatty():
295-
os.system("stty sane")
296-
except (ValueError, OSError):
297-
pass
295+
subprocess.run(["stty", "sane"], check=True)
296+
except (subprocess.CalledProcessError, FileNotFoundError):
297+
try:
298+
subprocess.run(["reset"], check=True) # Fallback if stty is unavailable
299+
except (subprocess.CalledProcessError, FileNotFoundError):
300+
pass
298301

299302

300303
async def do_the_thing(base_dir):

0 commit comments

Comments
 (0)