sets environment variable if it does not exist already env variables are stringified when set
505799
function set(key, val) {
    return process.env[key] = (process.env[key] === undefined ? val : process.env[key]);
}
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
1165947
function checkEnv(tmp) {
      if(typeof tmp === 'string') {
        var up = tmp.toUpperCase();
        if(up.indexOf("$ENV:") !== -1) {
          var envVariable = tmp.substr(5).trim();
          if(typeof process.env[envVariable] === 'undefined') {
            console.error('Environment variable: %s is missing, in config file: %s', envVariable, self.path);
            return;
          }
          return process.env[envVariable];
        }
        if(up.indexOf('$ARGV:') !== -1) {
          var argName = tmp.substr(6).trim(),
            argVal = crux.argv(argName);
          if(!argVal) {
            console.error('Argv variable: %s is missing, in config file: %s', argName, self.path);
            return;
          }
          return argVal;
        }
        return;
      }
      if(typeof tmp === 'object' && tmp !== null) {
        if(tmp instanceof Array) {
          for(var i= 0, len = tmp.length; i < len; i++) {
            var replacedVar = checkEnv(tmp[i]);
            if(typeof replacedVar !== 'undefined') {
              tmp[i] = replacedVar;
            }
          }
          return;
        }
        for(var key in tmp) {
          var replacedVar = checkEnv(tmp[key]);
          if(typeof replacedVar !== 'undefined') {
            tmp[key] = replacedVar;
          }
        }
      }
    }
353106
def env(var_name, default=False):
    
    try:
        value = os.environ[var_name]
        if str(value).strip().lower() in ['false', 'f', 'no', 'off' '0', 'none', 'null', '', ]:
            return None
        return value
    except:
        from traceback import format_exc
        msg = "Unable to find the %s environment variable.\nUsing the value %s (the default) instead.\n" % (var_name, default)
        sys.stderr.write(format_exc())
        sys.stderr.write(msg)
        return default
931816
def set_env(user, name, value=None):
    '''
    
    '''
    lst = list_tab(user)
    for env in lst['env']:
        if name == env['name']:
            if value != env['value']:
                rm_env(user, name)
                jret = set_env(user, name, value)
                if jret == 'new':
                    return 'updated'
                else:
                    return jret
            return 'present'
    env = {'name': name, 'value': value}
    lst['env'].append(env)
    comdat = _write_cron_lines(user, _render_tab(lst))
    if comdat['retcode']:
        # Failed to commit, return the error
        return comdat['stderr']
    return 'new'
372658
function setEnvironment (settings) {
  // Choose between inherited environment and new environment:
  if (typeof settings.options.env !== "object") {
    settings.options.env = process.env;
  }

  // Set environment variables for GET and POST requests
  // if 'inputData' is available:
  if (settings.inputData) {
    settings.options.env = setInputEnvironmentVariables(settings);
  }

  return settings.options.env;
}
267948
private static String replaceEnvVars(final String val) {
        String ret = val;
        final String[] envVars = StringUtils.substringsBetween(ret, "${", "}");
        if (null != envVars) {
            for (int i = 0; i < envVars.length; i++) {
                final String envKey = envVars[i];
                String envVal = System.getenv(envKey);
                if (StringUtils.isBlank(envVal)) {
                    envVal = "";
                }

                ret = StringUtils.replace(ret, "${" + envKey + "}", envVal);
            }
        }

        return ret;
    }
1084739
public function setEnv($env)
    {
        $env = strtolower($env);
        if (strcmp($env, 'sandbox') || strcmp($env, 'production')) {
            $this->env = $env;
        } else {
            $this->env = 'production';
        }
    }
557197
def set_env(self, key, value):
        
        os.environ[make_env_key(self.appname, key)] = str(value)  # must coerce to string
        self._registered_env_keys.add(key)
        self._clear_memoization()
1357553
function applyEnvironmentVariables(opts) {
  // if we have a custom CouchDB url
  if (typeof process.env.COUCH_URL !== 'undefined') {
    opts.url = process.env.COUCH_URL;
  }

  // if we have a specified databases
  if (typeof process.env.COUCH_DATABASE !== 'undefined') {
    opts.db = process.env.COUCH_DATABASE;
  }

  // if we have a specified buffer size
  if (typeof process.env.COUCH_BUFFER_SIZE !== 'undefined') {
    opts.bufferSize = parseInt(process.env.COUCH_BUFFER_SIZE);
  }

  // if we have a specified parallelism
  if (typeof process.env.COUCH_PARALLELISM !== 'undefined') {
    opts.parallelism = parseInt(process.env.COUCH_PARALLELISM);
  }

  // if we have a specified request timeout
  if (typeof process.env.COUCH_REQUEST_TIMEOUT !== 'undefined') {
    opts.requestTimeout = parseInt(process.env.COUCH_REQUEST_TIMEOUT);
  }

  // if we have a specified log file
  if (typeof process.env.COUCH_LOG !== 'undefined') {
    opts.log = path.normalize(process.env.COUCH_LOG);
  }

  // if we are instructed to resume
  if (typeof process.env.COUCH_RESUME !== 'undefined' && process.env.COUCH_RESUME === 'true') {
    opts.resume = true;
  }

  // if we are given an output filename
  if (typeof process.env.COUCH_OUTPUT !== 'undefined') {
    opts.output = path.normalize(process.env.COUCH_OUTPUT);
  }

  // if we only want a shallow copy
  if (typeof process.env.COUCH_MODE !== 'undefined' && process.env.COUCH_MODE === 'shallow') {
    opts.mode = 'shallow';
  }

  // if we have a specified API key
  if (typeof process.env.CLOUDANT_IAM_API_KEY !== 'undefined') {
    opts.iamApiKey = process.env.CLOUDANT_IAM_API_KEY;
  }

  // if we have a specified IAM token endpoint
  if (typeof process.env.CLOUDANT_IAM_TOKEN_URL !== 'undefined') {
    opts.iamTokenUrl = process.env.CLOUDANT_IAM_TOKEN_URL;
  }
}
511219
def get_optional_env(key):
    
    environment_variable_value = os.environ.get(key)
    if environment_variable_value:
        return environment_variable_value
    elif key in CONSTANTS:
        return CONSTANTS[key]
    else:
        raise Exception("The variable {1} is not set".format(key))
850246
protected function checkEnvVariable()
    {
        $key = $this->checkKey();
        $output = $this->execSSH("cd $this->domain;cat .env");
        if (str_contains($output, $key)) {
            $this->info("Key $key found in remote environment file");
        } else {
            $this->error("Key $key NOT found in remote environment file");
        }
    }
330604
def set_environ(env_name, value):
    """"""
    value_changed = value is not None
    if value_changed:
        old_value = os.environ.get(env_name)
        os.environ[env_name] = value
    try:
        yield
    finally:
        if value_changed:
            if old_value is None:
                del os.environ[env_name]
            else:
                os.environ[env_name] = old_value
635030
public static function setEnv(array $env = [])
    {
        self::$envIsSet = true;

        foreach ($env as $variable => $value) {
            self::setEnvironmentVariable($variable, $value);
        }
    }
1230345
def initialize_env(env_file=None, fail_silently=True, load_globally=True):
    
    data = {}
    data.update(os.environ)
    if env_file:
        data.update(read_file_values(env_file, fail_silently))
    
    if load_globally:
        os.environ.update(data)
    
    return Environment(env_dict=data)
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
16651
private static void printEnvVariables() {
    System.out.println("Environment Variables: ");
    Map<String,String> map = System.getenv();
    Set<String> keys = map.keySet();
    Iterator iter = keys.iterator();
    while(iter.hasNext()) {
      String thiskey = (String)(iter.next()); 
      String value = map.get(thiskey);
      System.out.println(thiskey + " = " + value);
    }
  }