Python tty.VTIME Examples

The following are 7 code examples of tty.VTIME(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tty , or try the search function .
Example #1
Source File: conch.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def _enterRawMode():
    global _inRawMode, _savedRawMode
    if _inRawMode:
        return
    fd = sys.stdin.fileno()
    try:
        old = tty.tcgetattr(fd)
        new = old[:]
    except:
        log.msg('not a typewriter!')
    else:
        # iflage
        new[0] = new[0] | tty.IGNPAR
        new[0] = new[0] & ~(tty.ISTRIP | tty.INLCR | tty.IGNCR | tty.ICRNL |
                            tty.IXON | tty.IXANY | tty.IXOFF)
        if hasattr(tty, 'IUCLC'):
            new[0] = new[0] & ~tty.IUCLC

        # lflag
        new[3] = new[3] & ~(tty.ISIG | tty.ICANON | tty.ECHO | tty.ECHO |
                            tty.ECHOE | tty.ECHOK | tty.ECHONL)
        if hasattr(tty, 'IEXTEN'):
            new[3] = new[3] & ~tty.IEXTEN

        #oflag
        new[1] = new[1] & ~tty.OPOST

        new[6][tty.VMIN] = 1
        new[6][tty.VTIME] = 0

        _savedRawMode = old
        tty.tcsetattr(fd, tty.TCSANOW, new)
        #tty.setraw(fd)
        _inRawMode = 1 
Example #2
Source File: keyboard.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def main(raw_args):
  parser = argparse.ArgumentParser(
      description="Use your keyboard as your phone's keyboard.")
  logging_common.AddLoggingArguments(parser)
  script_common.AddDeviceArguments(parser)
  args = parser.parse_args(raw_args)

  logging_common.InitializeLogging(args)

  devices = script_common.GetDevices(args.devices, None)
  if len(devices) > 1:
    raise MultipleDevicesError(devices)

  def next_char():
    while True:
      yield sys.stdin.read(1)

  try:
    fd = sys.stdin.fileno()

    # See man 3 termios for more info on what this is doing.
    old_attrs = termios.tcgetattr(fd)
    new_attrs = copy.deepcopy(old_attrs)
    new_attrs[tty.LFLAG] = new_attrs[tty.LFLAG] & ~(termios.ICANON)
    new_attrs[tty.CC][tty.VMIN] = 1
    new_attrs[tty.CC][tty.VTIME] = 0
    termios.tcsetattr(fd, termios.TCSAFLUSH, new_attrs)

    Keyboard(devices[0], next_char())
  finally:
    termios.tcsetattr(fd, termios.TCSAFLUSH, old_attrs)
  return 0 
Example #3
Source File: keyboard.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def main(raw_args):
  parser = argparse.ArgumentParser(
      description="Use your keyboard as your phone's keyboard.")
  logging_common.AddLoggingArguments(parser)
  script_common.AddDeviceArguments(parser)
  args = parser.parse_args(raw_args)

  logging_common.InitializeLogging(args)

  devices = script_common.GetDevices(args.devices, None)
  if len(devices) > 1:
    raise MultipleDevicesError(devices)

  def next_char():
    while True:
      yield sys.stdin.read(1)

  try:
    fd = sys.stdin.fileno()

    # See man 3 termios for more info on what this is doing.
    old_attrs = termios.tcgetattr(fd)
    new_attrs = copy.deepcopy(old_attrs)
    new_attrs[tty.LFLAG] = new_attrs[tty.LFLAG] & ~(termios.ICANON)
    new_attrs[tty.CC][tty.VMIN] = 1
    new_attrs[tty.CC][tty.VTIME] = 0
    termios.tcsetattr(fd, termios.TCSAFLUSH, new_attrs)

    Keyboard(devices[0], next_char())
  finally:
    termios.tcsetattr(fd, termios.TCSAFLUSH, old_attrs)
  return 0 
Example #4
Source File: keyboard.py    From Jandroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def main(raw_args):
  parser = argparse.ArgumentParser(
      description="Use your keyboard as your phone's keyboard.")
  logging_common.AddLoggingArguments(parser)
  script_common.AddDeviceArguments(parser)
  args = parser.parse_args(raw_args)

  logging_common.InitializeLogging(args)

  devices = script_common.GetDevices(args.devices, None)
  if len(devices) > 1:
    raise MultipleDevicesError(devices)

  def next_char():
    while True:
      yield sys.stdin.read(1)

  try:
    fd = sys.stdin.fileno()

    # See man 3 termios for more info on what this is doing.
    old_attrs = termios.tcgetattr(fd)
    new_attrs = copy.deepcopy(old_attrs)
    new_attrs[tty.LFLAG] = new_attrs[tty.LFLAG] & ~(termios.ICANON)
    new_attrs[tty.CC][tty.VMIN] = 1
    new_attrs[tty.CC][tty.VTIME] = 0
    termios.tcsetattr(fd, termios.TCSAFLUSH, new_attrs)

    Keyboard(devices[0], next_char())
  finally:
    termios.tcsetattr(fd, termios.TCSAFLUSH, old_attrs)
  return 0 
Example #5
Source File: conch.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def _enterRawMode():
    global _inRawMode, _savedRawMode
    if _inRawMode:
        return
    fd = sys.stdin.fileno()
    try:
        old = tty.tcgetattr(fd)
        new = old[:]
    except:
        log.msg('not a typewriter!')
    else:
        # iflage
        new[0] = new[0] | tty.IGNPAR
        new[0] = new[0] & ~(tty.ISTRIP | tty.INLCR | tty.IGNCR | tty.ICRNL |
                            tty.IXON | tty.IXANY | tty.IXOFF)
        if hasattr(tty, 'IUCLC'):
            new[0] = new[0] & ~tty.IUCLC

        # lflag
        new[3] = new[3] & ~(tty.ISIG | tty.ICANON | tty.ECHO | tty.ECHO |
                            tty.ECHOE | tty.ECHOK | tty.ECHONL)
        if hasattr(tty, 'IEXTEN'):
            new[3] = new[3] & ~tty.IEXTEN

        #oflag
        new[1] = new[1] & ~tty.OPOST

        new[6][tty.VMIN] = 1
        new[6][tty.VTIME] = 0

        _savedRawMode = old
        tty.tcsetattr(fd, tty.TCSANOW, new)
        #tty.setraw(fd)
        _inRawMode = 1 
Example #6
Source File: conch.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def _enterRawMode():
    global _inRawMode, _savedMode
    if _inRawMode:
        return
    fd = sys.stdin.fileno()
    try:
        old = tty.tcgetattr(fd)
        new = old[:]
    except:
        log.msg('not a typewriter!')
    else:
        # iflage
        new[0] = new[0] | tty.IGNPAR
        new[0] = new[0] & ~(tty.ISTRIP | tty.INLCR | tty.IGNCR | tty.ICRNL |
                            tty.IXON | tty.IXANY | tty.IXOFF)
        if hasattr(tty, 'IUCLC'):
            new[0] = new[0] & ~tty.IUCLC

        # lflag
        new[3] = new[3] & ~(tty.ISIG | tty.ICANON | tty.ECHO | tty.ECHO |
                            tty.ECHOE | tty.ECHOK | tty.ECHONL)
        if hasattr(tty, 'IEXTEN'):
            new[3] = new[3] & ~tty.IEXTEN

        #oflag
        new[1] = new[1] & ~tty.OPOST

        new[6][tty.VMIN] = 1
        new[6][tty.VTIME] = 0

        _savedMode = old
        tty.tcsetattr(fd, tty.TCSANOW, new)
        #tty.setraw(fd)
        _inRawMode = 1 
Example #7
Source File: conch.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def _enterRawMode():
    global _inRawMode, _savedMode
    if _inRawMode:
        return
    fd = sys.stdin.fileno()
    try:
        old = tty.tcgetattr(fd)
        new = old[:]
    except:
        log.msg('not a typewriter!')
    else:
        # iflage
        new[0] = new[0] | tty.IGNPAR
        new[0] = new[0] & ~(tty.ISTRIP | tty.INLCR | tty.IGNCR | tty.ICRNL |
                            tty.IXON | tty.IXANY | tty.IXOFF)
        if hasattr(tty, 'IUCLC'):
            new[0] = new[0] & ~tty.IUCLC

        # lflag
        new[3] = new[3] & ~(tty.ISIG | tty.ICANON | tty.ECHO | tty.ECHO | 
                            tty.ECHOE | tty.ECHOK | tty.ECHONL)
        if hasattr(tty, 'IEXTEN'):
            new[3] = new[3] & ~tty.IEXTEN

        #oflag
        new[1] = new[1] & ~tty.OPOST

        new[6][tty.VMIN] = 1
        new[6][tty.VTIME] = 0

        _savedMode = old
        tty.tcsetattr(fd, tty.TCSANOW, new)
        #tty.setraw(fd)
        _inRawMode = 1