當前位置: 首頁>>代碼示例>>Python>>正文


Python termios.TCSAFLUSH屬性代碼示例

本文整理匯總了Python中termios.TCSAFLUSH屬性的典型用法代碼示例。如果您正苦於以下問題:Python termios.TCSAFLUSH屬性的具體用法?Python termios.TCSAFLUSH怎麽用?Python termios.TCSAFLUSH使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在termios的用法示例。


在下文中一共展示了termios.TCSAFLUSH屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def __init__(self):
        '''Creates a KBHit object that you can call to do various keyboard things.
        '''

        if os.name == 'nt':
            pass
        
        else:
    
            # Save the terminal settings
            self.fd = sys.stdin.fileno()
            self.new_term = termios.tcgetattr(self.fd)
            self.old_term = termios.tcgetattr(self.fd)
    
            # New terminal setting unbuffered
            self.new_term[3] = (self.new_term[3] & ~termios.ICANON & ~termios.ECHO)
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.new_term)
    
            # Support normal-terminal reset at exit
            atexit.register(self.set_normal_term) 
開發者ID:sonofeft,項目名稱:RocketCEA,代碼行數:22,代碼來源:keyboard_hit.py

示例2: __init__

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def __init__(self):
        '''Creates a KBHit object that you can call to do various keyboard things.
        '''

        if os.name == 'nt':
            pass

        else:

            # Save the terminal settings
            self.fd = sys.stdin.fileno()
            self.new_term = termios.tcgetattr(self.fd)
            self.old_term = termios.tcgetattr(self.fd)

            # New terminal setting unbuffered
            self.new_term[3] = (self.new_term[3] & ~termios.ICANON & ~termios.ECHO)
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.new_term)

            # Support normal-terminal reset at exit
            atexit.register(self.set_normal_term) 
開發者ID:fandoghpaas,項目名稱:fandogh-cli,代碼行數:22,代碼來源:utils.py

示例3: wait_key

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def wait_key():
    """ Wait for a key press on the console and return it. """
    result = None
    if os.name == 'nt':
        result = input("Press Enter to continue...")
    else:
        import termios
        fd = sys.stdin.fileno()

        oldterm = termios.tcgetattr(fd)
        newattr = termios.tcgetattr(fd)
        newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
        termios.tcsetattr(fd, termios.TCSANOW, newattr)

        try:
            result = sys.stdin.read(1)
        except IOError:
            pass
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)

    return result 
開發者ID:donwayo,項目名稱:ebayKleinanzeigen,代碼行數:24,代碼來源:kleinanzeigen.py

示例4: getch

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def getch():
        """getch function
        """
        fd = sys.stdin.fileno()
        old = termios.tcgetattr(fd)
        new = termios.tcgetattr(fd)
        new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
        new[6][termios.VMIN] = 1
        new[6][termios.VTIME] = 0
        termios.tcsetattr(fd, termios.TCSANOW, new)
        key = None
        try:
            key = os.read(fd, 80)
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, old)
        return key 
開發者ID:mysql,項目名稱:mysql-utilities,代碼行數:18,代碼來源:console.py

示例5: getch

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def getch():
        """Make a get character keyboard method for Posix machines.
        """
        fd = sys.stdin.fileno()
        old = termios.tcgetattr(fd)
        new = termios.tcgetattr(fd)
        new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
        new[6][termios.VMIN] = 1
        new[6][termios.VTIME] = 0
        termios.tcsetattr(fd, termios.TCSANOW, new)
        key = None
        try:
            key = os.read(fd, 4)
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, old)
        return key 
開發者ID:mysql,項目名稱:mysql-utilities,代碼行數:18,代碼來源:failover_console.py

示例6: raw

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def raw(self):
        """Return a context manager that enters *raw* mode. Raw mode is
        similar to *cbreak* mode, in that characters typed are immediately
        available to ``inkey()`` with one exception: the interrupt, quit,
        suspend, and flow control characters are all passed through as their
        raw character values instead of generating a signal.
        """
        if self.keyboard_fd is not None:
            # save current terminal mode,
            save_mode = termios.tcgetattr(self.keyboard_fd)
            tty.setraw(self.keyboard_fd, termios.TCSANOW)
            try:
                yield
            finally:
                # restore prior mode,
                termios.tcsetattr(self.keyboard_fd,
                                  termios.TCSAFLUSH,
                                  save_mode)
        else:
            yield 
開發者ID:xtiankisutsa,項目名稱:MARA_Framework,代碼行數:22,代碼來源:terminal.py

示例7: wait_key

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def wait_key():
    ''' Wait for a key press on the console and return it. '''
    result = None
    if os.name == 'nt':
        import msvcrt
        result = msvcrt.getch()
    else:
        import termios
        fd = sys.stdin.fileno()

        oldterm = termios.tcgetattr(fd)
        newattr = termios.tcgetattr(fd)
        newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
        termios.tcsetattr(fd, termios.TCSANOW, newattr)

        try:
            result = sys.stdin.read(1)
        except IOError:
            pass
        finally:
            termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)

    return result 
開發者ID:bensauer,項目名稱:saywizard,代碼行數:25,代碼來源:wizardofoz.py

示例8: __init__

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def __init__(self, is_gui=False):
        self.is_gui = is_gui
        if os.name == "nt" or self.is_gui:
            pass
        else:
            # Save the terminal settings
            self.file_desc = sys.stdin.fileno()
            self.new_term = termios.tcgetattr(self.file_desc)
            self.old_term = termios.tcgetattr(self.file_desc)

            # New terminal setting unbuffered
            self.new_term[3] = (self.new_term[3] & ~termios.ICANON & ~termios.ECHO)
            termios.tcsetattr(self.file_desc, termios.TCSAFLUSH, self.new_term)

            # Support normal-terminal reset at exit
            atexit.register(self.set_normal_term) 
開發者ID:deepfakes,項目名稱:faceswap,代碼行數:18,代碼來源:keypress.py

示例9: SetTerminalRaw

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def SetTerminalRaw(fd, restore=False):
  """Set controlling terminal to raw mode.

  Set controlling terminal to raw mode and, if requested, register an
  exit handler to restore controlling terminal attribute on exit.

  Args:
    fd: file descriptor of the controlling terminal.
    restore: whether terminal mode should be restored on exit

  Returns:
    None.
  """

  if restore:
    when = termios.TCSAFLUSH
    orig_attr = termios.tcgetattr(fd)
    atexit.register(lambda: termios.tcsetattr(fd, when, orig_attr))
  tty.setraw(fd) 
開發者ID:google,項目名稱:ashier,代碼行數:21,代碼來源:terminal.py

示例10: cleanup_console

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def cleanup_console():
        if old:
            termios.tcsetattr(fd, termios.TCSAFLUSH, old) 
開發者ID:Obijuan,項目名稱:simplez-fpga,代碼行數:5,代碼來源:consola_io.py

示例11: raw

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def raw(self):
        r"""
        A context manager for :func:`tty.setraw`.

        Although both :meth:`break` and :meth:`raw` modes allow each keystroke
        to be read immediately after it is pressed, Raw mode disables
        processing of input and output.

        In cbreak mode, special input characters such as ``^C`` or ``^S`` are
        interpreted by the terminal driver and excluded from the stdin stream.
        In raw mode these values are receive by the :meth:`inkey` method.

        Because output processing is not done, the newline ``'\n'`` is not
        enough, you must also print carriage return to ensure that the cursor
        is returned to the first column::

            with term.raw():
                print("printing in raw mode", end="\r\n")
        """
        if HAS_TTY and self._keyboard_fd is not None:
            # Save current terminal mode:
            save_mode = termios.tcgetattr(self._keyboard_fd)
            save_line_buffered = self._line_buffered
            tty.setraw(self._keyboard_fd, termios.TCSANOW)
            try:
                self._line_buffered = False
                yield
            finally:
                # Restore prior mode:
                termios.tcsetattr(self._keyboard_fd,
                                  termios.TCSAFLUSH,
                                  save_mode)
                self._line_buffered = save_line_buffered
        else:
            yield 
開發者ID:QData,項目名稱:deepWordBug,代碼行數:37,代碼來源:terminal.py

示例12: cleanup

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def cleanup(self):
            termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old) 
開發者ID:cedricp,項目名稱:ddt4all,代碼行數:4,代碼來源:miniterm.py

示例13: pause

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def pause(secs):
    fd = sys.stdin.fileno()

    oldterm = termios.tcgetattr(fd)
    newattr = termios.tcgetattr(fd)
    newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO
    termios.tcsetattr(fd, termios.TCSANOW, newattr)

    oldflags = fcntl.fcntl(fd, fcntl.F_GETFL)
    fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK)

    try:
        ctrlc = False
        paused = False
        t = secs / 0.1
        i = 0
        while i < t:
            if keypressed():
                paused = True
                break
            sleep(0.1)
            i += 1

        if paused:
            while True:
                if keypressed():
                    break
                sleep(0.1)
    except KeyboardInterrupt:
        ctrlc = True

    termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
    fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
    if ctrlc:
        sys.exit(1) 
開發者ID:KONAMI,項目名稱:EM-uNetPi,代碼行數:37,代碼來源:Wanem.py

示例14: main

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
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 
開發者ID:FSecureLABS,項目名稱:Jandroid,代碼行數:34,代碼來源:keyboard.py

示例15: cleanup

# 需要導入模塊: import termios [as 別名]
# 或者: from termios import TCSAFLUSH [as 別名]
def cleanup(self):
            if self.old is not None:
                termios.tcsetattr(self.fd, termios.TCSAFLUSH, self.old) 
開發者ID:FSecureLABS,項目名稱:Jandroid,代碼行數:5,代碼來源:miniterm.py


注:本文中的termios.TCSAFLUSH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。