Do some basic checks on the configuration
546071
def __check_table_rules(configuration):
    
    for table_name in configuration['tables']:
        table = configuration['tables'][table_name]
        # Check that increase/decrease units is OK
        valid_units = ['percent', 'units']
        if table['increase_reads_unit'] not in valid_units:
            print('increase-reads-unit must be set to either percent or units')
            sys.exit(1)
        if table['decrease_reads_unit'] not in valid_units:
            print('decrease-reads-unit must be set to either percent or units')
            sys.exit(1)
        if table['increase_writes_unit'] not in valid_units:
            print(
                'increase-writes-unit must be set to either percent or units')
            sys.exit(1)
        if table['decrease_writes_unit'] not in valid_units:
            print(
                'decrease-writes-unit must be set to either percent or units')
            sys.exit(1)
        if ('increase_consumed_reads_unit' in table
                and table['increase_consumed_reads_unit']
                and table['increase_consumed_reads_unit'] not in valid_units):
            print(
                'increase-consumed-reads-unit must be set to '
                'either percent or units, or left unset')
            sys.exit(1)
        if ('increase_consumed_writes_unit' in table
                and table['increase_consumed_writes_unit']
                and table['increase_consumed_writes_unit'] not in valid_units):
            print(
                'increase-consumed-writes-unit must be set to '
                'either percent or units, or left unset')
            sys.exit(1)
        if ('increase_throttled_by_consumed_reads_unit' in table
                and table['increase_throttled_by_consumed_reads_unit']
                and table['increase_throttled_by_consumed_reads_unit']
                not in valid_units):
            print(
                'increase-throttled-by-consumed-reads-unit must be set to '
                'either percent or units, or left unset')
            sys.exit(1)
        if ('increase_throttled_by_consumed_writes_unit' in table
                and table['increase_throttled_by_consumed_writes_unit']
                and table['increase_throttled_by_consumed_writes_unit']
                not in valid_units):
            print(
                'increase-throttled-by-consumed-writes-unit must be set to '
                'either percent or units, or left unset')
            sys.exit(1)
        if ('increase_throttled_by_provisioned_reads_unit' in table
                and table['increase_throttled_by_provisioned_reads_unit']
                and table['increase_throttled_by_provisioned_reads_unit']
                not in valid_units):
            print(
                'increase-throttled-by-provisioned-reads-unit must be set to '
                'either percent or units, or left unset')
            sys.exit(1)
        if ('increase_throttled_by_provisioned_writes_unit' in table
                and table['increase_throttled_by_provisioned_writes_unit']
                and table['increase_throttled_by_provisioned_writes_unit']
                not in valid_units):
            print(
                'increase-throttled-by-provisioned-writes-unit must be set to '
                'either percent or units, or left unset')
            sys.exit(1)

        # Check lookback-window start
        if table['lookback_window_start'] < 1:
            print(
                'lookback-window-start must be a value higher than 1, '
                'as DynamoDB sends CloudWatch data every minute')
            sys.exit(1)

        # Check sns-message-types
        valid_sns_message_types = [
            'scale-up',
            'scale-down',
            'high-throughput-alarm',
            'low-throughput-alarm']

        if table['sns_message_types']:
            for sns_type in table['sns_message_types']:
                if sns_type not in valid_sns_message_types:
                    print('Warning: Invalid sns-message-type: {0}'.format(
                        sns_type))
                    table['sns_message_types'].remove(sns_type)

        # Ensure values > 0 for some important configuration options
        options = [
            'reads_lower_threshold',
            'reads_upper_threshold',
            'increase_reads_with',
            'decrease_reads_with',
            'writes_lower_threshold',
            'writes_upper_threshold',
            'increase_writes_with',
            'decrease_writes_with',
            'min_provisioned_reads',
            'max_provisioned_reads',
            'min_provisioned_writes',
            'max_provisioned_writes',
            'num_read_checks_before_scale_down',
            'num_write_checks_before_scale_down',
            'increase_consumed_reads_with',
            'increase_consumed_writes_with'
        ]
        # Config options without a mandatory default
        # should be allowed a None value
        non_default = [
            'increase_consumed_reads_with',
            'increase_consumed_writes_with'
        ]

        for option in options:
            if (option in non_default
                    and option in table
                    and table[option] and table[option] < 1):
                print('{0} may not be lower than 1 for table {1}'.format(
                    option, table_name))
                sys.exit(1)

            if (option in table
                    and option not in non_default
                    and table[option] < 1):
                print('{0} may not be lower than 1 for table {1}'.format(
                    option, table_name))
                sys.exit(1)

        if (int(table['min_provisioned_reads']) >
                int(table['max_provisioned_reads'])):
            print(
                'min_provisioned_reads ({0}) may not be higher than '
                'max_provisioned_reads ({1}) for table {2}'.format(
                    table['min_provisioned_reads'],
                    table['max_provisioned_reads'],
                    table_name))
            sys.exit(1)
        elif (int(table['min_provisioned_writes']) >
                int(table['max_provisioned_writes'])):
            print(
                'min_provisioned_writes ({0}) may not be higher than '
                'max_provisioned_writes ({1}) for table {2}'.format(
                    table['min_provisioned_writes'],
                    table['max_provisioned_writes'],
                    table_name))
            sys.exit(1)
629504
def check(self):
        ""
        config = self.load_config()
        if not check_dependency_epubcheck():
            sys.exit(error('Unavailable command.'))
        epub_file = u"%s.epub" % config['fileroot']
        epub_path = join(CWD, 'build', epub_file)
        print success("Starting to check %s..." % epub_file)
        epubcheck = u'epubcheck %s' % epub_path
        epubcheck = shell(epubcheck.encode())
        for line in epubcheck.errors():
            print error(line)
        for line in epubcheck.output():
            print line
1017514
def checkconfig():
    '''
    
    '''
    cmd = ['lxc-checkconfig']
    return subprocess.check_output(cmd).replace('[1;32m', '').replace('[1;33m', '').replace('[0;39m', '').replace('[1;32m', '').replace(' ', '').split('\n')
268494
protected function checkBehat() {
    $this->checkLocalConfig();
    if ($this->behatLocalYmlExists()) {
      $behatDefaultLocalConfig = $this->getInspector()->getLocalBehatConfig()->export();
      $this->checkDrupalVm($behatDefaultLocalConfig);
      $this->checkBaseUrl($behatDefaultLocalConfig);
    }
  }
7625
private function _checkLayerConfig()
    {
        $errorString = array();
        if ($this->_providerID == '') {
            array_push($errorString, 'LAYER_PROVIDER_ID');
        }

        if ($this->_keyID == '') {
            array_push($errorString, 'LAYER_PRIVATE_KEY_ID');
        }

        if ($this->_privateKey == '') {
            array_push($errorString, 'LAYER_PRIVATE_KEY');
        }

        if (count($errorString) > 0) {
            $joined = implode(',', $errorString);
            trigger_error("$joined  not configured. See README.md", E_USER_ERROR);
        }
    }
503455
function checkConfig()
    {
        //for joomla_int check to see if the source_url does not equal the default
	    try {
		    $db = Factory::getDatabase($this->getJname());
	    } catch (Exception $e) {
		    throw new RuntimeException(Text::_('NO_DATABASE') . ' : ' . $e->getMessage());
	    }

	    try {
		    $jdb = Factory::getDBO();
	    } catch (Exception $e) {
		    throw new RuntimeException($this->getJname() . ' -> joomla_int ' . Text::_('NO_DATABASE') . ' : ' . $e->getMessage());
	    }

	    if (!$db->connected()) {
		    throw new RuntimeException(Text::_('NO_DATABASE'));
	    } elseif (!$jdb->connected()) {
		    throw new RuntimeException($this->getJname() . ' -> joomla_int ' . Text::_('NO_DATABASE'));
	    } else {
		    //added check for missing files of copied plugins after upgrade
		    $admin = Factory::getAdmin($this->getJname());
		    $adminclass = 'JFusion\\Plugins\\' . $this->getJname(). '\\Admin';

		    $user = Factory::getUser($this->getJname());
		    $userclass = 'JFusion\\Plugins\\' . $this->getJname(). '\\User';
		    if (!$admin instanceof $adminclass) {
			    throw new RuntimeException(Text::_('NO_FILES') . ' '. $adminclass);
		    } else if (!$user instanceof $userclass) {
			    throw new RuntimeException(Text::_('NO_FILES') . ' '. $userclass);
		    } else {
			    $cookie_domain = $this->params->get('cookie_domain');
			    $jfc = Factory::getCookies();
			    list($url) = $jfc->getApiUrl($cookie_domain);
			    if ($url) {
				    $api = new Api($url, Factory::getParams('joomla_int')->get('secret'));
				    if (!$api->ping()) {
					    list ($message) = $api->getError();

					    throw new RuntimeException($api->url . ' ' . $message);
				    }
			    }
			    $source_path = $this->params->get('source_path');
			    if ($source_path && (strpos($source_path, 'http://') === 0 || strpos($source_path, 'https://') === 0)) {
				    throw new RuntimeException(Text::_('ERROR_SOURCE_PATH') . ' : ' . $source_path);
			    } else {
				    //get the user table name
				    $tablename = $this->getTablename();
				    // lets check if the table exists, now using the Joomla API
				    $table_list = $db->getTableList();
				    $table_prefix = $db->getPrefix();
				    if (!is_array($table_list)) {
					    throw new RuntimeException($table_prefix . $tablename . ': ' . Text::_('NO_TABLE'));
				    } else {
					    if (array_search($table_prefix . $tablename, $table_list) === false) {
						    //do a final check for case insensitive windows servers
						    if (array_search(strtolower($table_prefix . $tablename), $table_list) === false) {
							    throw new RuntimeException($table_prefix . $tablename . ': ' . Text::_('NO_TABLE'));
						    }
					    }
				    }
			    }
		    }
	    }
        return true;
    }
108858
def ensure_config
      return if @config_found
      found = CONFIG_FILES.all? {|f| File.exists? "#{@options[:config_path]}/#{f}" }
      found ? @config_dir = true : config_not_found
    end
263435
def check_configuration(self, file_path, test_program, custom_args):
        """"""
        # checking filepath
        if not os.path.isdir(file_path):
            raise InvalidFilePath("INVALID CONFIGURATION: file path %s is not a directory" %
                os.path.abspath(file_path)
            )

        if not test_program in IMPLEMENTED_TEST_PROGRAMS:
            raise InvalidTestProgram('The `%s` is unknown, or not yet implemented. Please chose another one.' % test_program)

        if custom_args:
            if not self.quiet and not ask("WARNING!!!\nYou are about to run the following command\n\n   $ %s\n\nAre you sure you still want to proceed [y/N]? " % self.get_cmd()):
                raise CancelDueToUserRequest('Test cancelled...')
574176
protected function checkDirectoryRights()
    {
        $translator = $this->getServiceLocator()->get('translator');
        $installHelper = $this->getServiceLocator()->get('InstallerHelper');

        $configDir = $installHelper->getDir('config');
        $module = $this->getModuleSvc()->getAllModules();

        $success = 0;
        $errors = [];
        $data = [];

        for ($x = 0; $x < count($configDir); $x++) {
            $configDir[$x] = 'config/' . $configDir[$x];
        }
        array_push($configDir, 'config');

        /**
         * Add config platform, MelisSites and public dir to check permission
         */
        array_push($configDir, 'config/autoload/platforms/');
        array_push($configDir, 'module/MelisModuleConfig/');
        array_push($configDir, 'module/MelisModuleConfig/languages');
        array_push($configDir, 'module/MelisModuleConfig/config');
        array_push($configDir, 'module/MelisSites/');
        array_push($configDir, 'dbdeploy/');
        array_push($configDir, 'dbdeploy/data');
        array_push($configDir, 'public/');
        array_push($configDir, 'cache/');
        array_push($configDir, 'test/');

        for ($x = 0; $x < count($module); $x++) {
            $module[$x] = $this->getModuleSvc()->getModulePath($module[$x], false) . '/config';
        }

        $dirs = array_merge($configDir, $module);

        $results = [];
        foreach ($dirs as $dir) {
            if (file_exists($dir)) {
                if ($installHelper->isDirWritable($dir)) {
                    $results[$dir] = 1;
                } else {
                    $results[$dir] = sprintf($translator->translate('tr_melis_installer_step_1_2_dir_not_writable'), $dir);
                    array_push($errors, sprintf($translator->translate('tr_melis_installer_step_1_2_dir_not_writable'), $dir));
                }
            }
        }

        if (empty($errors)) {
            $success = 1;
        }

        $response = [
            'success' => $success,
            'errors' => $errors,
            'data' => $results,
        ];


        return $response;
    }
1212092
protected function validateConfiguration()
    {
        if (!$this->environment->load(getcwd() . DIRECTORY_SEPARATOR . 'peridot.php')) {
            fwrite(STDERR, "Configuration file specified but does not exist" . PHP_EOL);
            exit(1);
        }
    }
865161
def _check_configuration(self, *attrs):
        
        for attr in attrs:
            if getattr(self, attr, None) is None:
                raise ConfigurationError("{} not configured".format(attr))
173908
def check_config_state(self):
        """"""
        config = self.config
        self.update_server_map(config)
        for member in config['members']:
            cfg_member_info = self.default_params.copy()
            cfg_member_info.update(member)
            # Remove attributes we can't check.
            for attr in ('priority', 'votes', 'tags', 'buildIndexes'):
                cfg_member_info.pop(attr, None)
            cfg_member_info['host'] = cfg_member_info['host'].lower()

            real_member_info = self.default_params.copy()
            info = self.member_info(member["_id"])
            real_member_info["_id"] = info['_id']
            member_hostname = self._servers.hostname(info['server_id'])
            real_member_info["host"] = member_hostname.lower()
            real_member_info.update(info['rsInfo'])
            logger.debug("real_member_info({member_id}): {info}".format(member_id=member['_id'], info=info))
            for key in cfg_member_info:
                if cfg_member_info[key] != real_member_info.get(key, None):
                    logger.debug("{key}: {value1} ! = {value2}".format(key=key, value1=cfg_member_info[key], value2=real_member_info.get(key, None)))
                    return False
        return True
595426
def basicConfig(**kwargs):
    """"""
    logging.basicConfig(**kwargs)
    logging._acquireLock()
    try:
        stream = logging.root.handlers[0]
        stream.setFormatter(
            ColoredFormatter(
                fmt=kwargs.get('format', BASIC_FORMAT),
                datefmt=kwargs.get('datefmt', None)))
    finally:
        logging._releaseLock()
853541
def _check_config_file(self, usr):
        '''  '''
        package_config_file = path.join(path.dirname(__file__), 'config')
        user_config_file = path.join(usr, 'config')

        ''' restore config from bck file '''
        if path.exists(user_config_file + '.restore'):
            try:
                copyfile(user_config_file + '.restore', user_config_file)
                remove(self.user_config_file + '.restore')
            except:
                pass

        ''' Copy package config into user dir '''
        if not path.exists(user_config_file):
            copyfile(package_config_file, user_config_file)
1195242
public function check_config()
    {
        $this->load_config();

        if (!$this->configured) {
            return;
        }

        $out = $seen = array();

        // iterate over the current configuration
        foreach (array_keys($this->config) as $prop) {
            if ($replacement = $this->replaced_config[$prop]) {
                $out['replaced'][]  = array('prop' => $prop, 'replacement' => $replacement);
                $seen[$replacement] = true;
            }
            else if (!$seen[$prop] && in_array($prop, $this->obsolete_config)) {
                $out['obsolete'][] = array('prop' => $prop);
                $seen[$prop]       = true;
            }
        }

        // the old default mime_magic reference is obsolete
        if ($this->config['mime_magic'] == '/usr/share/misc/magic') {
            $out['obsolete'][] = array(
                'prop'    => 'mime_magic',
                'explain' => "Set value to null in order to use system default"
            );
        }

        // check config dependencies and contradictions
        if ($this->config['enable_spellcheck'] && $this->config['spellcheck_engine'] == 'pspell') {
            if (!extension_loaded('pspell')) {
                $out['dependencies'][] = array(
                    'prop'    => 'spellcheck_engine',
                    'explain' => "This requires the <tt>pspell</tt> extension which could not be loaded."
                );
            }
            else if (!empty($this->config['spellcheck_languages'])) {
                foreach ($this->config['spellcheck_languages'] as $lang => $descr) {
                    if (!@pspell_new($lang)) {
                        $out['dependencies'][] = array(
                            'prop'    => 'spellcheck_languages',
                            'explain' => "You are missing pspell support for language $lang ($descr)"
                        );
                    }
                }
            }
        }

        if ($this->config['log_driver'] == 'syslog') {
            if (!function_exists('openlog')) {
                $out['dependencies'][] = array(
                    'prop'    => 'log_driver',
                    'explain' => "This requires the <tt>syslog</tt> extension which could not be loaded."
                );
            }

            if (empty($this->config['syslog_id'])) {
                $out['dependencies'][] = array(
                    'prop'    => 'syslog_id',
                    'explain' => "Using <tt>syslog</tt> for logging requires a syslog ID to be configured"
                );
            }
        }

        // check ldap_public sources having global_search enabled
        if (is_array($this->config['ldap_public']) && !is_array($this->config['autocomplete_addressbooks'])) {
            foreach ($this->config['ldap_public'] as $ldap_public) {
                if ($ldap_public['global_search']) {
                    $out['replaced'][] = array(
                        'prop'        => 'ldap_public::global_search',
                        'replacement' => 'autocomplete_addressbooks'
                    );
                    break;
                }
            }
        }

        return $out;
    }
761903
def check_config(config):
    ""
    shortnames = [count['shortname'] for count in config['count']]
    if len(shortnames) != len(set(shortnames)):
        logger.error("error: duplicate `shortname' in count configuration.")
        return False
    return True
173633
def check_settings!
      required_keys = %w(
        org
        project
      )

      required_keys.each do |key|
        unless Settings.send key
          error = "Config is missing required key '#{key}'. Please add it " \
            "to #{config_path} and try again."
          error += "\n\nFor more info, see https://github.com/jutonz/dctl_rb#required-keys"
          puts Rainbow(error).red
          exit 1
        end
      end
    end