Skip to content

Commit

Permalink
use subprocess for stty reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Audionut committed Mar 1, 2025
1 parent fe2b1d3 commit 860352e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import traceback
import time
import gc
import subprocess
from src.trackersetup import tracker_class_map, api_trackers, other_api_trackers, http_trackers
from src.trackerhandle import process_trackers
from src.queuemanage import handle_queue
Expand Down Expand Up @@ -289,12 +290,14 @@ async def save_processed_file(log_file, file_path):

def reset_terminal():
"""Reset the terminal to a sane state."""
if os.name == "posix":
if os.name == "posix" and sys.stdin.isatty():
try:
if sys.stdin and sys.stdin.fileno() >= 0 and sys.stdin.isatty():
os.system("stty sane")
except (ValueError, OSError):
pass
subprocess.run(["stty", "sane"], check=True)
except (subprocess.CalledProcessError, FileNotFoundError):
try:
subprocess.run(["reset"], check=True) # Fallback if stty is unavailable
except (subprocess.CalledProcessError, FileNotFoundError):
pass


async def do_the_thing(base_dir):
Expand Down

0 comments on commit 860352e

Please sign in to comment.