Checks for environment variables that can cause problems with supernova
6668
def check_environment_presets():
    
    presets = [x for x in os.environ.copy().keys() if x.startswith('NOVA_') or
               x.startswith('OS_')]
    if len(presets) < 1:
        return True
    else:
        click.echo("_" * 80)
        click.echo("*WARNING* Found existing environment variables that may "
                   "cause conflicts:")
        for preset in presets:
            click.echo("  - %s" % preset)
        click.echo("_" * 80)
        return False
1372549
def _env_is_exposed(env):
    '''
    
    '''
    if __opts__['svnfs_env_whitelist']:
        salt.utils.versions.warn_until(
            'Neon',
            'The svnfs_env_whitelist config option has been renamed to '
            'svnfs_saltenv_whitelist. Please update your configuration.'
        )
        whitelist = __opts__['svnfs_env_whitelist']
    else:
        whitelist = __opts__['svnfs_saltenv_whitelist']

    if __opts__['svnfs_env_blacklist']:
        salt.utils.versions.warn_until(
            'Neon',
            'The svnfs_env_blacklist config option has been renamed to '
            'svnfs_saltenv_blacklist. Please update your configuration.'
        )
        blacklist = __opts__['svnfs_env_blacklist']
    else:
        blacklist = __opts__['svnfs_saltenv_blacklist']

    return salt.utils.stringutils.check_whitelist_blacklist(
        env,
        whitelist=whitelist,
        blacklist=blacklist,
    )
1289538
def has_envconfig() -> bool:
        
        if (os.getenv("VAULT_TOKEN", None) or
                (os.getenv("VAULT_APPID", None) and os.getenv("VAULT_USERID", None)) or
                (os.getenv("VAULT_SSLCERT", None) and os.getenv("VAULT_SSLKEY", None)) or
                (os.getenv("VAULT_ROLEID", None) and os.getenv("VAULT_SECRETID", None))):
            return True

        return False
1357108
def run_command(nova_creds, nova_args, supernova_args):
    
    nova_env = supernova_args['nova_env']
    # (gtmanfred) make a copy of this object.  If we don't copy it, the insert
    # to 0 happens multiple times because it is the same object in memory.
    nova_args = copy.copy(nova_args)

    # Get the environment variables ready
    env_vars = os.environ.copy()
    env_vars.update(credentials.prep_shell_environment(nova_env,
                                                       nova_creds))

    # BYPASS_URL is a weird one, so we need to send it as an argument,
    # not an environment variable.
    nova_args = check_for_bypass_url(nova_creds[nova_env], nova_args)

    # Check for OS_EXECUTABLE
    supernova_args = check_for_executable(supernova_args, env_vars)

    # Check for a debug override
    nova_args = check_for_debug(supernova_args, nova_args)

    # Print a small message for the user (very helpful for groups)
    msg = "Running %s against %s..." % (supernova_args.get('executable'),
                                        nova_env)
    if not supernova_args.get('quiet'):
        click.echo("[%s] %s " % (click.style('SUPERNOVA', fg='green'), msg))

    # Call executable and connect stdout to the current terminal
    # so that any unicode characters from the executable's list will be
    # displayed appropriately.
    #
    # In other news, I hate how python 2.6 does unicode.
    nova_args.insert(0, supernova_args['executable'])
    nova_args = [nova_arg.strip() for nova_arg in nova_args]
    process = execute_executable(nova_args, env_vars)

    # If the user asked us to be quiet, then let's not print stderr
    if not supernova_args.get('quiet'):
        handle_stderr(process.stderr)

    return process.returncode
364778
protected function checkEnvironment()
    {
        if (OS::is(OS::WIN)) {
            $this->error('Swoole extension doesn\'t support Windows OS.');

            exit(1);
        }

        if (! extension_loaded('swoole')) {
            $this->error('Can\'t detect Swoole extension installed.');

            exit(1);
        }

        if (! version_compare(swoole_version(), '4.3.1', 'ge')) {
            $this->error('Your Swoole version must be higher than `4.3.1`.');

            exit(1);
        }
    }
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
258511
def _verify_python3_env():
    """"""
    if PY2:
        return
    try:
        import locale
        fs_enc = codecs.lookup(locale.getpreferredencoding()).name
    except Exception:
        fs_enc = 'ascii'
    if fs_enc != 'ascii':
        return

    extra = ''
    if os.name == 'posix':
        import subprocess
        try:
            rv = subprocess.Popen(['locale', '-a'], stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE).communicate()[0]
        except OSError:
            rv = b''
        good_locales = set()
        has_c_utf8 = False

        # Make sure we're operating on text here.
        if isinstance(rv, bytes):
            rv = rv.decode('ascii', 'replace')

        for line in rv.splitlines():
            locale = line.strip()
            if locale.lower().endswith(('.utf-8', '.utf8')):
                good_locales.add(locale)
                if locale.lower() in ('c.utf8', 'c.utf-8'):
                    has_c_utf8 = True

        extra += '\n\n'
        if not good_locales:
            extra += (
                'Additional information: on this system no suitable UTF-8\n'
                'locales were discovered.  This most likely requires resolving\n'
                'by reconfiguring the locale system.'
            )
        elif has_c_utf8:
            extra += (
                'This system supports the C.UTF-8 locale which is recommended.\n'
                'You might be able to resolve your issue by exporting the\n'
                'following environment variables:\n\n'
                '    export LC_ALL=C.UTF-8\n'
                '    export LANG=C.UTF-8'
            )
        else:
            extra += (
                'This system lists a couple of UTF-8 supporting locales that\n'
                'you can pick from.  The following suitable locales were\n'
                'discovered: %s'
            ) % ', '.join(sorted(good_locales))

        bad_locale = None
        for locale in os.environ.get('LC_ALL'), os.environ.get('LANG'):
            if locale and locale.lower().endswith(('.utf-8', '.utf8')):
                bad_locale = locale
            if locale is not None:
                break
        if bad_locale is not None:
            extra += (
                '\n\nClick discovered that you exported a UTF-8 locale\n'
                'but the locale system could not pick up from it because\n'
                'it does not exist.  The exported locale is "%s" but it\n'
                'is not supported'
            ) % bad_locale

    raise RuntimeError(
        'Click will abort further execution because Python 3 was'
        ' configured to use ASCII as encoding for the environment.'
        ' Consult https://click.palletsprojects.com/en/7.x/python3/ for'
        ' mitigation steps.' + extra
    )
44997
def env_valid(env):
  
  if env not in EFConfig.ENV_LIST:
    raise ValueError("unknown env: {}; env must be one of: ".format(env) + ", ".join(EFConfig.ENV_LIST))
  return True
367464
def check_for_usable_environment(self):
        """"""
        # Do not let the user run Mackup as root
        if os.geteuid() == 0:
            utils.error("Running Mackup as a superuser is useless and"
                        " dangerous. Don't do it!")

        # Do we have a folder to put the Mackup folder ?
        if not os.path.isdir(self._config.path):
            utils.error("Unable to find the storage folder: {}"
                        .format(self._config.path))
1262627
def check_embed_envvar(param)
      return unless param =~ /<%=\s*ENV\[[\'\"]?(.+)[\'\"]\]?\s*%>/
      envvar_name = Regexp.last_match(1)
      if !ENV.key?(envvar_name)
        @logger.error "Variable name: #{envvar_name} is not found in ENV"
      elsif ENV[envvar_name] =~ /^\s*$/
        @logger.warn "Env var: #{envvar_name} exists, but null string"
      end
    end
1142303
def apply_environment
      return if noenv
      @server   ||= ENV['EMAIL_SERVER']
      @from     ||= ENV['EMAIL_FROM']    || ENV['EMAIL_ACCOUNT']
      @account  ||= ENV['EMAIL_ACCOUNT'] || ENV['EMAIL_FROM']
      @password ||= ENV['EMAIL_PASSWORD']
      @port     ||= ENV['EMAIL_PORT']
      @domain   ||= ENV['EMAIL_DOMAIN']
      @login    ||= ENV['EMAIL_LOGIN']
      @secure   ||= ENV['EMAIL_SECURE']
    end
884908
private static function environmentVariableExists($name)
    {
        switch (true) {
            case array_key_exists($name, $_ENV):
                return true;
            case array_key_exists($name, $_SERVER):
                return true;
            default:
                $value = getenv($name);
                return $value !== false;
        }
    }
1160738
function EnvAlreadyExistsError (e) {

    e = e || {};

    var environmentName = e.environmentName || '';

    this.message = 'Environment "' + environmentName + '" already exists';

    this.code = ERR_ENVIRONMENT_ALREADY_EXISTS;
    this.environmentName = environmentName;

}
1348807
def get_env_variable(var_name, default=None):
    """"""
    try:
        return os.environ[var_name]
    except KeyError:
        if default is None:
            error_msg = "Set the %s environment variable" % var_name
            raise ImproperlyConfigured(error_msg)
        else:
            return default
1204720
def prep_nova_creds(nova_env, nova_creds):
    
    try:
        raw_creds = dict(nova_creds.get('DEFAULT', {}), **nova_creds[nova_env])
    except KeyError:
        msg = "{0} was not found in your supernova configuration "\
              "file".format(nova_env)
        raise KeyError(msg)

    proxy_re = re.compile(r"(^http_proxy|^https_proxy)")

    creds = []
    for param, value in raw_creds.items():
        if not proxy_re.match(param):
            param = param.upper()

        if not hasattr(value, 'startswith'):
            continue

        # Get values from the keyring if we find a USE_KEYRING constant
        if value.startswith("USE_KEYRING"):
            username, credential = pull_env_credential(nova_env, param,
                                                       value)
        else:
            credential = value.strip("\"'")

        # Make sure we got something valid from the configuration file or
        # the keyring
        if not credential:
            raise LookupError("No matching credentials found in keyring")

        creds.append((param, credential))

    return creds
545841
function ensure (env, options, names) {
  for (let k of Object.keys(names)) {
    let v = names[k]

    if (options[v]) {
      env[k] = options[v]
      env[k + 'Cwd'] = true
    }
  }
}
33070
function validateEnvironment(environment, envContext, source = null) {

    // not having an environment is ok
    if (!environment) {
        return;
    }

    Object.keys(environment).forEach(env => {
        if (!envContext.get(env)) {
            const message = `${source}:\n\tEnvironment key "${env}" is unknown\n`;

            throw new Error(message);
        }
    });
}