Return a dictionary representing the environment variables used to
        set the proxy settings.
517483
def get_environment(self):
        '''
        
        '''
        env = {}
        if self.http:
            env['http_proxy'] = env['HTTP_PROXY'] = self.http
        if self.https:
            env['https_proxy'] = env['HTTPS_PROXY'] = self.https
        if self.ftp:
            env['ftp_proxy'] = env['FTP_PROXY'] = self.ftp
        if self.no_proxy:
            env['no_proxy'] = env['NO_PROXY'] = self.no_proxy
        return env
198583
def inject_proxy_environment(self, environment):
        '''
        
        '''
        if not self:
            return environment

        proxy_env = format_environment(self.get_environment())
        if not environment:
            return proxy_env
        # It is important to prepend our variables, because we want the
        # variables defined in "environment" to take precedence.
        return proxy_env + environment
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'])
885202
def env(*_vars, **kwargs):
    
    for v in _vars:
        value = os.environ.get(v, None)
        if value:
            return value
    return kwargs.get('default', '')
1214443
def http_proxy(self):
    
    if os.getenv('HTTP_PROXY'):
      return os.getenv('HTTP_PROXY')
    if os.getenv('http_proxy'):
      return os.getenv('http_proxy')
    return self.get_options().http_proxy
83625
def settings(self):
        """"""
        if not self.__settings:
            self.__settings = self.request('get', 'settings').json()
        return self.__settings
659950
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'environments') and self.environments is not None:
            _dict['environments'] = [x._to_dict() for x in self.environments]
        return _dict
447599
def _get_env(self):
        
        env = {}
        for k, v in os.environ.items():
            k = k.decode() if isinstance(k, bytes) else k
            v = v.decode() if isinstance(v, bytes) else v
            env[k] = v
        return list(env.items())
19689
def config(env=DEFAULT_ENV, default=None, **overrides):
    """"""

    config = {}

    s = os.environ.get(env, default)

    if s:
        config = parse(s)

    overrides = dict([(k.upper(), v) for k, v in overrides.items()])

    config.update(overrides)

    return config
1197029
def to_env_vars(self):
        

        env = {
            'hosts': self.hosts, 'network_interface_name': self.network_interface_name,
            'hps': self.hyperparameters, 'user_entry_point': self.user_entry_point,
            'framework_params': self.additional_framework_parameters,
            'resource_config': self.resource_config, 'input_data_config': self.input_data_config,
            'output_data_dir': self.output_data_dir,
            'channels': sorted(self.channel_input_dirs.keys()),
            'current_host': self.current_host, 'module_name': self.module_name,
            'log_level': self.log_level,
            'framework_module': self.framework_module, 'input_dir': self.input_dir,
            'input_config_dir': self.input_config_dir, 'output_dir': self.output_dir,
            'num_cpus': self.num_cpus,
            'num_gpus': self.num_gpus, 'model_dir': self.model_dir, 'module_dir': self.module_dir,
            'training_env': dict(self), 'user_args': self.to_cmd_args(),
            'output_intermediate_dir': self.output_intermediate_dir
        }

        for name, path in self.channel_input_dirs.items():
            env['channel_%s' % name] = path

        for key, value in self.hyperparameters.items():
            env['hp_%s' % key] = value

        return _mapping.to_env_vars(env)
1010654
def load_environment_vars(self):
        
        for k, v in os.environ.items():
            if k.startswith(MACH9_PREFIX):
                _, config_key = k.split(MACH9_PREFIX, 1)
                self[config_key] = v
195556
def load_env(self):
        
        for key, value in self.spec.items():
            if value['type'] in (dict, list):
                envar = (self.env_prefix + "_" + key).upper()
                try:
                    envvar = env.json(envar,
                                      default=getattr(self, key.upper(), value.get('default')))
                except ConfigurationError as _err:  #pragma: no cover
                    print(_err)
                    self.log.critical(f"Error parsing json from env var. {os.environ.get(envar)}")
                    print(envar)
                    raise
            else:
                envvar = env((self.env_prefix + "_" + key).upper(),
                             default=getattr(self, key.upper(), value.get('default')),
                             cast=value['type'])
            setattr(self, key.upper(), envvar)
1128430
def GetEnvironmentVariable(self, name):
    
    name = name.upper()
    return self._environment_variables.get(name, None)
1102759
def create_environment_dict(overrides):
    
    result = os.environ.copy()
    result.update(overrides or {})
    return result
1371546
def get_environ(self, sock):
        """"""
        cipher = sock.cipher()
        ssl_environ = {
            'wsgi.url_scheme': 'https',
            'HTTPS': 'on',
            'SSL_PROTOCOL': cipher[1],
            'SSL_CIPHER': cipher[0],
            # SSL_VERSION_INTERFACE     string  The mod_ssl program version
            # SSL_VERSION_LIBRARY   string  The OpenSSL program version
        }

        if self.context and self.context.verify_mode != ssl.CERT_NONE:
            client_cert = sock.getpeercert()
            if client_cert:
                for cert_key, env_var in self.CERT_KEY_TO_ENV.items():
                    ssl_environ.update(
                        self.env_dn_dict(env_var, client_cert.get(cert_key)),
                    )

        return ssl_environ
1114952
def get_env_variable(var_name, default=None):
    """"""
    try:
        return os.environ[var_name]
    except KeyError:
        if default is not None:
            return default
        else:
            error_msg = 'The environment variable {} was missing, abort...'\
                        .format(var_name)
            raise EnvironmentError(error_msg)
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)