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

Python envutils.get_global函数代码示例

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

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



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

示例1: test_task

 def test_task(self):
     cfg = {
         "Dummy.dummy_random_fail_in_atomic": [
             {
                 "runner": {
                     "type": "constant",
                     "times": 100,
                     "concurrency": 5
                 }
             }
         ]
     }
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
         config = utils.TaskConfig(cfg)
         output = self.rally(("task start --task %(task_file)s "
                              "--deployment %(deployment_id)s") %
                             {"task_file": config.filename,
                              "deployment_id": deployment_id})
         result = re.search(
             r"(?P<uuid>[0-9a-f\-]{36}): started", output)
         uuid = result.group("uuid")
         self.rally("use task --uuid %s" % uuid)
         current_task = envutils.get_global("RALLY_TASK")
         self.assertEqual(uuid, current_task)
开发者ID:akalambu,项目名称:rally,代码行数:25,代码来源:test_cli_use.py


示例2: test_use

 def test_use(self):
     rally = utils.Rally()
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
         config = utils.TaskConfig(self._get_sample_task_config())
         output = rally(("task start --task %(task_file)s "
                         "--deployment %(deployment_id)s") %
                        {"task_file": config.filename,
                         "deployment_id": deployment_id})
         result = re.search(
             r"(?P<uuid>[0-9a-f\-]{36}): started", output)
         uuid = result.group("uuid")
         rally("task use --task %s" % uuid)
         current_task = envutils.get_global("RALLY_TASK")
         self.assertEqual(uuid, current_task)
开发者ID:tiagoapr,项目名称:rally,代码行数:15,代码来源:test_cli_task.py


示例3: show_verifier

    def show_verifier(self, api, verifier_id=None):
        """Show detailed information about a verifier."""

        verifier = api.verifier.get(verifier_id=verifier_id)
        fields = ["UUID", "Status", "Created at", "Updated at", "Active",
                  "Name", "Description", "Type", "Platform", "Source",
                  "Version", "System-wide", "Extra settings", "Location",
                  "Venv location"]
        used_verifier = envutils.get_global(envutils.ENV_VERIFIER)
        formatters = {
            "Created at": lambda v: v["created_at"].replace("T", " "),
            "Updated at": lambda v: v["updated_at"].replace("T", " "),
            "Active": lambda v: u"\u2714"
                                if v["uuid"] == used_verifier else None,
            "Extra settings": lambda v: (json.dumps(v["extra_settings"],
                                                    indent=4)
                                         if v["extra_settings"] else None),
            "Location": lambda v: self._get_location((v["uuid"]), "repo")
        }
        if not verifier["system_wide"]:
            formatters["Venv location"] = lambda v: self._get_location(
                v["uuid"], ".venv")
        cliutils.print_dict(verifier, fields=fields, formatters=formatters,
                            normalize_field_names=True, print_header=False,
                            table_label="Verifier")
        print("Attention! All you do in the verifier repository or verifier "
              "virtual environment, you do it at your own risk!")
开发者ID:andreykurilin,项目名称:rally,代码行数:27,代码来源:verify.py


示例4: test_deployment

 def test_deployment(self):
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         output = self.rally(
             "deployment create --name t_create_env1 --fromenv")
         uuid = self._get_deployment_uuid(output)
         self.rally("deployment create --name t_create_env2 --fromenv")
         self.rally("use deployment --deployment %s" % uuid)
         current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
         self.assertEqual(uuid, current_deployment)
开发者ID:akalambu,项目名称:rally,代码行数:9,代码来源:test_cli_use.py


示例5: test_use

 def test_use(self):
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         output = self.rally(
             "deployment create --name t_create_env1 --fromenv")
         uuid = re.search(r"Using deployment: (?P<uuid>[0-9a-f\-]{36})",
                          output).group("uuid")
         self.rally("deployment create --name t_create_env2 --fromenv")
         self.rally("deployment use --deployment %s" % uuid)
         current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
         self.assertEqual(uuid, current_deployment)
开发者ID:akalambu,项目名称:rally,代码行数:10,代码来源:test_cli_deployment.py


示例6: test_validate_is_invalid

 def test_validate_is_invalid(self):
     rally = utils.Rally()
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
     cfg = {"invalid": "config"}
     config = utils.TaskConfig(cfg)
     self.assertRaises(utils.RallyCliError,
                       rally,
                       ("task validate --task %(task_file)s "
                        "--deployment %(deployment_id)s") %
                       {"task_file": config.filename,
                        "deployment_id": deployment_id})
开发者ID:tiagoapr,项目名称:rally,代码行数:12,代码来源:test_cli_task.py


示例7: _test_start_abort_on_sla_failure

 def _test_start_abort_on_sla_failure(self, cfg, times):
     rally = utils.Rally()
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
         config = utils.TaskConfig(cfg)
         rally(("task start --task %(task_file)s "
                "--deployment %(deployment_id)s --abort-on-sla-failure") %
               {"task_file": config.filename,
                "deployment_id": deployment_id})
         results = json.loads(rally("task results"))
     iterations_completed = len(results[0]["result"])
     self.assertTrue(iterations_completed < times)
开发者ID:tiagoapr,项目名称:rally,代码行数:12,代码来源:test_cli_task.py


示例8: test_start

 def test_start(self):
     rally = utils.Rally()
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
         cfg = self._get_sample_task_config()
         config = utils.TaskConfig(cfg)
         output = rally(("task start --task %(task_file)s "
                         "--deployment %(deployment_id)s") %
                        {"task_file": config.filename,
                         "deployment_id": deployment_id})
     result = re.search(
         r"(?P<task_id>[0-9a-f\-]{36}): started", output)
     self.assertIsNotNone(result)
开发者ID:tiagoapr,项目名称:rally,代码行数:13,代码来源:test_cli_task.py


示例9: launch_verification_once

def launch_verification_once(launch_parameters):
    """Launch verification and show results in different formats."""
    results = call_rally("verify start %s" % launch_parameters)
    results["uuid"] = envutils.get_global(envutils.ENV_VERIFICATION)
    results["result_in_html"] = call_rally("verify results",
                                           output_type="html")
    results["result_in_json"] = call_rally("verify results",
                                           output_type="json")
    results["show"] = call_rally("verify show")
    results["show_detailed"] = call_rally("verify show --detailed")
    # NOTE(andreykurilin): we need to clean verification uuid from global
    # environment to be able to load it next time(for another verification).
    envutils.clear_global(envutils.ENV_VERIFICATION)
    return results
开发者ID:gluke77,项目名称:rally,代码行数:14,代码来源:rally_verify.py


示例10: setup

def setup(): 
    if CONF.profile:
        profile = CONF.profile
    else:
        profile = envutils.get_global("RALLY_PROFILE")
        if profile == None:
            profile = PROFILE_OPENSTACK
            
    if not profile in PROFILE_ALL_LIST:
        raise InvalidArgumentsException("Unknown profile %s" % profile)
    
    fileutils.update_globals_file("RALLY_PROFILE", profile)
    
    print("Using profile: %s" % profile)    
开发者ID:huikang,项目名称:rally,代码行数:14,代码来源:profile.py


示例11: list

    def list(self, api, deployment_list=None):
        """List existing deployments."""

        headers = ["uuid", "created_at", "name", "status", "active"]
        current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
        deployment_list = deployment_list or api.deployment.list()

        table_rows = []
        if deployment_list:
            for t in deployment_list:
                r = [str(t[column]) for column in headers[:-1]]
                r.append("" if t["uuid"] != current_deployment else "*")
                table_rows.append(utils.Struct(**dict(zip(headers, r))))
            cliutils.print_list(table_rows, headers,
                                sortby_index=headers.index("created_at"))
        else:
            print("There are no deployments. To create a new deployment, use:"
                  "\nrally deployment create")
开发者ID:jacobwagner,项目名称:rally,代码行数:18,代码来源:deployment.py


示例12: list

 def list(self, api, to_json=False):
     """List existing environments."""
     envs = env_mgr.EnvManager.list()
     if to_json:
         print(json.dumps([env.cached_data for env in envs], indent=2))
     elif not envs:
         print(self.MSG_NO_ENVS)
     else:
         cur_env = envutils.get_global(envutils.ENV_ENV)
         table = prettytable.PrettyTable()
         fields = ["uuid", "name", "status", "created_at", "description"]
         table.field_names = fields + ["default"]
         for env in envs:
             row = [env.cached_data[f] for f in fields]
             row.append(cur_env == env.cached_data["uuid"] and "*" or "")
             table.add_row(row)
         table.sortby = "created_at"
         table.reversesort = True
         table.align = "l"
         print(table.get_string())
开发者ID:jacobwagner,项目名称:rally,代码行数:20,代码来源:env.py


示例13: list_verifiers

    def list_verifiers(self, api, status=None):
        """List all verifiers."""

        verifiers = api.verifier.list(status=status)
        if verifiers:
            fields = ["UUID", "Name", "Type", "Platform", "Created at",
                      "Updated at", "Status", "Version", "System-wide",
                      "Active"]
            cv = envutils.get_global(envutils.ENV_VERIFIER)
            formatters = {
                "Created at": lambda v: v["created_at"],
                "Updated at": lambda v: v["updated_at"],
                "Active": lambda v: u"\u2714" if v["uuid"] == cv else "",
            }
            cliutils.print_list(verifiers, fields, formatters=formatters,
                                normalize_field_names=True, sortby_index=4)
        elif status:
            print("There are no verifiers with status '%s'." % status)
        else:
            print("There are no verifiers. You can create verifier, using "
                  "command `rally verify create-verifier`.")
开发者ID:andreykurilin,项目名称:rally,代码行数:21,代码来源:verify.py


示例14: test_get_task_id_with_none

 def test_get_task_id_with_none(self, mock_load_env_file):
     self.assertIsNone(envutils.get_global("RALLY_TASK"))
     mock_load_env_file.assert_called_once_with(os.path.expanduser(
         "~/.rally/globals"))
开发者ID:gwdg,项目名称:rally,代码行数:4,代码来源:test_envutils.py


示例15: test_get_task_id_in_env

 def test_get_task_id_in_env(self):
     self.assertEqual("my_task_id", envutils.get_global(envutils.ENV_TASK))
开发者ID:gwdg,项目名称:rally,代码行数:2,代码来源:test_envutils.py


示例16: test_get_deployment_id_in_env

 def test_get_deployment_id_in_env(self):
     deployment_id = envutils.get_global(envutils.ENV_DEPLOYMENT)
     self.assertEqual("my_deployment_id", deployment_id)
开发者ID:gwdg,项目名称:rally,代码行数:3,代码来源:test_envutils.py


示例17: test_get_deployment_id_with_none

 def test_get_deployment_id_with_none(self, mock_load_env_file):
     self.assertIsNone(envutils.get_global(envutils.ENV_DEPLOYMENT))
     mock_load_env_file.assert_called_once_with(os.path.expanduser(
         "~/.rally/globals"))
开发者ID:gwdg,项目名称:rally,代码行数:4,代码来源:test_envutils.py


示例18: results

    def results(self, uuids=None, output_file=None,
                output_html=False, output_json=False, output_csv=False):
        """Display results of verifications.

        :param verification: UUID of a verification
        :param output_file: Path to a file to save results
        :param output_json: Display results in JSON format (Default)
        :param output_html: Display results in HTML format
        :param output_csv: Display results in CSV format
        """
        if not uuids:
            uuid = envutils.get_global(envutils.ENV_VERIFICATION)
            if not uuid:
                raise exceptions.InvalidArgumentsException(
                    "Verification UUID is missing")
            uuids = [uuid]
        data = []
        for uuid in uuids:
            try:
                verification = api.Verification.get(uuid)
            except exceptions.NotFoundException as e:
                print(six.text_type(e))
                return 1
            data.append(verification)

        if output_json + output_html + output_csv > 1:
            print(_("Please specify only one format option from %s.")
                  % "--json, --html, --csv")
            return 1

        verifications = {}
        for ver in data:
            uuid = ver.db_object["uuid"]
            res = ver.get_results() or {}
            tests = {}
            for test in list(res.get("test_cases", {}).values()):
                name = test["name"]
                if name in tests:
                    mesg = ("Duplicated test in verification "
                            "%(uuid)s: %(test)s" % {"uuid": uuid,
                                                    "test": name})
                    raise exceptions.RallyException(mesg)
                tests[name] = {"tags": test["tags"],
                               "status": test["status"],
                               "duration": test["time"],
                               "details": (test.get("traceback", "").strip()
                                           or test.get("reason"))}
            verifications[uuid] = {
                "tests": tests,
                "duration": res.get("time", 0),
                "total": res.get("tests", 0),
                "skipped": res.get("skipped", 0),
                "success": res.get("success", 0),
                "expected_failures": res.get("expected_failures", 0),
                "unexpected_success": res.get("unexpected_success", 0),
                "failures": res.get("failures", 0),
                "started_at": ver.db_object[
                    "created_at"].strftime("%Y-%d-%m %H:%M:%S"),
                "finished_at": ver.db_object[
                    "updated_at"].strftime("%Y-%d-%m %H:%M:%S"),
                "status": ver.db_object["status"],
                "set_name": ver.db_object["set_name"]
            }

        if output_html:
            result = report.VerificationReport(verifications).to_html()
        elif output_csv:
            result = report.VerificationReport(verifications).to_csv()
        else:
            result = report.VerificationReport(verifications).to_json()

        if output_file:
            output_file = os.path.expanduser(output_file)
            with open(output_file, "wb") as f:
                f.write(result)
        else:
            print(result)
开发者ID:alinbalutoiu,项目名称:rally,代码行数:77,代码来源:verify.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python broker.run函数代码示例发布时间:2022-05-26
下一篇:
Python cliutils.validate_args函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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