Example #1
0
def tcsetattr(space, w_fd, when, w_attributes):
    fd = space.c_filedescriptor_w(w_fd)
    if not space.isinstance_w(w_attributes, space.w_list) or \
            space.len_w(w_attributes) != 7:
        raise OperationError(
            space.w_TypeError,
            space.wrap("tcsetattr, arg 3: must be 7 element list"))
    w_iflag, w_oflag, w_cflag, w_lflag, w_ispeed, w_ospeed, w_cc = \
             space.unpackiterable(w_attributes, expected_length=7)
    w_builtin = space.getbuiltinmodule('__builtin__')
    cc = []
    for w_c in space.unpackiterable(w_cc):
        if space.isinstance_w(w_c, space.w_int):
            ch = space.call_function(
                space.getattr(w_builtin, space.wrap('chr')), w_c)
            cc.append(space.str_w(ch))
        else:
            cc.append(space.str_w(w_c))
    tup = (space.int_w(w_iflag), space.int_w(w_oflag), space.int_w(w_cflag),
           space.int_w(w_lflag), space.int_w(w_ispeed), space.int_w(w_ospeed),
           cc)
    try:
        rtermios.tcsetattr(fd, when, tup)
    except OSError, e:
        raise convert_error(space, e)
Example #2
0
 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"
Example #3
0
 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"
Example #4
0
 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)
Example #5
0
        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)
Example #6
0
 def method_tcsetattr(self, space, fd, when, mode_w):
     cc = [space.str_w(w_char) for w_char in space.listview(mode_w[6])]
     mode = (
         space.int_w(mode_w[0]),  # iflag
         space.int_w(mode_w[1]),  # oflag
         space.int_w(mode_w[2]),  # cflag
         space.int_w(mode_w[3]),  # lflag
         space.int_w(mode_w[4]),  # ispeed
         space.int_w(mode_w[5]),  # ospeed
         cc)
     try:
         tcsetattr(fd, when, mode)
     except OSError as e:
         raise error_for_oserror(space, e)
     return self
Example #7
0
 def method_tcsetattr(self, space, fd, when, mode_w):
     cc = [space.str_w(w_char) for w_char in space.listview(mode_w[6])]
     mode = (
         space.int_w(mode_w[0]),  # iflag
         space.int_w(mode_w[1]),  # oflag
         space.int_w(mode_w[2]),  # cflag
         space.int_w(mode_w[3]),  # lflag
         space.int_w(mode_w[4]),  # ispeed
         space.int_w(mode_w[5]),  # ospeed
         cc
     )
     try:
         tcsetattr(fd, when, mode)
     except OSError as e:
         raise error_for_oserror(space, e)
     return self
Example #8
0
def tcsetattr(space, w_fd, when, w_attributes):
    fd = space.c_filedescriptor_w(w_fd)
    if not space.isinstance_w(w_attributes, space.w_list) or \
            space.len_w(w_attributes) != 7:
        raise OperationError(space.w_TypeError, space.wrap(
            "tcsetattr, arg 3: must be 7 element list"))
    w_iflag, w_oflag, w_cflag, w_lflag, w_ispeed, w_ospeed, w_cc = \
             space.unpackiterable(w_attributes, expected_length=7)
    cc = []
    for w_c in space.unpackiterable(w_cc):
        if space.isinstance_w(w_c, space.w_int):
            w_c = space.call_function(space.w_bytes, space.newlist([w_c]))
        cc.append(space.bytes_w(w_c))
    tup = (space.int_w(w_iflag), space.int_w(w_oflag),
           space.int_w(w_cflag), space.int_w(w_lflag),
           space.int_w(w_ispeed), space.int_w(w_ospeed), cc)
    try:
        rtermios.tcsetattr(fd, when, tup)
    except OSError, e:
        raise convert_error(space, e)
Example #9
0
def tcsetattr(space, w_fd, when, w_attributes):
    fd = space.c_filedescriptor_w(w_fd)
    w_iflag, w_oflag, w_cflag, w_lflag, w_ispeed, w_ospeed, w_cc = \
             space.unpackiterable(w_attributes, expected_length=7)
    w_builtin = space.getbuiltinmodule('__builtin__')
    cc = []
    for w_c in space.unpackiterable(w_cc):
        if space.isinstance_w(w_c, space.w_int):
            ch = space.call_function(space.getattr(w_builtin,
                                          space.wrap('chr')), w_c)
            cc.append(space.str_w(ch))
        else:
            cc.append(space.str_w(w_c))
    tup = (space.int_w(w_iflag), space.int_w(w_oflag),
           space.int_w(w_cflag), space.int_w(w_lflag),
           space.int_w(w_ispeed), space.int_w(w_ospeed), cc)
    try:
        rtermios.tcsetattr(fd, when, tup)
    except OSError, e:
        raise convert_error(space, e)