Beispiel #1
0
 def setModes(self):
     pty = self.pty
     attr = tty.tcgetattr(pty.fileno())
     for mode, modeValue in self.modes:
         if mode not in ttymodes.TTYMODES:
             continue
         ttyMode = ttymodes.TTYMODES[mode]
         if len(ttyMode) == 2:  # Flag.
             flag, ttyAttr = ttyMode
             if not hasattr(tty, ttyAttr):
                 continue
             ttyval = getattr(tty, ttyAttr)
             if modeValue:
                 attr[flag] = attr[flag] | ttyval
             else:
                 attr[flag] = attr[flag] & ~ttyval
         elif ttyMode == 'OSPEED':
             attr[tty.OSPEED] = getattr(tty, 'B%s' % (modeValue,))
         elif ttyMode == 'ISPEED':
             attr[tty.ISPEED] = getattr(tty, 'B%s' % (modeValue,))
         else:
             if not hasattr(tty, ttyMode):
                 continue
             ttyval = getattr(tty, ttyMode)
             attr[tty.CC][ttyval] = chr(modeValue)
     tty.tcsetattr(pty.fileno(), tty.TCSANOW, attr)
Beispiel #2
0
 def setModes(self):
     pty = self.pty
     attr = tty.tcgetattr(pty.fileno())
     for mode, modeValue in self.modes:
         if mode not in ttymodes.TTYMODES:
             continue
         ttyMode = ttymodes.TTYMODES[mode]
         if len(ttyMode) == 2:  # Flag.
             flag, ttyAttr = ttyMode
             if not hasattr(tty, ttyAttr):
                 continue
             ttyval = getattr(tty, ttyAttr)
             if modeValue:
                 attr[flag] = attr[flag] | ttyval
             else:
                 attr[flag] = attr[flag] & ~ttyval
         elif ttyMode == "OSPEED":
             attr[tty.OSPEED] = getattr(tty, "B%s" % (modeValue, ))
         elif ttyMode == "ISPEED":
             attr[tty.ISPEED] = getattr(tty, "B%s" % (modeValue, ))
         else:
             if not hasattr(tty, ttyMode):
                 continue
             ttyval = getattr(tty, ttyMode)
             attr[tty.CC][ttyval] = bytes((modeValue, ))
     tty.tcsetattr(pty.fileno(), tty.TCSANOW, attr)
Beispiel #3
0
 def setModes(self):
     pty = self.pty
     attr = tty.tcgetattr(pty.fileno())
     for mode, modeValue in self.modes:
         if not ttymodes.TTYMODES.has_key(mode): continue
         ttyMode = ttymodes.TTYMODES[mode]
         if len(ttyMode) == 2:  # flag
             flag, ttyAttr = ttyMode
             if not hasattr(tty, ttyAttr): continue
             ttyval = getattr(tty, ttyAttr)
             if modeValue:
                 attr[flag] = attr[flag] | ttyval
             else:
                 attr[flag] = attr[flag] & ~ttyval
         elif ttyMode == 'OSPEED':
             attr[tty.OSPEED] = getattr(tty, 'B%s' % modeValue)
         elif ttyMode == 'ISPEED':
             attr[tty.ISPEED] = getattr(tty, 'B%s' % modeValue)
         else:
             if not hasattr(tty, ttyMode): continue
             ttyval = getattr(tty, ttyMode)
             attr[tty.CC][ttyval] = chr(modeValue)
     tty.tcsetattr(pty.fileno(), tty.TCSANOW, attr)