tty

Return normal terminal input when using tty, sys, terminos

Return normal terminal input when using tty, sys, terminos Question: I’m working on a little project which requiers input without "pausing" for each time. Without completely understanding how it works, I used some code that I found online. import tty, sys, termios while True: filedescriptors = termios.tcgetattr(sys.stdin) tty.setcbreak(sys.stdin) dir_inp = 0 while 1: dir_inp = …

Total answers: 1

Capture output as a tty in python

Capture output as a tty in python Question: I have a executable which requires a tty (as stdin and stderr), and want to be able to test it. I want to input stdin, and capture the output of stdout and stderr, here’s an example script: # test.py import sys print(“stdin: {}”.format(sys.stdin.isatty())) print(“stdout: {}”.format(sys.stdout.isatty())) print(“stderr: {}”.format(sys.stderr.isatty())) …

Total answers: 1

Run interactive Bash with popen and a dedicated TTY Python

Run interactive Bash with popen and a dedicated TTY Python Question: I need to run an interactive Bash instance in a separated process in Python with it’s own dedicated TTY (I can’t use pexpect). I used this code snippet I commonly see used in similar programs: master, slave = pty.openpty() p = subprocess.Popen([“/bin/bash”, “-i”], stdin=slave, …

Total answers: 3

Python reading and writing to tty

Python reading and writing to tty Question: BACKGROUND: If you want, skip to the problem section I am working on a front end for test equipment. The purpose of the front end is to make it easier to write long test scripts. Pretty much just make them more human readable and writable. The equipment will …

Total answers: 3

Python in Emacs shell-mode turns on stty echo and breaks C-d

Python in Emacs shell-mode turns on stty echo and breaks C-d Question: When I run an interactive Python inside an Emacs shell buffer (M-x shell), it does two surprising things to the TTY. First, it turns on input echo, which persists after Python exits, until I do stty -echo. Secondly, it doesn’t accept C-d (or …

Total answers: 3

Why is printing to stdout so slow? Can it be sped up?

Why is printing to stdout so slow? Can it be sped up? Question: I’ve always been amazed/frustrated with how long it takes to simply output to the terminal with a print statement. After some recent painfully slow logging I decided to look into it and was quite surprised to find that almost all the time …

Total answers: 6