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


Python pexpect.EOF屬性代碼示例

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


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

示例1: after_scenario

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def after_scenario(context, scenario):
    """Cleans up after each scenario completes."""
    if hasattr(context, "cli") and context.cli and not context.exit_sent:
        # Quit nicely.
        if not context.atprompt:
            dbname = context.currentdb
            context.cli.expect_exact("{0}> ".format(dbname), timeout=15)
        context.cli.sendcontrol("c")
        context.cli.sendcontrol("d")
        try:
            context.cli.expect_exact(pexpect.EOF, timeout=15)
        except pexpect.TIMEOUT:
            print("--- after_scenario {}: kill cli".format(scenario.name))
            context.cli.kill(signal.SIGKILL)
    if hasattr(context, "tmpfile_sql_help") and context.tmpfile_sql_help:
        context.tmpfile_sql_help.close()
        context.tmpfile_sql_help = None


# # TODO: uncomment to debug a failure
# def after_step(context, step):
#     if step.status == "failed":
#         import pdb; pdb.set_trace() 
開發者ID:dbcli,項目名稱:pgcli,代碼行數:25,代碼來源:environment.py

示例2: _execute

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def _execute(self, cmd, skip_cwd=False, **kwargs):
        """
        Additional Args:
            skip_cwd (bool): Whether to skip changing to the current working
                directory associated with this client before executing the
                command. This is mainly useful to methods internal to this
                class.
        """
        template = 'ssh {login} -T -o ControlPath={socket} << EOF\n{cwd}{cmd}\nEOF'
        config = dict(self._subprocess_config)
        config.update(kwargs)

        cwd = 'cd "{path}"\n'.format(path=escape_path(self.path_cwd)) if not skip_cwd else ''
        return run_in_subprocess(template.format(login=self._login_info,
                                                 socket=self._socket_path,
                                                 cwd=cwd,
                                                 cmd=cmd),
                                 check_output=True,
                                 **config) 
開發者ID:airbnb,項目名稱:omniduct,代碼行數:21,代碼來源:ssh.py

示例3: _stop_ssh_connection

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def _stop_ssh_connection(self, conn):
        if not conn or PEXPECT_VERSION == NO_MODULE:
            return

        if PEXPECT_VERSION == NEW_MODULE:
            conn.logout()
            if conn:
                conn.close()
        elif PEXPECT_VERSION == OLD_MODULE:
            conn.sendline('exit')
            i = conn.expect([pexpect.EOF, "(?i)there are stopped jobs"])
            if i == 1:
                conn.sendline("exit")
                conn.expect(pexpect.EOF)
            if conn:
                conn.close()

        self.remote_system_command_prompt = '[#$] ' 
開發者ID:aerospike,項目名稱:aerospike-admin,代碼行數:20,代碼來源:node.py

示例4: _try_passwordless_openssh

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def _try_passwordless_openssh(server, keyfile):
    """Try passwordless login with shell ssh command."""
    if pexpect is None:
        raise ImportError("pexpect unavailable, use paramiko")
    cmd = 'ssh -f '+ server
    if keyfile:
        cmd += ' -i ' + keyfile
    cmd += ' exit'
    p = pexpect.spawn(cmd)
    while True:
        try:
            p.expect('[Pp]assword:', timeout=.1)
        except pexpect.TIMEOUT:
            continue
        except pexpect.EOF:
            return True
        else:
            return False 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:20,代碼來源:tunnel.py

示例5: readline

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def readline(self, size = -1):
        """This reads and returns one entire line. A trailing newline is kept
        in the string, but may be absent when a file ends with an incomplete
        line. Note: This readline() looks for a \\r\\n pair even on UNIX
        because this is what the pseudo tty device returns. So contrary to what
        you may expect you will receive the newline as \\r\\n. An empty string
        is returned when EOF is hit immediately. Currently, the size argument is
        mostly ignored, so this behavior is not standard for a file-like
        object. If size is 0 then an empty string is returned. """

        if size == 0:
            return self._empty_buffer
        index = self.expect ([self._pty_newline, self.delimiter]) # delimiter default is EOF
        if index == 0:
            return self.before + self._pty_newline
        return self.before 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:18,代碼來源:_pexpect.py

示例6: expect_exact

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def expect_exact(self, pattern_list, timeout = -1, searchwindowsize = -1):

        """This is similar to expect(), but uses plain string matching instead
        of compiled regular expressions in 'pattern_list'. The 'pattern_list'
        may be a string; a list or other sequence of strings; or TIMEOUT and
        EOF.

        This call might be faster than expect() for two reasons: string
        searching is faster than RE matching and it is possible to limit the
        search to just the end of the input buffer.

        This method is also useful when you don't want to have to worry about
        escaping regular expression characters that you want to match."""

        if isinstance(pattern_list, (bytes, unicode)) or pattern_list in (TIMEOUT, EOF):
            pattern_list = [pattern_list]
        return self.expect_loop(searcher_string(pattern_list), timeout, searchwindowsize) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:19,代碼來源:_pexpect.py

示例7: __init__

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def __init__(self, strings):

        """This creates an instance of searcher_string. This argument 'strings'
        may be a list; a sequence of strings; or the EOF or TIMEOUT types. """

        self.eof_index = -1
        self.timeout_index = -1
        self._strings = []
        for n, s in enumerate(strings):
            if s is EOF:
                self.eof_index = n
                continue
            if s is TIMEOUT:
                self.timeout_index = n
                continue
            self._strings.append((n, s)) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:18,代碼來源:_pexpect.py

示例8: change_password2

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def change_password2(old_passwd, new_passwd):
    child = pexpect.spawn('passwd')
    i = child.expect(['[Oo]ld [Pp]assword', '.current.*password', '[Nn]ew [Pp]assword'])

    # Root does not require old password, so it gets to bypass the next step.
    if i == 0 or i == 1:
        child.sendline(old_passwd)
        child.expect('[Nn]ew [Pp]assword')

    child.sendline(new_passwd)
    i = child.expect(['[Nn]ew [Pp]assword', '[Rr]etype', '[Rr]e-enter'])

    if i == 0:
        print('Host did not like new password. Here is what it said...')
        print(child.before)
        child.send(chr(3)) # Ctrl-C
        child.sendline('') # This should tell remote passwd command to quit.
        return
    child.sendline(new_passwd)
    child.expect(pexpect.EOF) 
開發者ID:Akagi201,項目名稱:learning-python,代碼行數:22,代碼來源:change_passwd.py

示例9: do_test_rebuilder

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def do_test_rebuilder(tree, path):
    directory = mktree(FORGE_YAML + tree, MANGLE=MANGLE)
    forge = launch(directory, "forge build containers")
    forge.expect(pexpect.EOF)
    assert forge.wait() == 0
    assert run_image(directory).strip() == "hello"

    with open(os.path.join(directory, path), "write") as f:
        f.write('print("goodbye")\n')

    forge = launch(directory, "forge build containers")
    forge.expect(pexpect.EOF)
    assert forge.wait() == 0
    assert run_image(directory).strip() == "goodbye"

    forge = launch(directory, "forge clean")
    forge.expect("docker kill ")
    forge.expect(pexpect.EOF)
    assert forge.wait() == 0 
開發者ID:datawire,項目名稱:forge,代碼行數:21,代碼來源:test_forge.py

示例10: recv_ClientInit

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def recv_ClientInit(self, block):
        # start reward proxy.
        self._log_info('Starting reward proxy server')
        self.reward_proxy = pexpect.spawnu(self.factory.reward_proxy_bin,
                                           logfile=sys.stdout,
                                           timeout=None)

        # wait on reward proxy to be up.
        self._log_info('Waiting for reward proxy server')
        self.reward_proxy.expect('\[RewardProxyServer\]')
        self.reward_proxy_thread = threading.Thread(target=lambda: self.reward_proxy.expect(pexpect.EOF))
        self.reward_proxy_thread.start()

        self._log_info('Reward proxy server is up %s', self.reward_proxy.before)

        super(DualProxyServer, self).recv_ClientInit(block)

        self.logfile_dir = self.log_manager.logfile_dir 
開發者ID:openai,項目名稱:universe,代碼行數:20,代碼來源:dual_proxy_server.py

示例11: _pexpect_out

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def _pexpect_out(self):
        if self.subprocess.encoding:
            result = ""
        else:
            result = b""

        if self.subprocess.before:
            result += self.subprocess.before

        if self.subprocess.after and self.subprocess.after not in (pexpect.EOF, pexpect.TIMEOUT):
            try:
                result += self.subprocess.after
            except (pexpect.EOF, pexpect.TIMEOUT):
                pass

        result += self.subprocess.read()
        return result 
開發者ID:pypa,項目名稱:pipenv,代碼行數:19,代碼來源:delegator.py

示例12: readline

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def readline (self, size = -1):    # File-like object.

        """This reads and returns one entire line. A trailing newline is kept
        in the string, but may be absent when a file ends with an incomplete
        line. Note: This readline() looks for a \\r\\n pair even on UNIX
        because this is what the pseudo tty device returns. So contrary to what
        you may expect you will receive the newline as \\r\\n. An empty string
        is returned when EOF is hit immediately. Currently, the size argument is
        mostly ignored, so this behavior is not standard for a file-like
        object. If size is 0 then an empty string is returned. """

        if size == 0:
            return ''
        index = self.expect (['\r\n', self.delimiter]) # delimiter default is EOF
        if index == 0:
            return self.before + '\r\n'
        else:
            return self.before 
開發者ID:theralfbrown,項目名稱:smod-1,代碼行數:20,代碼來源:pexpect.py

示例13: expect_exact

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def expect_exact(self, pattern_list, timeout = -1, searchwindowsize = -1):

        """This is similar to expect(), but uses plain string matching instead
        of compiled regular expressions in 'pattern_list'. The 'pattern_list'
        may be a string; a list or other sequence of strings; or TIMEOUT and
        EOF.

        This call might be faster than expect() for two reasons: string
        searching is faster than RE matching and it is possible to limit the
        search to just the end of the input buffer.

        This method is also useful when you don't want to have to worry about
        escaping regular expression characters that you want to match."""

        if type(pattern_list) in types.StringTypes or pattern_list in (TIMEOUT, EOF):
            pattern_list = [pattern_list]
        return self.expect_loop(searcher_string(pattern_list), timeout, searchwindowsize) 
開發者ID:theralfbrown,項目名稱:smod-1,代碼行數:19,代碼來源:pexpect.py

示例14: __init__

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def __init__(self, strings):

        """This creates an instance of searcher_string. This argument 'strings'
        may be a list; a sequence of strings; or the EOF or TIMEOUT types. """

        self.eof_index = -1
        self.timeout_index = -1
        self._strings = []
        for n, s in zip(range(len(strings)), strings):
            if s is EOF:
                self.eof_index = n
                continue
            if s is TIMEOUT:
                self.timeout_index = n
                continue
            self._strings.append((n, s)) 
開發者ID:theralfbrown,項目名稱:smod-1,代碼行數:18,代碼來源:pexpect.py

示例15: init_scoutfish

# 需要導入模塊: import pexpect [as 別名]
# 或者: from pexpect import EOF [as 別名]
def init_scoutfish(self):
        """ Create/open .scout database index file to help querying
            using scoutfish from https://github.com/mcostalba/scoutfish
        """
        if scoutfish_path is not None and self.path and self.size > 0:
            try:
                if self.progressbar is not None:
                    from gi.repository import GLib
                    GLib.idle_add(self.progressbar.set_text, _("Creating .scout index file..."))
                self.scoutfish = Scoutfish(engine=(scoutfish_path, ))
                self.scoutfish.open(self.path)
                scout_path = os.path.splitext(self.path)[0] + '.scout'
                if getmtime(self.path) > getmtime(scout_path):
                    self.scoutfish.make()
            except OSError as err:
                self.scoutfish = None
                log.warning("Failed to sart scoutfish. OSError %s %s" % (err.errno, err.strerror))
            except pexpect.TIMEOUT:
                self.scoutfish = None
                log.warning("scoutfish failed (pexpect.TIMEOUT)")
            except pexpect.EOF:
                self.scoutfish = None
                log.warning("scoutfish failed (pexpect.EOF)") 
開發者ID:pychess,項目名稱:pychess,代碼行數:25,代碼來源:pgn.py


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