Reads config files in, checking their security first
		(in case passwords/sensitive info is in them).
160997
def get_configs(self, configs):
		
		shutit_global.shutit_global_object.yield_to_draw()
		cp  = LayerConfigParser()
		fail_str = ''
		files    = []
		for config_file in configs:
			if isinstance(config_file, tuple):
				continue
			if not shutit_util.is_file_secure(config_file):
				fail_str = fail_str + '\nchmod 0600 ' + config_file
				files.append(config_file)
		if fail_str != '':
			if shutit_global.shutit_global_object.interactive > 1:
				fail_str = 'Files are not secure, mode should be 0600. Running the following commands to correct:\n' + fail_str + '\n'
				# Actually show this to the user before failing...
				self.log(fail_str,level=logging.INFO)
				self.log('Do you want me to run this for you? (input y/n)',level=logging.INFO)
				if shutit_global.shutit_global_object.interactive == 0 or shutit_util.util_raw_input(default='y') == 'y':
					for f in files:
						self.log('Correcting insecure file permissions on: ' + f,level=logging.INFO)
						os.chmod(f,0o600)
					# recurse
					return self.get_configs(configs)
			else:
				for f in files:
					self.log('Correcting insecure file permissions on: ' + f,level=logging.INFO)
					os.chmod(f,0o600)
				# recurse
				return self.get_configs(configs)
			self.fail(fail_str) # pragma: no cover
		for config in configs:
			if isinstance(config, tuple):
				cp.readfp(config[1], filename=config[0])
			else:
				cp.read(config)
		# Treat allowed_images as a special, additive case
		self.build['shutit.core.module.allowed_images'] = cp.get_config_set('build', 'shutit.core.module.allowed_images')
		return cp
295559
def _read_config(self):
        
        default_config_filepath = Path2(os.path.dirname(__file__), DEAFULT_CONFIG_FILENAME)
        log.debug("Read defaults from: '%s'" % default_config_filepath)
        if not default_config_filepath.is_file():
            raise RuntimeError(
                "Internal error: Can't locate the default .ini file here: '%s'" % default_config_filepath
            )
        config = self._read_and_convert(default_config_filepath, all_values=True)
        log.debug("Defaults: %s", pprint.pformat(config))

        self.ini_filepath = get_ini_filepath()
        if not self.ini_filepath:
            # No .ini file made by user found
            # -> Create one into user home
            self.ini_filepath = get_user_ini_filepath()

            # We don't use shutil.copyfile here, so the line endings will
            # be converted e.g. under windows from \n to \n\r
            with default_config_filepath.open("r") as infile:
                with self.ini_filepath.open("w") as outfile:
                    outfile.write(infile.read())

            print("\n*************************************************************")
            print("Default config file was created into your home:")
            print("\t%s" % self.ini_filepath)
            print("Change it for your needs ;)")
            print("*************************************************************\n")
        else:
            print("\nread user configuration from:")
            print("\t%s\n" % self.ini_filepath)
            config.update(self._read_and_convert(self.ini_filepath, all_values=False))
            log.debug("RawConfig changed to: %s", pprint.pformat(config))

        return config
1119255
private void readConfigFile() {
    File configFile = new File(CONFIG_FILE_PATH);
    /* config file is not there -> create config file with default */
    if (!configFile.exists()) {
      resetConfigToDefault();
    }

    try {
      PropertiesConfiguration conf = new PropertiesConfiguration(CONFIG_FILE_PATH);
      chemistry = conf.getString(CHEMISTRY_PLUGIN);
    } catch (ConfigurationException e) {
      resetConfigToDefault();
      e.printStackTrace();
    }
  }
301972
def _read_config(self):
        """"""
        config = configparser.ConfigParser()
        config.read(self.path)
        if config.has_section('distutils'):
            server_names = config.get('distutils', 'index-servers')
            servers = [name.strip() for name in server_names.split('\n')]
            servers = [server for server in servers if server]

            for server in servers:
                repo_config = RepositoryConfig(server)
                repo_config.fill(config, server)
                self.repositories.append(repo_config)

        repo_config = RepositoryConfig('default')
        repo_config.fill(config, 'server-login')
1194804
def _check_config():
    """"""
    config.CONFIG_DIR.mkdir(parents=True, exist_ok=True)
    verfile = config.CONFIG_DIR / '.version'
    uptodate = verfile.is_file() and verfile.read_text() == __version__
    if not uptodate:
        verfile.write_text(__version__)
    if not (uptodate and config.CONFIG_FILE.is_file()):
        conf.create_config_(update=True)
    for stfile in ('stagpy-paper.mplstyle',
                   'stagpy-slides.mplstyle'):
        stfile_conf = config.CONFIG_DIR / stfile
        if not (uptodate and stfile_conf.is_file()):
            stfile_local = pathlib.Path(__file__).parent / stfile
            shutil.copy(str(stfile_local), str(stfile_conf))
535520
def load_config_file(self):
        """"""
        config_parser = SafeConfigParser()

        config_parser.read(self.CONFIG_FILE)

        if config_parser.has_section('handlers'):
            self._config['handlers_package'] = config_parser.get('handlers', 'package')

        if config_parser.has_section('auth'):
            self._config['consumer_key'] = config_parser.get('auth', 'consumer_key')
            self._config['consumer_secret'] = config_parser.get('auth', 'consumer_secret')
            self._config['token_key'] = config_parser.get('auth', 'token_key')
            self._config['token_secret'] = config_parser.get('auth', 'token_secret')

        if config_parser.has_section('stream'):
            self._config['user_stream'] = config_parser.get('stream', 'user_stream').lower() == 'true'
        else:
            self._config['user_stream'] = False

        if config_parser.has_option('general', 'min_seconds_between_errors'):
            self._config['min_seconds_between_errors'] = config_parser.get('general', 'min_seconds_between_errors')
        if config_parser.has_option('general', 'sleep_seconds_on_consecutive_errors'):
            self._config['sleep_seconds_on_consecutive_errors'] = config_parser.get(
                'general', 'sleep_seconds_on_consecutive_errors')
372683
def check_config(filename):
    
    conf = configparser.SafeConfigParser(allow_no_value=False)
    conf.read(filename)
    try:
        server = conf.get('global', 'server')
    except configparser.NoSectionError:
        server = False
    except configparser.NoOptionError:
        server = False
    try:
        username = conf.get('auth', 'username')
    except configparser.NoSectionError:
        username = False
    except configparser.NoOptionError:
        username = False
    try:
        password = conf.get('auth', 'password')
    except configparser.NoSectionError:
        password = False
    except configparser.NoOptionError:
        password = False
    try:
        auto_update_soa = conf.get('global', 'soa_update')
    except configparser.NoSectionError:
        auto_update_soa = False
    except configparser.NoOptionError:
        auto_update_soa = False

    return server, username, password, auto_update_soa
92241
private List<CmsGitConfiguration> readConfigFiles() {

        List<CmsGitConfiguration> configurations = new LinkedList<CmsGitConfiguration>();

        // Default configuration file for backwards compatibility
        addConfigurationIfValid(configurations, new File(DEFAULT_CONFIG_FILE));

        // All files in the config folder
        File configFolder = new File(DEFAULT_CONFIG_FOLDER);
        if (configFolder.isDirectory()) {
            for (File configFile : configFolder.listFiles()) {
                addConfigurationIfValid(configurations, configFile);
            }
        }
        return configurations;
    }
627196
def read_config(conf_dir=DEFAULT_CONFIG_DIR):
    ""

    conf_path = os.path.expanduser(conf_dir)
    if not os.path.exists(conf_path):
        # only throw if not default
        if conf_dir != DEFAULT_CONFIG_DIR:
            raise IOError("Config directory not found at %s" % (conf_path, ))

    return munge.load_datafile('config', conf_path, default=None)
808633
def read_config_file(path):
    """"""
    try:
        with open(path, 'r') as f:
            return json.load(f, object_pairs_hook=OrderedDict)
    except IOError as ex:
        if ex != errno.ENOENT:
            raise
    return {}
443713
def read_checking_config (self):
        """"""
        section = "checking"
        self.read_int_option(section, "threads", min=-1)
        self.config['threads'] = max(0, self.config['threads'])
        self.read_int_option(section, "timeout", min=1)
        self.read_int_option(section, "aborttimeout", min=1)
        self.read_int_option(section, "recursionlevel", min=-1)
        self.read_string_option(section, "nntpserver")
        self.read_string_option(section, "useragent")
        self.read_int_option(section, "maxrequestspersecond", min=1)
        self.read_int_option(section, "maxnumurls", min=0)
        self.read_int_option(section, "maxfilesizeparse", min=1)
        self.read_int_option(section, "maxfilesizedownload", min=1)
        if self.has_option(section, "allowedschemes"):
            self.config['allowedschemes'] = [x.strip().lower() for x in \
                 self.get(section, 'allowedschemes').split(',')]
        self.read_boolean_option(section, "debugmemory")
        self.read_string_option(section, "cookiefile")
        self.read_string_option(section, "localwebroot")
        try:
            self.read_boolean_option(section, "sslverify")
        except ValueError:
            self.read_string_option(section, "sslverify")
        self.read_int_option(section, "maxrunseconds", min=0)
52142
function loadConfigFile(dist, paths, options, callback) {
        if (options.config) {
            fs.readFile(options.config, {encoding: 'utf8'}, function(err, contents) {
                if (err) {
                    callback(err);
                    return;
                }
                
                var config = ini.parse(contents);

                if (config && config.default) {
                    options.accessKeyId = config.default.access_key;
                    options.secretAccessKey = config.default.secret_key;
                }
                if (!options.secretAccessKey || !options.accessKeyId) {
                    callback("Config file missing access_key or secret_key");
                    return;
                }

                invalidate(dist, paths, options, callback);
            });
        } else {
            invalidate(dist, paths, options, callback);
        }
    }
944958
def _read_config_file(args):
    """"""
    stage = args.stage
    with open(args.config, 'rt') as f:
        config = yaml.safe_load(f.read())
    STATE['stages'] = config['stages']
    config['config'] = _decrypt_item(config['config'], stage=stage, key='',
                                     render=True)
    return config['stages'], config['config']
1078270
def read(self, config_dir=None, config_name=None, clear=False):
        

# TODO should probably allow config_dir to be a list as well
        # get name of config directory
        if not config_dir:
            config_dir = self._defaults.get('config_dir', None)
        if not config_dir:
            raise KeyError('config_dir not set')

        # get name of config file
        if not config_name:
            config_name = self._defaults.get('config_name', None)
        if not config_name:
            raise KeyError('config_name not set')

        conf_path = os.path.expanduser(config_dir)
        if not os.path.exists(conf_path):
            raise IOError("config dir not found at %s" % (conf_path,))

        config = munge.load_datafile(config_name, conf_path, default=None)

        if not config:
            raise IOError("config file not found in %s" % (conf_path,))

        if clear:
            self.clear()

        munge.util.recursive_update(self.data, config)
        self._meta_config_dir = conf_path
        return self
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
305536
def read_config_file(f):
    """"""

    if isinstance(f, basestring):
        f = os.path.expanduser(f)

    try:
        config = ConfigObj(f, interpolation=False, encoding='utf8')
    except ConfigObjError as e:
        log(LOGGER, logging.ERROR, "Unable to parse line {0} of config file "
            "'{1}'.".format(e.line_number, f))
        log(LOGGER, logging.ERROR, "Using successfully parsed config values.")
        return e.config
    except (IOError, OSError) as e:
        log(LOGGER, logging.WARNING, "You don't have permission to read "
            "config file '{0}'.".format(e.filename))
        return None

    return config
405471
def read (self, files):
        
        assert isinstance(files, list), "Invalid file list %r" % files
        try:
            self.read_ok = super(LCConfigParser, self).read(files)
            if len(self.read_ok) < len(files):
                failed_files = set(files) - set(self.read_ok)
                log.warn(LOG_CHECK, "Could not read configuration files %s.", failed_files)
            # Read all the configuration parameters from the given files.
            self.read_checking_config()
            self.read_authentication_config()
            self.read_filtering_config()
            self.read_output_config()
            self.read_plugin_config()
        except Exception as msg:
            raise LinkCheckerError(
              _("Error parsing configuration: %s") % unicode(msg))