Skip to content
Snippets Groups Projects
Commit e66443b5 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

New module.

(__all__): New constant.
(RAW): New constant.
(CBREAK): New constant.
(COOKED): New constant.
(user): New class.
(user.__init__): New method.
(user.send): New method.
(user.close): New method.
parent 369ac3cc
No related branches found
No related tags found
No related merge requests found
import sys
import tty
import termios
import pcl_expect
__all__ = [
"user",
"RAW",
"CBREAK",
"COOKED",
]
RAW = 0
CBREAK = 1
COOKED = 2
class user(pcl_expect.expectable):
def __init__(self, mode = CBREAK):
fd = sys.stdin.fileno()
self.__mode = termios.tcgetattr(fd)
if mode == COOKED:
# Let's hope the fd already is in cooked mode...
pass
elif mode == CBREAK:
tty.setcbreak(fd)
elif mode == RAW:
tty.setraw(fd)
else:
raise pcl_expect.BadArgs()
pcl_expect.expectable.__init__(self, fd)
def send(self, s):
sys.stdout.write(s)
sys.stdout.flush()
def close(self):
termios.tcsetattr(self.fileno(), termios.TCSAFLUSH, self.__mode)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment