• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python expect.Expect类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: list

    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,代码行数:28,代码来源:rhuimanager_repo.py


示例2: delete_cdses

 def delete_cdses(connection, *cdses):
     '''
     unregister (delete) CDS instance from the RHUI
     '''
     RHUIManager.screen(connection, "cds")
     Expect.enter(connection, "d")
     RHUIManager.select_items(connection, *cdses)
     RHUIManager.quit(connection, timeout=30)
开发者ID:pombredanne,项目名称:rhui3-automation,代码行数:8,代码来源:rhuimanager_cds.py


示例3: logout

    def logout(connection, prefix=""):
        '''
        Logout from rhui-manager

        Use @param prefix to specify something to expect before exiting
        '''
        Expect.expect(connection, prefix + ".*rhui \(.*\) =>")
        Expect.enter(connection, "logout")
开发者ID:RedHatQE,项目名称:rhui3-automation,代码行数:8,代码来源:rhuimanager.py


示例4: list_lines

 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,代码行数:9,代码来源:rhuimanager.py


示例5: delete_repo

 def delete_repo(connection, repolist):
     '''
     delete a repository from the RHUI
     '''
     RHUIManager.screen(connection, "repo")
     Expect.enter(connection, "d")
     RHUIManager.select(connection, repolist)
     RHUIManager.proceed_with_check(connection, "The following repositories will be deleted:", repolist, ["Red Hat Repositories", "Custom Repositories"])
     RHUIManager.quit(connection)
开发者ID:RedHatQE,项目名称:rhui-testing-tools,代码行数:9,代码来源:rhuimanager_repo.py


示例6: quit

    def quit(connection, prefix="", timeout=10):
        '''
        Quit from rhui-manager

        Use @param prefix to specify something to expect before exiting
        Use @param timeout to specify the timeout
        '''
        Expect.expect(connection, prefix + ".*rhui \(.*\) =>", timeout)
        Expect.enter(connection, "q")
开发者ID:vex21,项目名称:rhui3-automation,代码行数:9,代码来源:rhuimanager.py


示例7: sync_cds

 def sync_cds(connection, cdslist):
     '''
     sync an individual CDS immediately
     '''
     RHUIManager.screen(connection, "sync")
     Expect.enter(connection, "sc")
     RHUIManager.select(connection, cdslist)
     RHUIManager.proceed_with_check(connection, "The following CDS instances will be scheduled for synchronization:", cdslist)
     RHUIManager.quit(connection)
开发者ID:RedHatQE,项目名称:rhui-testing-tools,代码行数:9,代码来源:rhuimanager_sync.py


示例8: sync_cluster

 def sync_cluster(connection, clusterlist):
     '''
     sync a CDS cluster immediately
     '''
     RHUIManager.screen(connection, "sync")
     Expect.enter(connection, "sl")
     RHUIManager.select(connection, clusterlist)
     RHUIManager.proceed_with_check(connection, "The following CDS clusters will be scheduled for synchronization:", clusterlist)
     RHUIManager.quit(connection)
开发者ID:RedHatQE,项目名称:rhui-testing-tools,代码行数:9,代码来源:rhuimanager_sync.py


示例9: delete_repo

 def delete_repo(connection, repolist):
     '''
     delete a repository from the RHUI
     '''
     RHUIManager.screen(connection, "repo")
     Expect.enter(connection, "d")
     RHUIManager.select(connection, repolist)
     RHUIManager.proceed_without_check(connection)
     Expect.expect(connection, ".*rhui \(" + "repo" + "\) =>")
开发者ID:RedHatQE,项目名称:rhui3-automation,代码行数:9,代码来源:rhuimanager_repo.py


示例10: check_for_package

    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,代码行数:29,代码来源:rhuimanager_repo.py


示例11: list

 def list(connection):
     '''
     return the list of currently managed CDSes
     '''
     RHUIManager.screen(connection, "cds")
     # eating prompt!!
     lines = RHUIManager.list_lines(connection, prompt=RHUIManagerCds.prompt)
     ret = Cds.parse(lines)
     # custom quitting; have eaten the prompt
     Expect.enter(connection, 'q')
     return [cds for _, cds in ret]
开发者ID:pombredanne,项目名称:rhui3-automation,代码行数:11,代码来源:rhuimanager_cds.py


示例12: install_rpm_from_rhua

 def install_rpm_from_rhua(rhua_connection, connection, rpmpath):
     '''
     Transfer RPM package from RHUA host to the instance and install it
     @param rpmpath: path to RPM package on RHUA node
     '''
     tfile = tempfile.NamedTemporaryFile(delete=False)
     tfile.close()
     rhua_connection.sftp.get(rpmpath, tfile.name)
     connection.sftp.put(tfile.name, tfile.name + ".rpm")
     os.unlink(tfile.name)
     Expect.ping_pong(connection, "rpm -i " + tfile.name + ".rpm" + " && echo SUCCESS", "[^ ]SUCCESS", 60)
开发者ID:RedHatQE,项目名称:rhui-testing-tools,代码行数:11,代码来源:util.py


示例13: _sync_cds

 def _sync_cds(self, cdslist):
     """ Sync cds """
     if (not "RHUA" in self.rs.Instances.keys()) or len(self.rs.Instances["RHUA"]) < 1:
         raise nose.exc.SkipTest("can't test without RHUA!")
     try:
         RHUIManagerSync.sync_cds(self.rs.Instances["RHUA"][0], cdslist)
     except ExpectFailed:
         # The CDS is not available for syncing so most probably it's syncing right now
         # Trying to check the status
         Expect.enter(self.rs.Instances["RHUA"][0], "b")
         RHUIManager.quit(self.rs.Instances["RHUA"][0])
     self._sync_wait_cds(cdslist)
开发者ID:RedHatQE,项目名称:rhui-testing-tools,代码行数:12,代码来源:rhui_testcase.py


示例14: command_output

 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,代码行数:12,代码来源:pulp_admin.py


示例15: screen

 def screen(connection, screen_name):
     '''
     Open specified rhui-manager screen
     '''
     if screen_name in ["repo", "cds", "loadbalancers", "sync", "identity", "users"]:
         key = screen_name[:1]
     elif screen_name == "client":
         key = "e"
     elif screen_name == "entitlements":
         key = "n"
     Expect.enter(connection, key)
     Expect.expect(connection, "rhui \(" + screen_name + "\) =>")
开发者ID:RedHatQE,项目名称:rhui3-automation,代码行数:12,代码来源:rhuimanager.py


示例16: info

    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,代码行数:52,代码来源:rhuimanager_repo.py


示例17: list

 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,代码行数:13,代码来源:rhuimanager_cds.py


示例18: get_cds_status

 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,代码行数:14,代码来源:rhuimanager_sync.py


示例19: move_cds

 def move_cds(connection, cdslist, clustername):
     """
     move the CDSes to clustername
     """
     RHUIManager.screen(connection, "cds")
     Expect.enter(connection, "m")
     RHUIManager.select(connection, cdslist)
     RHUIManagerCds._select_cluster(connection, clustername)
     RHUIManager.proceed_with_check(
         connection,
         "The following Content Delivery Servers will be moved to the %s cluster:\r\n.*-+" % clustername,
         cdslist,
     )
     RHUIManager.quit(connection, "successfully moved CDS")
开发者ID:pombredanne,项目名称:rhui-testing-tools,代码行数:14,代码来源:rhuimanager_cds.py


示例20: upload_content_cert

 def upload_content_cert(connection, certpath):
     '''
     upload a new or updated Red Hat content certificate
     '''
     if certpath[:1] == '/':
         Expect.enter(connection, "mkdir -p `dirname " + certpath + "` && echo SUCCESS")
         Expect.expect(connection, "[^ ]SUCCESS")
     connection.sftp.put(certpath, certpath)
     RHUIManager.screen(connection, "entitlements")
     Expect.enter(connection, "u")
     Expect.expect(connection, "Full path to the new content certificate:")
     Expect.enter(connection, certpath)
     RHUIManager.proceed_with_check(connection, "The RHUI will be updated with the following certificate:", [certpath])
     RHUIManager.quit(connection, "Red Hat Entitlements.*Valid.*------------------")
开发者ID:RedHatQE,项目名称:rhui-testing-tools,代码行数:14,代码来源:rhuimanager_entitlements.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.Confidence类代码示例发布时间:2022-05-27
下一篇:
Python utils.simon函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap