Configures environment variables
766350
def _readconfig():
    """"""
    config = ConfigParser.SafeConfigParser()
    try:
        found = config.read(littlechef.CONFIGFILE)
    except ConfigParser.ParsingError as e:
        abort(str(e))
    if not len(found):
        try:
            found = config.read(['config.cfg', 'auth.cfg'])
        except ConfigParser.ParsingError as e:
            abort(str(e))
        if len(found):
            print('\nDeprecationWarning: deprecated config file name \'{0}\'.'
                  ' Use {1}'.format(found[0], littlechef.CONFIGFILE))
        else:
            abort('No {0} file found in the current '
                  'directory'.format(littlechef.CONFIGFILE))

    in_a_kitchen, missing = _check_appliances()
    missing_str = lambda m: ' and '.join(', '.join(m).rsplit(', ', 1))
    if not in_a_kitchen:
        abort("Couldn't find {0}. "
              "Are you executing 'fix' outside of a kitchen?\n"
              "To create a new kitchen in the current directory "
              " type 'fix new_kitchen'".format(missing_str(missing)))

    # We expect an ssh_config file here,
    # and/or a user, (password/keyfile) pair
    try:
        env.ssh_config_path = config.get('userinfo', 'ssh-config')
    except ConfigParser.NoSectionError:
        abort('You need to define a "userinfo" section'
              ' in the config file. Refer to the README for help '
              '(http://github.com/tobami/littlechef)')
    except ConfigParser.NoOptionError:
        env.ssh_config_path = None

    if env.ssh_config_path:
        env.ssh_config = _SSHConfig()
        env.ssh_config_path = os.path.expanduser(env.ssh_config_path)
        env.use_ssh_config = True
        try:
            env.ssh_config.parse(open(env.ssh_config_path))
        except IOError:
            abort("Couldn't open the ssh-config file "
                  "'{0}'".format(env.ssh_config_path))
        except Exception:
            abort("Couldn't parse the ssh-config file "
                  "'{0}'".format(env.ssh_config_path))
    else:
        env.ssh_config = None

    # check for a gateway
    try:
        env.gateway = config.get('connection', 'gateway')
    except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
        env.gateway = None

    # check for http_proxy which will be put into solo.rb
    try:
        env.http_proxy = config.get('connection', 'http_proxy')
    except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
        env.http_proxy = None

    try:
        env.https_proxy = config.get('connection', 'https_proxy')
    except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
        env.https_proxy = None

    try:
        env.remove_data_bags = config.get('userinfo', 'remove_data_bags')
    except ConfigParser.NoOptionError:
        env.remove_data_bags = False
        
    # Check for an encrypted_data_bag_secret file and set the env option
    try:
        env.encrypted_data_bag_secret = config.get('userinfo',
                                                   'encrypted_data_bag_secret')
    except ConfigParser.NoOptionError:
        env.encrypted_data_bag_secret = None

    if env.encrypted_data_bag_secret:
        env.encrypted_data_bag_secret = os.path.expanduser(
            env.encrypted_data_bag_secret)
        try:
            open(env.encrypted_data_bag_secret)
        except IOError as e:
            abort("Failed to open encrypted_data_bag_secret file at "
                  "'{0}'".format(env.encrypted_data_bag_secret))

    try:
        sudo_prefix = config.get('ssh', 'sudo_prefix', raw=True)
    except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
        pass
    else:
        env.sudo_prefix = sudo_prefix

    try:
        env.user = config.get('userinfo', 'user')
    except ConfigParser.NoOptionError:
        if not env.ssh_config_path:
            msg = 'You need to define a user in the "userinfo" section'
            msg += ' of {0}. Refer to the README for help'
            msg += ' (http://github.com/tobami/littlechef)'
            abort(msg.format(littlechef.CONFIGFILE))
        user_specified = False
    else:
        user_specified = True

    try:
        env.password = config.get('userinfo', 'password') or None
    except ConfigParser.NoOptionError:
        pass

    try:
        # If keypair-file is empty, assign None or fabric will try to read key
        env.key_filename = config.get('userinfo', 'keypair-file') or None
    except ConfigParser.NoOptionError:
        pass

    if (user_specified and not env.password and not env.key_filename
            and not env.ssh_config):
        abort('You need to define a password, keypair file, or ssh-config '
              'file in {0}'.format(littlechef.CONFIGFILE))

    # Node's Chef Solo working directory for storing cookbooks, roles, etc.
    try:
        env.node_work_path = os.path.expanduser(config.get('kitchen',
                                                'node_work_path'))
    except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
        env.node_work_path = littlechef.node_work_path
    else:
        if not env.node_work_path:
            abort('The "node_work_path" option cannot be empty')

    # Follow symlinks
    try:
        env.follow_symlinks = config.getboolean('kitchen', 'follow_symlinks')
    except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
        env.follow_symlinks = False

    try:
        env.berksfile = config.get('kitchen', 'berksfile')
    except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) as e:
        env.berksfile = None
    else:
        try:
            env.berksfile_cookbooks_directory = config.get('kitchen', 'berksfile_cookbooks_directory')
            littlechef.cookbook_paths.append(env.berksfile_cookbooks_directory)
        except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) as e:
            if env.berksfile:
                env.berksfile_cookbooks_directory = tempfile.mkdtemp('littlechef-berks')
                littlechef.cookbook_paths.append(env.berksfile_cookbooks_directory)
            else:
                env.berksfile_cookbooks_directory = None
        chef.ensure_berksfile_cookbooks_are_installed()

    # Upload Directory
    try:
        env.sync_packages_dest_dir = config.get('sync-packages',
                                                'dest-dir')
    except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
        env.sync_packages_dest_dir = None

    # Local Directory
    try:
        env.sync_packages_local_dir = config.get('sync-packages',
                                                 'local-dir')
    except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
        env.sync_packages_local_dir = None

    try:
        env.autodeploy_chef = config.get('userinfo', 'autodeploy_chef') or None
    except ConfigParser.NoOptionError:
        env.autodeploy_chef = None
1244179
public function setEnvironmentVariable($name, $value = null)
    {
        list($name, $value) = $this->normaliseEnvironmentVariable($name, $value);

        // Don't overwrite existing environment variables if we're immutable
        // Ruby's dotenv does this with `ENV[key] ||= value`.
        if ($this->immutable === true && !is_null($this->getEnvironmentVariable($name))) {
            return;
        }

        $_ENV[$name] = $value;
        $_SERVER[$name] = $value;
        putenv("$name=$value");
    }
1296832
def set_windows_env_var(key, value):
    

    if not isinstance(key, text_type):
        raise TypeError("%r not of type %r" % (key, text_type))

    if not isinstance(value, text_type):
        raise TypeError("%r not of type %r" % (value, text_type))

    status = winapi.SetEnvironmentVariableW(key, value)
    if status == 0:
        raise ctypes.WinError()
1161249
def set_env_or_defaults(self):
        
        option = namedtuple('Option', ['section', 'name', 'env_var',
                                       'default_value'])

        options = [option('auth', 'user', 'NAPPS_USER', None),
                   option('auth', 'token', 'NAPPS_TOKEN', None),
                   option('napps', 'api', 'NAPPS_API_URI',
                          'https://napps.kytos.io/api/'),
                   option('napps', 'repo', 'NAPPS_REPO_URI',
                          'https://napps.kytos.io/repo'),
                   option('kytos', 'api', 'KYTOS_API',
                          'http://localhost:8181/')]

        for option in options:
            if not self.config.has_option(option.section, option.name):
                env_value = os.environ.get(option.env_var,
                                           option.default_value)
                if env_value:
                    self.config.set(option.section, option.name, env_value)

        self.config.set('global', 'debug', str(self.debug))
158943
protected function configure()
    {
        $this->config = array(
            'app_include' => getenv('APP_INCLUDE'),
            'worker_count' => false === getenv('COUNT') ? 1 : getenv('COUNT'),
            'queues' => getenv('QUEUE'),
            'queue_blocking' => (bool)getenv('BLOCKING'),
            'queue_interval' => false === getenv('INTERVAL') ? 5 : getenv('INTERVAL'),
            'redis_prefix' => false === getenv('PREFIX') ? 'resque' : getenv('PREFIX'),
            'redis_dsn' => getenv('REDIS_BACKEND'),
            'logging' => (bool)getenv('LOGGING'),
            'verbose' => (bool)getenv('VERBOSE'),
            'very_verbose' => (bool)getenv('VVERBOSE'),
        );
    }
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
1154607
def load_env():
    """"""
    # environment variables take precedence over conf file
    for key, envvar in [['cache_dir', 'INTAKE_CACHE_DIR'],
                        ['catalog_path', 'INTAKE_PATH'],
                        ['persist_path', 'INTAKE_PERSIST_PATH']]:
        if envvar in os.environ:
            conf[key] = make_path_posix(os.environ[envvar])
    conf['catalog_path'] = intake_path_dirs(conf['catalog_path'])
    for key, envvar in [['cache_disabled', 'INTAKE_DISABLE_CACHING'],
                        ['cache_download_progress', 'INTAKE_CACHE_PROGRESS']]:
        if envvar in os.environ:
            conf[key] = os.environ[envvar].lower() in ['true', 't', 'y', 'yes']
    if 'INTAKE_LOG_LEVEL' in os.environ:
        conf['logging'] = os.environ['INTAKE_LOG_LEVEL']
783377
def add_env_var(self, key, value):
        
        self.manifest['env'][key] = value
        os.environ[key] = str(value)
1243723
def setup_path(self):
        """"""
        path = self.opts.path or self.config['crony'].get('path')
        if path:
            self.logger.debug(f'Adding {path} to PATH environment variable')
            self.cmd = f'export PATH={path}:$PATH && {self.cmd}'
688545
def configure(env=:default, &block)
      environment = config_attributes[env.to_sym]

      Builder.new(environment, &block)
    end
617631
def _setup(self, name=None):
        
        envvar = self.__dict__['env_var']
        if envvar:
            settings_file = os.environ.get(envvar)
        else:
            settings_file = self.__dict__['file_path']

        if not settings_file:
            msg = ("Requested settings, but none can be obtained for the envvar."
                   "Since no config filepath can be obtained, a default config "
                   "will be used.")
            logger.error(msg)
            raise OSError(msg)

        self._wrapped = Settings(settings_file)
1006134
def set_env(self):
        """"""

        if self.cov_source is None:
            os.environ['COV_CORE_SOURCE'] = ''
        else:
            os.environ['COV_CORE_SOURCE'] = UNIQUE_SEP.join(self.cov_source)
        os.environ['COV_CORE_DATA_FILE'] = self.cov_data_file
        os.environ['COV_CORE_CONFIG'] = self.cov_config
1111466
private function set_up_environment() {
		if ( $this->it_has( 'environment' ) ) {
			$this->environment = $this->options['environment'];
		} else {
			$this->environment = defined( 'WP_DEBUG' ) && WP_DEBUG
				? 'development'
				: 'production';
		}
	}
379425
public void setEnvironmentVariables(Map<String, String> environment) {
    for (Map.Entry<String, String> entry : environment.entrySet()) {
      setEnvironmentVariable(entry.getKey(), entry.getValue());
    }
  }
900748
public void setEnvironmentVariables(java.util.Collection<EnvironmentVariable> environmentVariables) {
        if (environmentVariables == null) {
            this.environmentVariables = null;
            return;
        }

        this.environmentVariables = new java.util.ArrayList<EnvironmentVariable>(environmentVariables);
    }
1333923
public static function setEnvVariables()
    {
        $env_variables = [];

        if (file_exists(static::projectRoot() . '/.env')) {
            $env_variables = (new Dotenv(static::projectRoot()))
                ->load();
        }

        self::$projectEnv = $env_variables;
    }
984607
def SetupVars(self):
    """"""
    # Python paths chosen to match appveyor:
    # http://www.appveyor.com/docs/installed-software#python

    self.python_dir_64 = args.python64_dir
    self.python_dir_32 = args.python32_dir

    self.virtualenv_bin64 = os.path.join(self.python_dir_64,
                                         r"Scripts\virtualenv.exe")
    self.virtualenv_bin32 = os.path.join(self.python_dir_32,
                                         r"Scripts\virtualenv.exe")

    if args.virtualenv_64bit:
      self.virtualenv64 = args.virtualenv_64bit
    else:
      self.virtualenv64 = os.path.join(args.build_dir, "python_64")
    if args.virtualenv_32bit:
      self.virtualenv32 = args.virtualenv_32bit
    else:
      self.virtualenv32 = os.path.join(args.build_dir, "python_32")

    self.grr_client_build64 = os.path.join(self.virtualenv64,
                                           r"Scripts\grr_client_build.exe")
    self.grr_client_build32 = os.path.join(self.virtualenv32,
                                           r"Scripts\grr_client_build.exe")
    self.pip64 = os.path.join(self.virtualenv64, r"Scripts\pip.exe")
    self.pip32 = os.path.join(self.virtualenv32, r"Scripts\pip.exe")

    self.virtualenv_python64 = os.path.join(self.virtualenv64,
                                            r"Scripts\python.exe")
    self.virtualenv_python32 = os.path.join(self.virtualenv32,
                                            r"Scripts\python.exe")

    self.git = r"C:\Program Files\Git\bin\git.exe"

    self.install_path = r"C:\Windows\System32\GRR"
    self.service_name = "GRR Monitor"

    self.expect_service_running = args.expect_service_running