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


Python environ.keys方法代碼示例

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


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

示例1: ci

# 需要導入模塊: from os import environ [as 別名]
# 或者: from os.environ import keys [as 別名]
def ci(show_env: bool = False) -> int:
    # Output exact python version
    cp = run(("python", "-V"), check=True, stdout=PIPE, universal_newlines=True)
    print(f"Using {cp.stdout}", file=sys.stderr)

    if show_env:
        print("- Environment:", file=sys.stderr)
        for key in sorted(environ.keys()):
            print(f"{key}: {environ[key]}", file=sys.stderr)

    # Azure sets CI_ENV=PTR_INTEGRATION
    # Travis sets PTR_INTEGRATION=1
    if "PTR_INTEGRATION" in environ or (
        "CI_ENV" in environ and environ["CI_ENV"] == "PTR_INTEGRATION"
    ):
        return integration_test()

    print("Running `ptr` unit tests", file=sys.stderr)
    return run(("python", "ptr_tests.py", "-v"), check=True).returncode 
開發者ID:facebookincubator,項目名稱:ptr,代碼行數:21,代碼來源:ci.py

示例2: parse_args

# 需要導入模塊: from os import environ [as 別名]
# 或者: from os.environ import keys [as 別名]
def parse_args():
    """
    Parses the arguments
    Returns:
        argparse Namespace
    """
    assert 'project_root' in environ.keys()
    project_root = getenv('project_root')
    parser = argparse.ArgumentParser()

    parser.add_argument("--input",
                        type=str,
                        default=getenv('camera_stream'))

    parser.add_argument("--model",
                        type=str,
                        default=join(project_root,
                                     getenv('model_type')))

    parser.add_argument("--cpu",
                        dest="use_cuda",
                        action="store_false", default=True)
    args = parser.parse_args()

    return args 
開發者ID:ZQPei,項目名稱:deep_sort_pytorch,代碼行數:27,代碼來源:rtsp_webserver.py

示例3: teardown_environment

# 需要導入模塊: from os import environ [as 別名]
# 或者: from os.environ import keys [as 別名]
def teardown_environment():
    """Restore things that were remembered by the setup_environment function
    """
    orig_env = GIVEN_ENV['env']
    for key in env.keys():
        if key not in orig_env:
            del env[key]
    env.update(orig_env)


# decorator to use setup, teardown environment 
開發者ID:ME-ICA,項目名稱:me-ica,代碼行數:13,代碼來源:test_environment.py

示例4: get

# 需要導入模塊: from os import environ [as 別名]
# 或者: from os.environ import keys [as 別名]
def get(self, key):
        name = 'TXTRADER%s_%s' % (self.label, key)
        if not name in environ.keys():
            #print('Config.get(%s): %s not found in %s' % (key, name, environ.keys()))
            name = 'TXTRADER_%s' % key
        if not name in environ.keys():
            print('ALERT: Config.get(%s) failed' % key)
        return environ[name] 
開發者ID:rstms,項目名稱:txTrader,代碼行數:10,代碼來源:config.py

示例5: assert_in_env

# 需要導入模塊: from os import environ [as 別名]
# 或者: from os.environ import keys [as 別名]
def assert_in_env(check_list: list):
    for item in check_list:
        assert_in(item, environ.keys())
    return True 
開發者ID:ZQPei,項目名稱:deep_sort_pytorch,代碼行數:6,代碼來源:asserts.py

示例6: check_ptr_stats_json

# 需要導入模塊: from os import environ [as 別名]
# 或者: from os.environ import keys [as 別名]
def check_ptr_stats_json(stats_file: Path) -> int:
    stats_errors = 0

    if not stats_file.exists():
        print(f"{stats_file} stats file does not exist")
        return 68

    try:
        with stats_file.open("r") as sfp:
            stats_json = json.load(sfp)
    except json.JSONDecodeError as jde:
        print(f"Stats JSON Error: {jde}")
        return 69

    # Lets always print JSON to help debug any failures and have JSON history
    print(json.dumps(stats_json, indent=2, sort_keys=True))

    any_fail = int(stats_json["total.fails"]) + int(stats_json["total.timeouts"])
    if any_fail:
        print(f"Stats report {any_fail} fails/timeouts", file=sys.stderr)
        return any_fail

    if int(stats_json["total.setup_pys"]) > 1:
        print("Somehow we had more than 1 setup.py - What?", file=sys.stderr)
        stats_errors += 1

    if int(stats_json["pct.setup_py_ptr_enabled"]) != 100:
        print("We didn't test all setup.py files ...", file=sys.stderr)
        stats_errors += 1

    # TODO: Make getting project name better - For now quick CI hack
    coverage_key_count = 0
    for key in stats_json.keys():
        if "_coverage." in key:
            coverage_key_count += 1
    if coverage_key_count != 4:
        print("We didn't get coverage stats for all ptr files + total", file=sys.stderr)
        stats_errors += 1

    print(f"Stats check found {stats_errors} error(s)")

    return stats_errors 
開發者ID:facebookincubator,項目名稱:ptr,代碼行數:44,代碼來源:ci.py


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