def runs_tcgetattr(): fd = os.open('.', 0, 0777) try: rtermios.tcgetattr(fd) except OSError, e: assert e.errno == errno.ENOTTY print "ok"
def runs_tcgetattr(): fd = os.open('.', 0, 0777) try: rtermios.tcgetattr(fd) except OSError as e: assert e.errno == errno.ENOTTY print "ok"
def runs_tcsetattr(): tp = rtermios.tcgetattr(2) a, b, c, d, e, f, g = tp rtermios.tcsetattr(2, rtermios.TCSANOW, (a, b, c, d, e, f, g)) time.sleep(.1) tp = rtermios.tcgetattr(2) assert tp[5] == f print "ok"
def f(): from rpython.rlib import rtermios import termios def check(fd, when, attributes): count = len([i for i in attributes[-1] if isinstance(i, int)]) assert count == 2 termios.tcsetattr = check attr = list(rtermios.tcgetattr(2)) attr[3] |= termios.ICANON rtermios.tcsetattr(2, termios.TCSANOW, attr)
def method_tcsetattr(self, space, fd): try: mode = tcgetattr(fd) except OSError as e: raise error_for_oserror(space, e) mode_w = [ space.newint(mode[0]), # iflag space.newint(mode[1]), # oflag space.newint(mode[2]), # cflag space.newint(mode[3]), # lflag space.newint(mode[4]), # ispeed space.newint(mode[5]), # ospeed space.newarray([space.newstr_fromstr(cc) for cc in mode[6]]) ] return space.newarray(mode_w)
def method_tcgetattr(self, space, fd): try: mode = tcgetattr(fd) except OSError as e: raise error_for_oserror(space, e) mode_w = [ space.newint(mode[0]), # iflag space.newint(mode[1]), # oflag space.newint(mode[2]), # cflag space.newint(mode[3]), # lflag space.newint(mode[4]), # ispeed space.newint(mode[5]), # ospeed space.newarray([space.newstr_fromstr(cc) for cc in mode[6]]) ] return space.newarray(mode_w)
def tcgetattr(space, w_fd): fd = space.c_filedescriptor_w(w_fd) try: tup = rtermios.tcgetattr(fd) except OSError as e: raise convert_error(space, e) iflag, oflag, cflag, lflag, ispeed, ospeed, cc = tup l_w = [space.newint(i) for i in [iflag, oflag, cflag, lflag, ispeed, ospeed]] # last one need to be chosen carefully cc_w = [space.newbytes(i) for i in cc] if lflag & rtermios.ICANON: cc_w[rtermios.VMIN] = space.newint(ord(cc[rtermios.VMIN][0])) cc_w[rtermios.VTIME] = space.newint(ord(cc[rtermios.VTIME][0])) w_cc = space.newlist(cc_w) l_w.append(w_cc) return space.newlist(l_w)
def tcgetattr(space, w_fd): fd = space.c_filedescriptor_w(w_fd) try: tup = rtermios.tcgetattr(fd) except OSError as e: raise convert_error(space, e) iflag, oflag, cflag, lflag, ispeed, ospeed, cc = tup l_w = [space.wrap(i) for i in [iflag, oflag, cflag, lflag, ispeed, ospeed]] # last one need to be chosen carefully cc_w = [space.wrap(i) for i in cc] if lflag & rtermios.ICANON: cc_w[rtermios.VMIN] = space.wrap(ord(cc[rtermios.VMIN][0])) cc_w[rtermios.VTIME] = space.wrap(ord(cc[rtermios.VTIME][0])) w_cc = space.newlist(cc_w) l_w.append(w_cc) return space.newlist(l_w)
def tcgetattr(space, w_fd): fd = space.c_filedescriptor_w(w_fd) try: tup = rtermios.tcgetattr(fd) except OSError, e: raise convert_error(space, e)
def runs_tcgetattr(): tpl = list(rtermios.tcgetattr(2)[:-1]) return str(tpl)