当前位置: 首页>>代码示例>>Python>>正文


Python termios.ECHO属性代码示例

本文整理汇总了Python中termios.ECHO属性的典型用法代码示例。如果您正苦于以下问题:Python termios.ECHO属性的具体用法?Python termios.ECHO怎么用?Python termios.ECHO使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在termios的用法示例。


在下文中一共展示了termios.ECHO属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: restore_echo

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [as 别名]
def restore_echo():
    """Hack for https://stackoverflow.com/questions/6488275 equivalent
    issue with Nmap (from
    http://stackoverflow.com/a/8758047/3223422)

    """
    try:
        fdesc = sys.stdin.fileno()
    except ValueError:
        return
    try:
        attrs = termios.tcgetattr(fdesc)
    except termios.error:
        return
    attrs[3] = attrs[3] | termios.ECHO
    termios.tcsetattr(fdesc, termios.TCSADRAIN, attrs) 
开发者ID:cea-sec,项目名称:ivre,代码行数:18,代码来源:runscans.py

示例2: __init__

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [as 别名]
def __init__(self, verbosity, maxJobs):
        super().__init__(verbosity)
        self.__index = 1
        self.__maxJobs = maxJobs
        self.__jobs = {}
        self.__slots = [None] * maxJobs
        self.__tasksDone = 0
        self.__tasksNum = 1

        # disable cursor
        print("\x1b[?25l")

        # disable echo
        try:
            import termios
            fd = sys.stdin.fileno()
            self.__oldTcAttr = termios.tcgetattr(fd)
            new = termios.tcgetattr(fd)
            new[3] = new[3] & ~termios.ECHO
            termios.tcsetattr(fd, termios.TCSADRAIN, new)
        except ImportError:
            pass 
开发者ID:BobBuildTool,项目名称:bob,代码行数:24,代码来源:tty.py

示例3: __init__

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [as 别名]
def __init__(self, args, close_stderr=False):
    pid, fd = pty.fork()
    if pid == 0:
      # We're the child. Transfer control to command.
      if close_stderr:
        dev_null = os.open('/dev/null', 0)
        os.dup2(dev_null, 2)
      os.execvp(args[0], args)
    else:
      # Disable echoing.
      attr = termios.tcgetattr(fd)
      attr[3] = attr[3] & ~termios.ECHO
      termios.tcsetattr(fd, termios.TCSANOW, attr)
      # Set up a file()-like interface to the child process
      self.r = os.fdopen(fd, 'r', 1)
      self.w = os.fdopen(os.dup(fd), 'w', 1) 
开发者ID:google,项目名称:clusterfuzz,代码行数:18,代码来源:stack_symbolizer.py

示例4: init

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [as 别名]
def init():
    if os.name == 'posix':
        global old
        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

        # -- Cambiar los atributos
        termios.tcsetattr(fd, termios.TCSANOW, new)

        # -- Restaurar el terminal a la salida
        atexit.register(cleanup_console)
    pass


# -------------------------------------
# Pequena prueba del modulo
# ------------------------------------- 
开发者ID:Obijuan,项目名称:simplez-fpga,代码行数:22,代码来源:consola_io.py

示例5: launch_proc_with_pty

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [as 别名]
def launch_proc_with_pty(args, stdin=None, stdout=None, stderr=None, echo=True):
    """Similar to pty.fork, but handle stdin/stdout according to parameters
    instead of connecting to the pty

    :return tuple (subprocess.Popen, pty_master)
    """

    def set_ctty(ctty_fd, master_fd):
        os.setsid()
        os.close(master_fd)
        fcntl.ioctl(ctty_fd, termios.TIOCSCTTY, 0)
        if not echo:
            termios_p = termios.tcgetattr(ctty_fd)
            # termios_p.c_lflags
            termios_p[3] &= ~termios.ECHO
            termios.tcsetattr(ctty_fd, termios.TCSANOW, termios_p)
    (pty_master, pty_slave) = os.openpty()
    # pylint: disable=not-an-iterable
    p = yield from asyncio.create_subprocess_exec(*args,
        stdin=stdin,
        stdout=stdout,
        stderr=stderr,
        preexec_fn=lambda: set_ctty(pty_slave, pty_master))
    os.close(pty_slave)
    return p, open(pty_master, 'wb+', buffering=0) 
开发者ID:QubesOS,项目名称:qubes-core-admin,代码行数:27,代码来源:backup.py

示例6: _setecho

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [as 别名]
def _setecho(fd, state):
    errmsg = 'setecho() may not be called on this platform (it may still be possible to enable/disable echo when spawning the child process)'

    try:
        attr = termios.tcgetattr(fd)
    except termios.error as err:
        if err.args[0] == errno.EINVAL:
            raise IOError(err.args[0], '%s: %s.' % (err.args[1], errmsg))
        raise

    if state:
        attr[3] = attr[3] | termios.ECHO
    else:
        attr[3] = attr[3] & ~termios.ECHO

    try:
        # I tried TCSADRAIN and TCSAFLUSH, but these were inconsistent and
        # blocked on some platforms. TCSADRAIN would probably be ideal.
        termios.tcsetattr(fd, termios.TCSANOW, attr)
    except IOError as err:
        if err.args[0] == errno.EINVAL:
            raise IOError(err.args[0], '%s: %s.' % (err.args[1], errmsg))
        raise 
开发者ID:pypa,项目名称:pipenv,代码行数:25,代码来源:ptyprocess.py

示例7: getecho

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [as 别名]
def getecho(self):
        '''This returns the terminal echo mode. This returns True if echo is
        on or False if echo is off. Child applications that are expecting you
        to enter a password often set ECHO False. See waitnoecho().

        Not supported on platforms where ``isatty()`` returns False.  '''

        try:
            attr = termios.tcgetattr(self.fd)
        except termios.error as err:
            errmsg = 'getecho() may not be called on this platform'
            if err.args[0] == errno.EINVAL:
                raise IOError(err.args[0], '%s: %s.' % (err.args[1], errmsg))
            raise

        self.echo = bool(attr[3] & termios.ECHO)
        return self.echo 
开发者ID:pypa,项目名称:pipenv,代码行数:19,代码来源:ptyprocess.py

示例8: __init__

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [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

示例9: _setecho

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [as 别名]
def _setecho(fd, state):
    errmsg = 'setecho() may not be called on this platform'

    try:
        attr = termios.tcgetattr(fd)
    except termios.error as err:
        if err.args[0] == errno.EINVAL:
            raise IOError(err.args[0], '%s: %s.' % (err.args[1], errmsg))
        raise

    if state:
        attr[3] = attr[3] | termios.ECHO
    else:
        attr[3] = attr[3] & ~termios.ECHO

    try:
        # I tried TCSADRAIN and TCSAFLUSH, but these were inconsistent and
        # blocked on some platforms. TCSADRAIN would probably be ideal.
        termios.tcsetattr(fd, termios.TCSANOW, attr)
    except IOError as err:
        if err.args[0] == errno.EINVAL:
            raise IOError(err.args[0], '%s: %s.' % (err.args[1], errmsg))
        raise 
开发者ID:daveleroy,项目名称:sublime_debugger,代码行数:25,代码来源:ptyprocess.py

示例10: getecho

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [as 别名]
def getecho(self):
        '''This returns the terminal echo mode. This returns True if echo is
        on or False if echo is off. Child applications that are expecting you
        to enter a password often set ECHO False. See waitnoecho().

        Not supported on platforms where ``isatty()`` returns False.  '''

        try:
            attr = termios.tcgetattr(self.child_fd)
        except termios.error as err:
            errmsg = 'getecho() may not be called on this platform'
            if err.args[0] == errno.EINVAL:
                raise IOError(err.args[0], '%s: %s.' % (err.args[1], errmsg))
            raise

        self.echo = bool(attr[3] & termios.ECHO)
        return self.echo 
开发者ID:c-amr,项目名称:camr,代码行数:19,代码来源:__init__.py

示例11: __init__

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [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

示例12: wait_key

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [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

示例13: getch

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [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

示例14: getch

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [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

示例15: wait_key

# 需要导入模块: import termios [as 别名]
# 或者: from termios import ECHO [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


注:本文中的termios.ECHO属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。