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


Python environ.update方法代码示例

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


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

示例1: deploy_clojure

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [as 别名]
def deploy_clojure(app, deltas={}):
    """Deploy a Clojure Application"""

    virtual = join(ENV_ROOT, app)
    target_path = join(APP_ROOT, app, 'target')
    env_file = join(APP_ROOT, app, 'ENV')

    if not exists(target_path):
        makedirs(virtual)
    env = {
        'VIRTUAL_ENV': virtual,
        "PATH": ':'.join([join(virtual, "bin"), join(app, ".bin"), environ['PATH']]),
        "LEIN_HOME": environ.get('LEIN_HOME', join(environ['HOME'], '.lein')),
    }
    if exists(env_file):
        env.update(parse_settings(env_file, env))
    echo("-----> Building Clojure Application")
    call('lein clean', cwd=join(APP_ROOT, app), env=env, shell=True)
    call('lein uberjar', cwd=join(APP_ROOT, app), env=env, shell=True)

    return spawn_app(app, deltas) 
开发者ID:piku,项目名称:piku,代码行数:23,代码来源:piku.py

示例2: deploy_go

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [as 别名]
def deploy_go(app, deltas={}):
    """Deploy a Go application"""

    go_path = join(ENV_ROOT, app)
    deps = join(APP_ROOT, app, 'Godeps')

    first_time = False
    if not exists(go_path):
        echo("-----> Creating GOPATH for '{}'".format(app), fg='green')
        makedirs(go_path)
        # copy across a pre-built GOPATH to save provisioning time
        call('cp -a $HOME/gopath {}'.format(app), cwd=ENV_ROOT, shell=True)
        first_time = True

    if exists(deps):
        if first_time or getmtime(deps) > getmtime(go_path):
            echo("-----> Running godep for '{}'".format(app), fg='green')
            env = {
                'GOPATH': '$HOME/gopath',
                'GOROOT': '$HOME/go',
                'PATH': '$PATH:$HOME/go/bin',
                'GO15VENDOREXPERIMENT': '1'
            }
            call('godep update ...', cwd=join(APP_ROOT, app), env=env, shell=True)
    return spawn_app(app, deltas) 
开发者ID:piku,项目名称:piku,代码行数:27,代码来源:piku.py

示例3: cmd_git_receive_pack

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [as 别名]
def cmd_git_receive_pack(app):
    """INTERNAL: Handle git pushes for an app"""

    app = sanitize_app_name(app)
    hook_path = join(GIT_ROOT, app, 'hooks', 'post-receive')
    env = globals()
    env.update(locals())

    if not exists(hook_path):
        makedirs(dirname(hook_path))
        # Initialize the repository with a hook to this script
        call("git init --quiet --bare " + app, cwd=GIT_ROOT, shell=True)
        with open(hook_path, 'w') as h:
            h.write("""#!/usr/bin/env bash
set -e; set -o pipefail;
cat | PIKU_ROOT="{PIKU_ROOT:s}" {PIKU_SCRIPT:s} git-hook {app:s}""".format(**env))
        # Make the hook executable by our user
        chmod(hook_path, stat(hook_path).st_mode | S_IXUSR)
    # Handle the actual receive. We'll be called with 'git-hook' after it happens
    call('git-shell -c "{}" '.format(argv[1] + " '{}'".format(app)), cwd=GIT_ROOT, shell=True) 
开发者ID:piku,项目名称:piku,代码行数:22,代码来源:piku.py

示例4: test_module

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [as 别名]
def test_module(self):
        environ.pop('DJANGO_ADMINS', None)
        environ.update({
            'DJANGO_DEBUG': 'true',
            'DJANGO_INTERNAL_IPS': '127.0.0.1, 10.0.0.1',
            'DJANGO_FILE_UPLOAD_DIRECTORY_PERMISSIONS': '0o644',
            'DJANGO_SECRET_KEY': '123',
        })

        from . import settings_example as settings

        self.assertEqual(global_settings.DEBUG, False)
        self.assertEqual(settings.DEBUG, True)
        if django.VERSION[:2] >= (1, 9):
            self.assertListEqual(settings.INTERNAL_IPS, ['127.0.0.1', '10.0.0.1'])
        else:
            self.assertTupleEqual(settings.INTERNAL_IPS, ('127.0.0.1', '10.0.0.1'))
        self.assertIsNone(global_settings.FILE_UPLOAD_DIRECTORY_PERMISSIONS)
        self.assertEqual(settings.FILE_UPLOAD_DIRECTORY_PERMISSIONS, 420) 
开发者ID:5monkeys,项目名称:django-bananas,代码行数:21,代码来源:tests.py

示例5: teardown_environment

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [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

示例6: deploy_gradle

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [as 别名]
def deploy_gradle(app, deltas={}):
    """Deploy a Java application using Gradle"""
    java_path = join(ENV_ROOT, app)
    build_path = join(APP_ROOT, app, 'build')
    env_file = join(APP_ROOT, app, 'ENV')

    env = {
        'VIRTUAL_ENV': java_path,
        "PATH": ':'.join([join(java_path, "bin"), join(app, ".bin"), environ['PATH']])
    }

    if exists(env_file):
        env.update(parse_settings(env_file, env))

    if not exists(java_path):
        makedirs(java_path)

    if not exists(build_path):
        echo("-----> Building Java Application")
        call('gradle build', cwd=join(APP_ROOT, app), env=env, shell=True)

    else:
        echo("-----> Removing previous builds")
        echo("-----> Rebuilding Java Application")
        call('gradle clean build', cwd=join(APP_ROOT, app), env=env, shell=True)

    return spawn_app(app, deltas) 
开发者ID:piku,项目名称:piku,代码行数:29,代码来源:piku.py

示例7: deploy_java

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [as 别名]
def deploy_java(app, deltas={}):
    """Deploy a Java application using Maven"""
    # TODO: Use jenv to isolate Java Application environments

    java_path = join(ENV_ROOT, app)
    target_path = join(APP_ROOT, app, 'target')
    env_file = join(APP_ROOT, app, 'ENV')

    env = {
        'VIRTUAL_ENV': java_path,
        "PATH": ':'.join([join(java_path, "bin"), join(app, ".bin"), environ['PATH']])
    }

    if exists(env_file):
        env.update(parse_settings(env_file, env))

    if not exists(java_path):
        makedirs(java_path)

    if not exists(target_path):
        echo("-----> Building Java Application")
        call('mvn package', cwd=join(APP_ROOT, app), env=env, shell=True)

    else:
        echo("-----> Removing previous builds")
        echo("-----> Rebuilding Java Application")
        call('mvn clean package', cwd=join(APP_ROOT, app), env=env, shell=True)

    return spawn_app(app, deltas) 
开发者ID:piku,项目名称:piku,代码行数:31,代码来源:piku.py

示例8: deploy_python

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [as 别名]
def deploy_python(app, deltas={}):
    """Deploy a Python application"""

    virtualenv_path = join(ENV_ROOT, app)
    requirements = join(APP_ROOT, app, 'requirements.txt')
    env_file = join(APP_ROOT, app, 'ENV')
    # Peek at environment variables shipped with repo (if any) to determine version
    env = {}
    if exists(env_file):
        env.update(parse_settings(env_file, env))

    # TODO: improve version parsing
    # pylint: disable=unused-variable
    version = int(env.get("PYTHON_VERSION", "3"))

    first_time = False
    if not exists(virtualenv_path):
        echo("-----> Creating virtualenv for '{}'".format(app), fg='green')
        makedirs(virtualenv_path)
        call('virtualenv --python=python{version:d} {app:s}'.format(**locals()), cwd=ENV_ROOT, shell=True)
        first_time = True

    activation_script = join(virtualenv_path, 'bin', 'activate_this.py')
    exec(open(activation_script).read(), dict(__file__=activation_script))

    if first_time or getmtime(requirements) > getmtime(virtualenv_path):
        echo("-----> Running pip for '{}'".format(app), fg='green')
        call('pip install -r {}'.format(requirements), cwd=virtualenv_path, shell=True)
    return spawn_app(app, deltas) 
开发者ID:piku,项目名称:piku,代码行数:31,代码来源:piku.py

示例9: cmd_run

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [as 别名]
def cmd_run(app, cmd):
    """e.g.: piku run <app> ls -- -al"""

    app = exit_if_invalid(app)

    config_file = join(ENV_ROOT, app, 'LIVE_ENV')
    environ.update(parse_settings(config_file))
    for f in [stdout, stderr]:
        fl = fcntl(f, F_GETFL)
        fcntl(f, F_SETFL, fl | O_NONBLOCK)
    p = Popen(' '.join(cmd), stdin=stdin, stdout=stdout, stderr=stderr, env=environ, cwd=join(APP_ROOT, app), shell=True)
    p.communicate() 
开发者ID:piku,项目名称:piku,代码行数:14,代码来源:piku.py

示例10: cmd_git_upload_pack

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [as 别名]
def cmd_git_upload_pack(app):
    """INTERNAL: Handle git upload pack for an app"""
    app = sanitize_app_name(app)
    env = globals()
    env.update(locals())
    # Handle the actual receive. We'll be called with 'git-hook' after it happens
    call('git-shell -c "{}" '.format(argv[1] + " '{}'".format(app)), cwd=GIT_ROOT, shell=True) 
开发者ID:piku,项目名称:piku,代码行数:9,代码来源:piku.py

示例11: use_matplot

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [as 别名]
def use_matplot():
        from matplotlib import use as mpl_use

        # Fix possible problems with Mac OS X venv backend
        if platform == "darwin":
            mpl_use("TkAgg")
            environ.update({"TK_SILENCE_DEPRECATION": "1"})

        from matplotlib import pyplot as _plot
        global plot
        plot = _plot 
开发者ID:sdnewhop,项目名称:grinder,代码行数:13,代码来源:plots.py

示例12: without_jira_vars

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [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

示例13: temp_env

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [as 别名]
def temp_env(kw):
    old = {k: environ.get(k) for k in kw}
    environ.update(kw)
    try:
        yield
    finally:
        for key, value in old.items():
            if value:
                environ[key] = value
            else:
                del environ[key] 
开发者ID:nuclio,项目名称:nuclio-jupyter,代码行数:13,代码来源:test_export.py

示例14: params

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [as 别名]
def params(cls):
        """ Define configuration parameters.

        """
        environ.update({"env1": "ENV1", "env2": "ENV2"})
        return {"var1": "VAR1", "var2": "VAR2", "var3": "VAR3", "env2": "VAR2"} 
开发者ID:mdklatt,项目名称:cookiecutter-python-app,代码行数:8,代码来源:test_config.py

示例15: clean_state

# 需要导入模块: from os import environ [as 别名]
# 或者: from os.environ import update [as 别名]
def clean_state(self):
        """
        Cleans up the state.
        """
        if path.exists(self.state_file):
            remove(self.state_file)
        environ.update(self.old_environ) 
开发者ID:CentOS,项目名称:container-pipeline-service,代码行数:9,代码来源:state.py


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