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


Python environ.copy方法代码示例

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


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

示例1: disconnect_telepresence

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def disconnect_telepresence(namespace):
    # Kill off sshd server process the SSH client is talking to, forcing
    # disconnection:
    env = environ.copy()
    # Don't want torsocks messing with kubectl:
    for name in ["LD_PRELOAD", "DYLD_INSERT_LIBRARIES"]:
        if name in env:
            del env[name]
    # We can't tell if this succeeded, sadly, since it kills ssh session used
    # by kubectl exec!
    command = [
        "kubectl", "exec", "--namespace=" + namespace,
        "--container=" + environ["TELEPRESENCE_CONTAINER"],
        environ["TELEPRESENCE_POD"], "--", "/bin/sh", "-c",
        r"kill $(ps xa | tail -n +2 | " + r"sed 's/ *\([0-9][0-9]*\).*/\1/')"
    ]
    print("Using kubectl to kill Telepresence support processes:")
    print("\t{}".format(" ".join(command)), flush=True)

    run(command, env=env)
    sleep(10)
    # The test expects 3, which is how telepresence exits when one of its
    # subprocesses dies. That is, we expect to be killed before we reach this
    # point, if we exit with 66 that means disconnect-detection failed.
    raise SystemExit(66) 
开发者ID:telepresenceio,项目名称:telepresence,代码行数:27,代码来源:probe_endtoend.py

示例2: setup_environment

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def setup_environment():
    """Setup test environment for some functions that are tested
    in this module. In particular this functions stores attributes
    and other things that we need to stub in some test functions.
    This needs to be done on a function level and not module level because
    each testfunction needs a pristine environment.
    """
    global GIVEN_ENV
    GIVEN_ENV['env'] = env.copy() 
开发者ID:ME-ICA,项目名称:me-ica,代码行数:11,代码来源:test_environment.py

示例3: GetCompilerType

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def GetCompilerType(env):
    try:
        sysenv = environ.copy()
        sysenv['PATH'] = str(env['ENV']['PATH'])
        result = exec_command([env.subst("$CC"), "-v"], env=sysenv)
    except OSError:
        return None
    if result['returncode'] != 0:
        return None
    output = "".join([result['out'], result['err']]).lower()
    for type_ in ("clang", "gcc"):
        if type_ in output:
            return type_
    return None 
开发者ID:bq,项目名称:web2board,代码行数:16,代码来源:piomisc.py

示例4: _set_build_env

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def _set_build_env(build_base_path: Optional[Path]) -> Dict[str, str]:
    build_environ = environ.copy()

    if not build_base_path or not build_base_path.exists():
        if build_base_path:
            LOG.error(
                f"Configured local build env path {build_base_path} does not exist"
            )
        return build_environ

    if build_base_path.exists():
        build_env_vars = [
            (
                ("PATH", build_base_path / "Scripts")
                if WINDOWS
                else ("PATH", build_base_path / "sbin")
            ),
            ("C_INCLUDE_PATH", build_base_path / "include"),
            ("CPLUS_INCLUDE_PATH", build_base_path / "include"),
        ]
        if not WINDOWS:
            build_env_vars.append(("PATH", build_base_path / "bin"))

        for var_name, value in build_env_vars:
            if var_name in build_environ:
                build_environ[var_name] = f"{value}:{build_environ[var_name]}"
            else:
                build_environ[var_name] = str(value)
    else:
        LOG.error(
            "{} does not exist. Not add int PATH + INCLUDE Env variables".format(
                build_base_path
            )
        )

    return build_environ 
开发者ID:facebookincubator,项目名称:ptr,代码行数:38,代码来源:ptr.py

示例5: raster2pgsql

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def raster2pgsql():
    """
    Imports SRTM v4.1 tiles to PostGIS.
    
    :raises subprocess.CalledProcessError: Raised when raster2pgsql throws an error.
    """
    
    pg_settings = SETTINGS['provider_parameters']
    
    # Copy all env variables and add PGPASSWORD
    env_current = environ.copy()
    env_current['PGPASSWORD'] = pg_settings['password']
    
    # Tried to import every raster individually by user-specified xyrange 
    # similar to download(), but raster2pgsql fuck it up somehow.. The PostGIS
    # raster will not be what one would expect. Instead doing a bulk import of all files.
    cmd_raster2pgsql = r"raster2pgsql -s 4326 -a -C -M -P -t 50x50 {filename} {table_name} | psql -q -h {host} -p {port} -U {user_name} -d {db_name}"
    # -s: raster SRID
    # -a: append to table (assumes it's been create with 'create()')
    # -C: apply all raster Constraints
    # -P: pad tiles to guarantee all tiles have the same width and height
    # -M: vacuum analyze after import
    # -t: specifies the pixel size of each row. Important to keep low for performance!
    
    cmd_raster2pgsql = cmd_raster2pgsql.format(**{'filename': path.join(TILES_DIR, '*.tif'),
                                                  **pg_settings})
    
    proc = subprocess.Popen(cmd_raster2pgsql,
                         stdout=subprocess.PIPE, 
                         stderr=subprocess.STDOUT,
                         shell=True,
                         env=env_current
                         )
    
#    for line in proc.stdout:
#        log.debug(line.decode())
#    proc.stdout.close()
    return_code = proc.wait()
    if return_code:
        raise subprocess.CalledProcessError(return_code, cmd_raster2pgsql) 
开发者ID:GIScience,项目名称:openelevationservice,代码行数:42,代码来源:filestreams.py

示例6: without_jira_vars

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def without_jira_vars():
    backup = environ.copy()
    del environ['JIRA_PROJECT']
    del environ['JIRA_USER']
    del environ['JIRA_PASSWORD']
    del environ['JIRA_URL']
    reload(jira)
    yield
    environ.update(backup)
    reload(jira) 
开发者ID:snowflakedb,项目名称:SnowAlert,代码行数:12,代码来源:SP1099_missing_jira_env_vars.py

示例7: call_exit_errors

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def call_exit_errors(command):
    print("+ {}".format(" ".join(command)))
    rc = call(command, env=environ.copy())
    if rc > 0:
       exit(rc) 
开发者ID:mozilla,项目名称:telemetry-airflow,代码行数:7,代码来源:telemetry_batch_view.py

示例8: __init__

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def __init__(self):
        makedirs(DAGS_FOLDER, mode=0o0775, exist_ok=True)
        extend_env = {"AIRFLOW__CORE__LOGGING_LEVEL": "ERROR"}
        self.env = environ.copy()
        self.env.update(extend_env) 
开发者ID:Barski-lab,项目名称:cwl-airflow,代码行数:7,代码来源:backend.py

示例9: execute_reproducer

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def execute_reproducer(self, cgroup, inputfile, functionname):
        menv = environ.copy()
        menv["ASAN_OPTIONS"] = "detect_leaks=0"
        infd = open(inputfile, "r")
        (returncode, stdoutdata, stderrdata) = cgroups_run_timed_subprocess(
            [self.reproducer, "--fuzz-driver=" + functionname], cgroup=cgroup, stdin=infd, env=menv)
        ret = AsanResult(stderrdata, inputfile, functionname)
        infd.close()
        return ret

    # Function to check for saturation of AFL 
开发者ID:tum-i22,项目名称:macke,代码行数:13,代码来源:Fuzzer.py

示例10: execute_afl_tmin

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def execute_afl_tmin(self, cgroup, inputfile, outputfile, functionname):
        asan_env = environ.copy()
        asan_env["AFL_USE_ASAN"] = "1"
        return cgroups_run_checked_silent_subprocess([AFLTMIN, "-e", "-t", "50", "-i", inputfile, "-o", outputfile, "-m", "none", "--", self.minimizer, "--fuzz-driver=" + functionname], cgroup, env=asan_env) 
开发者ID:tum-i22,项目名称:macke,代码行数:6,代码来源:Fuzzer.py

示例11: build_notebook

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def build_notebook(nb_file, no_embed=False, tag=""):
    env = environ.copy()  # Pass argument to exporter via environment
    yaml_path = mktemp('.yaml')
    py_path = ''
    code = ''
    if no_embed:
        py_path = mktemp('.py')
        env[env_keys.code_target_path] = py_path
    env[env_keys.drop_nb_outputs] = 'y'

    cmd = [
        executable, '-m', 'nbconvert',
        '--to', 'nuclio.export.NuclioExporter',
        '--output', yaml_path,
        nb_file,
    ]
    out = run(cmd, env=env, stdout=PIPE, stderr=PIPE)
    if out.returncode != 0:
        print(out.stdout.decode('utf-8'))
        print(out.stderr.decode('utf-8'), file=stderr)
        raise BuildError('cannot convert notebook')

    if not path.isfile(yaml_path):
        raise BuildError('failed to convert, tmp file %s not found', yaml_path)

    with open(yaml_path) as yp:
        config_data = yp.read()
    config = yaml.safe_load(config_data)
    os.remove(yaml_path)

    if py_path:
        with open(py_path) as pp:
            code = pp.read()
        os.remove(py_path)

    return config, code 
开发者ID:nuclio,项目名称:nuclio-jupyter,代码行数:38,代码来源:build.py

示例12: pipe_output

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def pipe_output(read, write):
    from os import environ
    environ = environ.copy()

    from subprocess import Popen
    vupdate = Popen(
        ('venv-update', 'venv=', '--version'),
        env=environ,
        stdout=write,
        close_fds=True,
    )

    from os import close
    from testing.capture_subprocess import read_all
    close(write)
    result = read_all(read)
    vupdate.wait()

    result = result.decode('US-ASCII')
    print(result)
    uncolored = uncolor(result)
    assert uncolored.startswith('> ')
    # FIXME: Sometimes this is 'python -m', sometimes 'python2.7 -m'. Weird.
    import virtualenv
    assert uncolored.endswith('''
> virtualenv --version
%s
''' % virtualenv.__version__)

    return result, uncolored 
开发者ID:Yelp,项目名称:venv-update,代码行数:32,代码来源:simple_test.py

示例13: run

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def run(*cmd, **env):
    if env:
        from os import environ
        tmp = env
        env = environ.copy()
        env.update(tmp)
    else:
        env = None

    from .capture_subprocess import capture_subprocess
    from venv_update import info, colorize
    info('\nTEST> ' + colorize(cmd))
    out, err = capture_subprocess(cmd, env=env)
    err = strip_coverage_warnings(err)
    return out, err 
开发者ID:Yelp,项目名称:venv-update,代码行数:17,代码来源:__init__.py

示例14: patch_and_capture_env_for_download_all_image_descriptions

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def patch_and_capture_env_for_download_all_image_descriptions(testcase):
    class CaptureEnv:
        """Fake function; records a copy of the environment."""

        def __call__(self, *args, **kwargs):
            self.args = args
            self.env = environ.copy()
            return MagicMock()

    capture = testcase.patch(
        bootsources, "download_all_image_descriptions", CaptureEnv()
    )
    return capture 
开发者ID:maas,项目名称:maas,代码行数:15,代码来源:test_bootsources.py

示例15: patch_and_capture_env_for_download_all_boot_resources

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import copy [as 别名]
def patch_and_capture_env_for_download_all_boot_resources(self):
        class CaptureEnv:
            """Fake function; records a copy of the environment."""

            def __call__(self, *args, **kwargs):
                self.args = args
                self.env = environ.copy()

        capture = self.patch(
            bootresources, "download_all_boot_resources", CaptureEnv()
        )
        return capture 
开发者ID:maas,项目名称:maas,代码行数:14,代码来源:test_bootresources.py


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