Add an environment variable to the launched process.
542766
public void addEnv(final Environment.Variable var) {
    if (this.env == null) {
      this.env = new Environment();
      this.newEnvironment = true;
      if (this.processor != null) {
        // Change the environment in the processor
        setProcessor(this.processor);
      }
    }
    this.env.addVariable(var);
  }
186346
def init(envVarName, enableColorOutput=False):
    
    global _initialized

    if _initialized:
        return

    global _ENV_VAR_NAME
    _ENV_VAR_NAME = envVarName

    if enableColorOutput:
        _preformatLevels(envVarName + "_NO_COLOR")
    else:
        _preformatLevels(None)

    if envVarName in os.environ:
        # install a log handler that uses the value of the environment var
        setDebug(os.environ[envVarName])
    addLimitedLogHandler(stderrHandler)

    _initialized = True
330614
def update_environment(lib_directory):
        """"""
        # Use this if you want to include modules from a subfolder
        # lib_path = os.path.realpath(
        #     os.path.abspath(
        #         os.path.join(
        #             os.path.split(inspect.getfile(inspect.currentframe()))[0], lib_directory)))
        lib_path = os.path.join(os.getcwd(), lib_directory)
        if 'PYTHONPATH' in os.environ:
            os.environ['PYTHONPATH'] = '{}{}{}'.format(
                lib_path, os.pathsep, os.environ['PYTHONPATH']
            )
        else:
            os.environ['PYTHONPATH'] = '{}'.format(lib_path)
612384
@Override
    public void buildEnvironment(Run<?,?> build, EnvVars env) {
        env.put(name,value);
        env.put(name.toUpperCase(Locale.ENGLISH),value); // backward compatibility pre 1.345
    }
379425
public void setEnvironmentVariables(Map<String, String> environment) {
    for (Map.Entry<String, String> entry : environment.entrySet()) {
      setEnvironmentVariable(entry.getKey(), entry.getValue());
    }
  }
214808
def add_all_to_env(env):
    """"""
    add_fortran_to_env(env)
    add_f77_to_env(env)
    add_f90_to_env(env)
    add_f95_to_env(env)
    add_f03_to_env(env)
    add_f08_to_env(env)
757871
def make(env_name, *args, **kwargs):
    """"""
    if env_name not in REGISTERED_ENVS:
        raise Exception(
            "Environment {} not found. Make sure it is a registered environment among: {}".format(
                env_name, ", ".join(REGISTERED_ENVS)
            )
        )
    return REGISTERED_ENVS[env_name](*args, **kwargs)
947270
protected function init()
    {
        $this->addCommand(CopyConfigCommand::class);
        $this->addCommand(InstallCommand::class);

        $this->addGlobalOption('e')
            ->alias('env')
            ->description('The environment application name or class.')
            ->defaultValue('dev');
    }
658590
def _include_environment_variables(self, program, executor_vars):
        """"""
        env_vars = {
            'RESOLWE_HOST_URL': self.settings_actual.get('RESOLWE_HOST_URL', 'localhost'),
        }

        set_env = self.settings_actual.get('FLOW_EXECUTOR', {}).get('SET_ENV', {})
        env_vars.update(executor_vars)
        env_vars.update(set_env)

        export_commands = ['export {}={}'.format(key, shlex.quote(value)) for key, value in env_vars.items()]
        return os.linesep.join(export_commands) + os.linesep + program
1075185
def SetEnvironmentVariable(self, name, value):
    
    if isinstance(value, py2to3.STRING_TYPES):
      value = self._PathStripPrefix(value)

    if value is not None:
      self._environment_variables[name.upper()] = value
987740
def setup(basepath=DEFAULT_BASEPATH):
    """"""

    module_version = os.environ.get('MODULE_VERSION', DEFAULT_VERSION)
    moduleshome = os.path.join(basepath, module_version)

    # Abort if MODULESHOME does not exist
    if not os.path.isdir(moduleshome):
        print('payu: warning: MODULESHOME does not exist; disabling '
              'environment modules.')
        os.environ['MODULESHOME'] = ''
        return

    os.environ['MODULE_VERSION'] = module_version
    os.environ['MODULE_VERSION_STACK'] = module_version
    os.environ['MODULESHOME'] = moduleshome

    if 'MODULEPATH' not in os.environ:
        module_initpath = os.path.join(moduleshome, 'init', '.modulespath')
        with open(module_initpath) as initpaths:
            modpaths = [
                line.partition('#')[0].strip()
                for line in initpaths.readlines() if not line.startswith('#')
            ]

        os.environ['MODULEPATH'] = ':'.join(modpaths)

    os.environ['LOADEDMODULES'] = os.environ.get('LOADEDMODULES', '')

    # Environment modules with certain characters will cause corruption
    # when MPI jobs get launched on other nodes (possibly a PBS issue).
    #
    # Bash processes obscure the issue on Raijin, since it occurs in an
    # environment module function, and bash moves those to the end of
    # the environment variable list.
    #
    # Raijin's mpirun wrapper is a bash script, and therefore "fixes" by doing
    # the shuffle and limiting the damage to other bash functions, but some
    # wrappers (e.g. OpenMPI 2.1.x) may not be present.  So we manually patch
    # the problematic variable here.  But a more general solution would be nice
    # someday.

    if 'BASH_FUNC_module()' in os.environ:
        bash_func_module = os.environ['BASH_FUNC_module()']
        os.environ['BASH_FUNC_module()'] = bash_func_module.replace('\n', ';')
1273572
def extend_env(conn, arguments):
    
    # retrieve the remote environment variables for the host
    try:
        result = conn.gateway.remote_exec("import os; channel.send(os.environ.copy())")
        env = result.receive()
    except Exception:
        conn.logger.exception('failed to retrieve the remote environment variables')
        env = {}

    # get the $PATH and extend it (do not overwrite)
    path = env.get('PATH', '')
    env['PATH'] = path + '/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin'
    arguments['env'] = env
    if arguments.get('extend_env'):
        for key, value in arguments['extend_env'].items():
            arguments['env'][key] = value
        arguments.pop('extend_env')
    return arguments
1202225
def from_env(cls):
        """"""
        token = getenv(cls.TOKEN_ENV_VAR)
        if token is None:
            msg = 'missing environment variable: {!r}'.format(cls.TOKEN_ENV_VAR)
            raise ValueError(msg)
        return cls(api_token=token)
950174
def init_project_env(subject='Automation', proj_path = None, sysencoding = "utf-8", debug = False):
    '''  '''    
        
#     if sysencoding:
#         set_sys_encode(sysencoding)
    
    if not proj_path:
        try:
            executable_file_path = os.path.dirname(os.path.abspath(inspect.stack()[-1][1]))
        except:
            executable_file_path = os.path.dirname(sys.path[0])
        finally:
            proj_path = executable_file_path
    
    p = os.path.join(proj_path,subject)
    
    proj_conf = {
        "sys_coding" : sysencoding,
        "debug" : debug,
        "module_name" : os.path.splitext(os.path.basename(subject))[0],
        "cfg_file" : os.path.join(p,"config.ini"),
        "path" : {"root" : p,
                  "case" : os.path.join(p,"testcase"),
                  "data" : os.path.join(p,"data"),
                  "buffer" : os.path.join(p,"buffer"),
                  "resource" : os.path.join(p,"resource"),
                  "tools" : os.path.join(p,"tools"),
                  "rst" : os.path.join(p,"result"),
                  "rst_log" : os.path.join(p,"result","testcase"),
                  "rst_shot" : os.path.join(p,"result","screenshots"),
            },
        }
     
    [FileSystemUtils.mkdirs(v) for v in proj_conf["path"].values()]    
    sys.path.append(p) if os.path.isdir(p) else ""
    return proj_conf
1081420
def environment_variables
      vars = @process.environment_variables.merge({
        'PROC_NAME' => self.description,
        'PID_FILE' => self.pid_file_path,
        'APP_ROOT' => @process.config.root
      })
      vars['PORT'] = @port.to_s if @port
      vars
    end
625023
@Override
    public void buildEnvironment(Run<?,?> build, EnvVars env) {
        env.put(name,originalFileName);
    }
424797
def _env(self, line):
        '''
   
        '''
        line = self._setup('ENV', line)

        # Extract environment (list) from the line
        environ = parse_env(line)

        # Add to global environment, run during install
        self.install += environ

        # Also define for global environment
        self.environ += environ