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


Python Expect.match方法代码示例

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


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

示例1: select

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
 def select(connection, value_list):
     '''
     Select list of items (multiple choice)
     '''
     for value in value_list:
         match = Expect.match(connection, re.compile(".*-\s+([0-9]+)\s*:[^\n]*\s+" + value + "\s*\n.*for more commands:.*", re.DOTALL))
         Expect.enter(connection, match[0])
         match = Expect.match(connection, re.compile(".*x\s+([0-9]+)\s*:[^\n]*\s+" + value + "\s*\n.*for more commands:.*", re.DOTALL))
         Expect.enter(connection, "l")
     Expect.enter(connection, "c")
开发者ID:RedHatQE,项目名称:rhui3-automation,代码行数:12,代码来源:rhuimanager.py

示例2: list

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
    def list(connection):
        '''
        list repositories
        '''
        RHUIManager.screen(connection, "repo")
        Expect.enter(connection, "l")
        # eating prompt!!
        pattern = re.compile('l\r\n(.*)\r\n-+\r\nrhui\s* \(repo\)\s* =>',
                re.DOTALL)
        ret = Expect.match(connection, pattern, grouplist=[1])[0]
        print ret
        reslist = map(lambda x: x.strip(), ret.split("\r\n"))
        print reslist
        repolist = []
        for line in reslist:
            # Readling lines and searching for repos
            if line == '':
                continue
            if "Custom Repositories" in line:
                continue
            if "Red Hat Repositories" in line:
                continue
            if "No repositories are currently managed by the RHUI" in line:
                continue
            repolist.append(line)

        Expect.enter(connection, 'q')
        return repolist
开发者ID:RedHatQE,项目名称:rhui-testing-tools,代码行数:30,代码来源:rhuimanager_repo.py

示例3: check_for_package

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
    def check_for_package(connection, reponame, package):
        '''
        list packages in a repository
        '''
        RHUIManager.screen(connection, "repo")
        Expect.enter(connection, "p")
        RHUIManager.select_one(connection, reponame)
        Expect.expect(connection, "\(blank line for no filter\):")
        Expect.enter(connection, package)

        pattern = re.compile('.*only\.\r\n(.*)\r\n-+\r\nrhui\s* \(repo\)\s* =>',
                             re.DOTALL)
        ret = Expect.match(connection, pattern, grouplist=[1])[0]
        reslist = map(lambda x: x.strip(), ret.split("\r\n"))
        print reslist
        packagelist = []
        for line in reslist:
            if line == '':
                continue
            if line == 'Packages:':
                continue
            if line == 'No packages found that match the given filter.':
                continue
            if line == 'No packages in the repository.':
                continue
            packagelist.append(line)

        Expect.enter(connection, 'q')
        return packagelist
开发者ID:RedHatQE,项目名称:rhui-testing-tools,代码行数:31,代码来源:rhuimanager_repo.py

示例4: upload_content

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
 def upload_content(connection, repolist, path):
     '''
     upload content to a custom repository
     '''
     # Temporarily quit rhui-manager and check whether "path" is a file or a directory.
     # If it is a directory, get a list of *.rpm files in it.
     Expect.enter(connection, 'q')
     Expect.enter(connection, "stat -c %F " + path)
     path_type = Expect.expect_list(connection, [(re.compile(".*regular file.*", re.DOTALL), 1), (re.compile(".*directory.*", re.DOTALL), 2)])
     if path_type == 1:
         content = [basename(path)]
     elif path_type == 2:
         Expect.enter(connection, "echo " + path + "/*.rpm")
         output = Expect.match(connection, re.compile("(.*)", re.DOTALL))[0]
         rpm_files = output.splitlines()[1]
         content = []
         for rpm_file in rpm_files.split():
             content.append(basename(rpm_file))
     else:
         # This should not happen. Getting here means that "path" is neither a file nor a directory.
         # Anyway, going on with no content, leaving it up to proceed_with_check() to handle this situation.
         content = []
     # Start rhui-manager again and continue.
     RHUIManager.initial_run(connection)
     RHUIManager.screen(connection, "repo")
     Expect.enter(connection, "u")
     RHUIManager.select(connection, repolist)
     Expect.expect(connection, "will be uploaded:")
     Expect.enter(connection, path)
     RHUIManager.proceed_with_check(connection, "The following RPMs will be uploaded:", content)
     Expect.expect(connection, "rhui \(" + "repo" + "\) =>")
开发者ID:RedHatQE,项目名称:rhui3-automation,代码行数:33,代码来源:rhuimanager_repo.py

示例5: list_lines

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
 def list_lines(connection, prompt='', enter_l=True):
     '''
     list items on screen returning a list of lines seen
     eats prompt!!!
     '''
     if enter_l:
         Expect.enter(connection, "l")
     match = Expect.match(connection, re.compile("(.*)" + prompt, re.DOTALL))
     return match[0].split('\r\n')
开发者ID:vex21,项目名称:rhui3-automation,代码行数:11,代码来源:rhuimanager.py

示例6: command_output

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
 def command_output(connection, command, pattern_tuple, username="admin",
         password="admin"):
     """return output of a command based on pattern_tuple provided. Output
     is split to lines"""
     Expect.enter(connection, "pulp-admin -u %s -p %s %s" % \
             (username, password, command))
     # eats prompt!
     pattern, group_index = pattern_tuple
     ret = Expect.match(connection, pattern, grouplist=[group_index])[0]
     # reset prompt
     Expect.enter(connection, "")
     return ret.split('\r\n')
开发者ID:RedHatQE,项目名称:rhui-testing-tools,代码行数:14,代码来源:pulp_admin.py

示例7: info

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
    def info(connection, repolist):
        '''
        detailed information about repositories

        Method returns list of items from rhui-manager info screen. Some of them are variable and these are replaced by "rh_repo" constant.
        '''
        RHUIManager.screen(connection, "repo")
        Expect.enter(connection, "i")
        RHUIManager.select(connection, repolist)

        try:
            pattern = re.compile('.*for more commands: \r\n\r\nName:\s(.*)\r\n-+\r\nrhui\s* \(repo\)\s* =>',
                                 re.DOTALL)
            ret = Expect.match(connection, pattern, grouplist=[1])[0]
            print ret
            res = map(lambda x: x.strip(), ret.split("\r\n"))
            reslist = ["Name:"]
            for line in res:
                reslist.extend(map(lambda y: y.strip(), re.split("\s{3}", line)))
            print reslist
            repoinfo = []
            rh_repo = 0
            rh_repo_info = 0
            for line in reslist:
                # Readling lines
                if line == '':
                    continue
                if rh_repo_info == 1:
                    line = "rh_repo"
                    rh_repo_info = 0
                if line == "Red Hat":
                    rh_repo = 1
                if "Relative Path:" in line:
                    if rh_repo == 1:
                        rh_repo_info = 1
                if "Package Count:" in line:
                    if rh_repo == 1:
                        rh_repo_info = 1
                if "Last Sync:" in line:
                    if rh_repo == 1:
                        rh_repo_info = 1
                if "Next Sync:" in line:
                    if rh_repo == 1:
                        rh_repo_info = 1
                repoinfo.append(line)
            print repoinfo

        except:
            repoinfo = []

        Expect.enter(connection, 'q')
        return repoinfo
开发者ID:RedHatQE,项目名称:rhui-testing-tools,代码行数:54,代码来源:rhuimanager_repo.py

示例8: list

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
 def list(connection):
     """
     return the list currently managed CDSes and clusters as it is provided
     by the cds list command
     """
     RHUIManager.screen(connection, "cds")
     Expect.enter(connection, "l")
     # eating prompt!!
     pattern = re.compile("l(\r\n)+(.*)rhui\s* \(cds\)\s* =>", re.DOTALL)
     ret = Expect.match(connection, pattern, grouplist=[2])[0]
     # custom quitting; have eaten the prompt
     Expect.enter(connection, "q")
     return ret
开发者ID:pombredanne,项目名称:rhui-testing-tools,代码行数:15,代码来源:rhuimanager_cds.py

示例9: get_cds_status

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
 def get_cds_status(connection, cdsname):
     '''
     display CDS sync summary
     '''
     RHUIManager.screen(connection, "sync")
     Expect.enter(connection, "dc")
     res_list = Expect.match(connection, re.compile(".*\n" + cdsname.replace(".", "\.") + "[\.\s]*\[([^\n]*)\].*" + cdsname.replace(".", "\.") + "\s*\r\n([^\n]*)\r\n", re.DOTALL), [1, 2], 60)
     connection.cli.exec_command("killall -s SIGINT rhui-manager")
     ret_list = []
     for val in [res_list[0]] + res_list[1].split("             "):
         val = Util.uncolorify(val.strip())
         ret_list.append(val)
     RHUIManager.quit(connection)
     return ret_list
开发者ID:RedHatQE,项目名称:rhui-testing-tools,代码行数:16,代码来源:rhuimanager_sync.py

示例10: list_custom_entitlements

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
 def list_custom_entitlements(connection):
     '''
     list custom entitlements
     '''
      
     RHUIManager.screen(connection, "entitlements")
     Expect.enter(connection, "c")
     match = Expect.match(connection, re.compile("c\r\n\r\nCustom Repository Entitlements\r\n\r\n(.*)" + RHUIManagerEntitlements.prompt, re.DOTALL))[0]
     
     repo_list = []
     
     for line in match.splitlines():
         if "Name:" in line:
             repo_list.append(line.replace("Name:", "").strip())
     return sorted(repo_list)
开发者ID:RedHatQE,项目名称:rhui3-automation,代码行数:17,代码来源:rhuimanager_entitlement.py

示例11: get_repo_status

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
 def get_repo_status(connection, reponame):
     '''
     display repo sync summary
     '''
     RHUIManager.screen(connection, "sync")
     Expect.enter(connection, "dr")
     reponame_quoted = reponame.replace(".", "\.")
     res = Expect.match(connection, re.compile(".*" + reponame_quoted + "\s*\r\n([^\n]*)\r\n.*", re.DOTALL), [1], 60)[0]
     connection.cli.exec_command("killall -s SIGINT rhui-manager")
     res = Util.uncolorify(res)
     ret_list = res.split("             ")
     for i in range(len(ret_list)):
         ret_list[i] = ret_list[i].strip()
     RHUIManager.quit(connection)
     return ret_list
开发者ID:RedHatQE,项目名称:rhui-testing-tools,代码行数:17,代码来源:rhuimanager_sync.py

示例12: _select_cluster

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
 def _select_cluster(connection, clustername, create_new=True):
     """
     select cluster
     """
     try:
         select = Expect.match(
             connection, re.compile(".*\s+([0-9]+)\s*-\s*" + clustername + "\s*\r\n.*to abort:.*", re.DOTALL)
         )
         Expect.enter(connection, select[0])
     except ExpectFailed as err:
         if not create_new:
             raise err
         Expect.enter(connection, "1")
         Expect.expect(connection, "Enter a[^\n]*CDS cluster name:")
         Expect.enter(connection, clustername)
开发者ID:pombredanne,项目名称:rhui-testing-tools,代码行数:17,代码来源:rhuimanager_cds.py

示例13: list_rh_entitlements

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
 def list_rh_entitlements(connection):
     '''
     list Red Hat entitlements
     '''
     
     RHUIManager.screen(connection, "entitlements")
     Expect.enter(connection, "l")
     match = Expect.match(connection, re.compile("(.*)" + RHUIManagerEntitlements.prompt, re.DOTALL))
     
     matched_string = match[0].replace('l\r\n\r\nRed Hat Entitlements\r\n\r\n  \x1b[92mValid\x1b[0m\r\n    ', '', 1)
     
     entitlements_list = []
     pattern = re.compile('(.*?\r\n.*?pem)', re.DOTALL)
     for entitlement in pattern.findall(matched_string):
         entitlements_list.append(entitlement.strip())
     return entitlements_list
开发者ID:RedHatQE,项目名称:rhui3-automation,代码行数:18,代码来源:rhuimanager_entitlement.py

示例14: proceed_with_check

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
    def proceed_with_check(connection, caption, value_list, skip_list=[]):
        '''
        Proceed with prior checking the list of values

        Use @param skip_list to skip meaningless 2nd-level headers
        '''
        selected = Expect.match(connection, re.compile(".*" + caption + "\r\n(.*)\r\nProceed\? \(y/n\).*", re.DOTALL))[0].split("\r\n")
        selected_clean = []
        for val in selected:
            val = val.strip()
            val = val.replace("\t", " ")
            val = ' '.join(val.split())
            val = val.replace("(", "\(")
            val = val.replace(")", "\)")
            if val != "" and not val in skip_list:
                selected_clean.append(val)
        if sorted(selected_clean) != sorted(value_list):
            logging.debug("Selected: " + str(selected_clean))
            logging.debug("Expected: " + str(value_list))
            raise ExpectFailed()
        Expect.enter(connection, "y")
开发者ID:vex21,项目名称:rhui3-automation,代码行数:23,代码来源:rhuimanager.py

示例15: upload_rh_certificate

# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import match [as 别名]
    def upload_rh_certificate(connection):
        '''
        upload a new or updated Red Hat content certificate
        '''
        
        certificate_file = '/tmp/extra_rhui_files/rhcert.pem'
        
        if connection.recv_exit_status("ls -la %s" % certificate_file)!=0:
            raise ExpectFailed("Missing certificate file: %s" % certificate_file)

        RHUIManager.screen(connection, "entitlements")
        Expect.enter(connection, "u")
        Expect.expect(connection, "Full path to the new content certificate:")
        Expect.enter(connection, certificate_file)
        Expect.expect(connection, "The RHUI will be updated with the following certificate:")
        Expect.enter(connection, "y")
        match = Expect.match(connection, re.compile("(.*)" + RHUIManagerEntitlements.prompt, re.DOTALL))
        matched_string = match[0].replace('l\r\n\r\nRed Hat Entitlements\r\n\r\n  \x1b[92mValid\x1b[0m\r\n    ', '', 1)
        entitlements_list = []
        pattern = re.compile('(.*?\r\n.*?pem)', re.DOTALL)
        for entitlement in pattern.findall(matched_string):
            entitlements_list.append(entitlement.strip())
        return entitlements_list
开发者ID:RedHatQE,项目名称:rhui3-automation,代码行数:25,代码来源:rhuimanager_entitlement.py


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