Set the application environment for a web request.

@param {Object|function} environments
@return string
542805
function detectWebEnvironment(environments) {
    // If the given environment is just a Closure, we will defer the environment check
    // to the Closure the developer has provided, which allows them to totally swap
    // the webs environment detection logic with their own custom Closure's code.
    if (typeof environments === 'function') {
        return environments()
    }

    var hosts;
    for (var environment in environments) {
        hosts = environments[environment];

        // To determine the current environment, we'll simply iterate through the possible
        // environments and look for the host that matches the host for this request we
        // are currently processing here, then return back these environment's names.
        hosts = helper.parseObject(hosts);
        var k, host;
        for (k in hosts) {
            host = hosts[k];
            if (isMachine(host)) return environment;
        }
    }

    return 'production';
}
142897
def get_api_envs():
    """"""
    client_id = os.environ.get('CLIENT_ID')
    user_id = os.environ.get('USER_ID')
    if not client_id or not user_id:
        raise ValueError('API keys are not found in the environment')
    return client_id, user_id
739925
protected function detectWebEnvironment($environments)
	{
		$default = ClientManager::client('site', true);

		foreach ($environments as $environment => $url)
		{
			if ($client = ClientManager::client($environment, true))
			{
				$const = 'JPATH_' . strtoupper($environment);

				// To determine the current environment, we'll simply iterate through the possible
				// environments and look for the host that matches the host for this request we
				// are currently processing here, then return back these environment's names.
				if ((defined($const) && JPATH_BASE == constant($const)) || $this->request->segment(1) == $url)
				{
					return $client;
				}
			}
		}

		return $default;
	}
570948
function theme (env) {
    let promise = env.theme(env.dest, env)

    if (!is.promise(promise)) {
      let type = Object.prototype.toString.call(promise)
      throw new errors.Error(`Theme didn't return a promise, got ${type}.`)
    }

    return promise
      .then(() => {
        let displayTheme = env.displayTheme || 'anonymous'
        env.logger.log(`Theme \`${displayTheme}\` successfully rendered.`)
      })
  }
220069
function getOverloadedConfigFromEnvironment() {
  var env = typeof document === 'undefined' ? {} : document.documentElement.dataset;
  var platformUrl = env.zpPlatformUrl;
  var appName = env.zpSandboxid;
  return {
    platformUrl: platformUrl,
    appName: appName
  };
}
88758
function () {
    var envJson = ko.utils.stringifyJson(this.app.getEnvironment()),
        datasJson = ko.utils.stringifyJson(this.datas, function replacer(key, value) {
          if (typeof value === "undefined" || value == null) {
            return '';
          }
          return value;
        }),
        compressType = '',
        compression = false
    if (window.trimServerEventData) {
        datasJson = window.trimServerEventData(datasJson);
    }
    if (this.compression) {
        if (!env.isIE8 && window.pako) {
            envJson = encodeBase64(window.pako.gzip(envJson));
            datasJson = encodeBase64(window.pako.gzip(datasJson));
            compression = true
            compressType = 'gzip'
        }
    }
    return {
        environment: envJson,
        dataTables: datasJson,
        compression: compression,
        compressType: compressType
    }
}
587023
def get_environments():
    """"""
    envs = []
    for root, subfolders, files in os.walk('environments'):
        for filename in files:
            if filename.endswith(".json"):
                path = os.path.join(
                    root[len('environments'):], filename[:-len('.json')])
                envs.append(get_environment(path))
    return sorted(envs, key=lambda x: x['name'])
962786
protected function detectConsoleEnvironment($environments, array $args)
    {
        // First we will check if an environment argument was passed via console arguments
        // and if it was that automatically overrides as the environment. Otherwise, we
        // will check the environment as a "web" request like a typical HTTP request.
        if (!is_null($value = $this->getEnvironmentArgument($args))) {
            return head(array_slice(explode('=', $value), 1));
        }
    }
128247
def get_environ(self):
        """"""
        req = self.req
        env_10 = WSGIGateway_10.get_environ(self)
        env = dict([(k.decode('ISO-8859-1'), v) for k, v in env_10.iteritems()])
        env[u'wsgi.version'] = ('u', 0)
        
        # Request-URI
        env.setdefault(u'wsgi.url_encoding', u'utf-8')
        try:
            for key in [u"PATH_INFO", u"SCRIPT_NAME", u"QUERY_STRING"]:
                env[key] = env_10[str(key)].decode(env[u'wsgi.url_encoding'])
        except UnicodeDecodeError:
            # Fall back to latin 1 so apps can transcode if needed.
            env[u'wsgi.url_encoding'] = u'ISO-8859-1'
            for key in [u"PATH_INFO", u"SCRIPT_NAME", u"QUERY_STRING"]:
                env[key] = env_10[str(key)].decode(env[u'wsgi.url_encoding'])
        
        for k, v in sorted(env.items()):
            if isinstance(v, str) and k not in ('REQUEST_URI', 'wsgi.input'):
                env[k] = v.decode('ISO-8859-1')
        
        return env
429543
def create_api_environment(self):
        """"""
        return ApiEnvironment(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
600869
public static function loadEnvironment()
    {
        /**
         * Application Environment
         */
        $required_env = [
            # application configuration
            'APP_NAME', 'APP_ENV', 'APP_KEY',

            # database configuration
            'DB_HOSTNAME', 'DB_PORT', 'DB_USERNAME', 'DB_PASSWORD', 'DB_NAME',

            # debugging
            'DEBUG_ON', 'DEBUG_BAR_ON',

            # application mode
            'APP_MODE',

            # flag whether use dist or not
            'USE_DIST'
        ];

        $is_own_server = count(glob($_SERVER['DOCUMENT_ROOT'] . "/.env")) === 0;
        $root = $_SERVER['DOCUMENT_ROOT'] . ($is_own_server ? "/.." : "");

        if (is_api_request())
        {
            // remove DEBUG_BAR_ON, USE_DIST on api request
            unset($required_env[array_search("DEBUG_BAR_ON", $required_env)]);
            unset($required_env[array_search("USE_DIST", $required_env)]);
        }

        $dotenv = new \Dotenv\Dotenv($root);
        $dotenv->overload();
        $dotenv->required($required_env);
    }
1240354
function envInfo () {
	var browser = browserInfo();
	var osName = browser.os;

	if (osName === 'MacOS') {
		osName = 'OS X';
	}

	return {
		runtime: {
			name: browser.name,
			version: browser.version
		},
		os: {
			name: osName
		}
	};
}
300359
def environment=(env)
      @environment = (env.to_s.downcase.strip == 'production') ? :production : :sandbox
      @uri = URI.parse(production? ? URI_PRODUCTION : URI_SANDBOX)
      @environment
    end
16454
public static function detectEnvironment($request = null)
    {
        if (!empty(static::$env)) {
            return static::$env;
        }

        $rules = self::get('env');

        $request = $request ? $request : Request::createFromGlobals();

        $host = $request->getHost();

        foreach ($rules as $env => $rule) {
            if (is_callable($rule)) {
                static::$env = $env;
            } elseif (preg_match($rule, $host)) {
                static::$env = $env;
                break;
            }
        }

        static::loadEnvironment(static::$env);

        return static::$env;
    }
1050932
function getEnv() {
    var ua = navigator.userAgent;

    env = {
      // True if this browser supports disabling async mode on dynamically
      // created script nodes. See
      // http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order
      async: doc.createElement('script').async === true
    };

    (env.webkit = /AppleWebKit\//.test(ua))
      || (env.ie = /MSIE/.test(ua))
      || (env.opera = /Opera/.test(ua))
      || (env.gecko = /Gecko\//.test(ua))
      || (env.unknown = true);
  }
1371334
def get_environment(id=None, name=None):
    
    data = get_environment_raw(id, name)
    if data:
        return utils.format_json(data)
476556
public function detect($environments, $consoleArgs = null)
	{
		if ($consoleArgs)
		{
			return $this->detectConsoleEnvironment($environments, $consoleArgs);
		}
		else
		{
			return $this->detectWebEnvironment($environments);
		}
	}