Perform some basic configuration validation.
491167
def validate(self):
        
        if not self.conf.get('auth_token'):
            raise PacketManagerException('The auth token for Packet is not defined but required.')
        if not self.conf.get('projects'):
            raise PacketManagerException('Required "projects" section is missing.')

        projects = self.conf.get('projects')
        if not projects.keys():
            raise PacketManagerException('At least one project at Packet is required.')

        failure = False
        for project, identifier in projects.items():
            if not identifier:
                failure = True
                logging.error('Project "%s" has no valid identifier.', project)
        if failure:
            raise PacketManagerException('One or more projects are not setup appropriately.')
1140545
def _verify_config(self):
        '''
        
        '''
        if not self.config_dict:
            self._raise_config_exception('No config found')
        # Check for device conifg, if there isn't anything then just log, do not raise an exception
        for dev_os, dev_config in self.config_dict.items():
            if not dev_config:
                log.warning('No config found for %s', dev_os)
                continue
            # Compare the valid opts with the conifg
            self._verify_config_dict(CONFIG.VALID_CONFIG, dev_config, dev_os)
        log.debug('Read the config without error')
227561
protected function validateConfig()
    {
        $defaults = [
            'tpl_folder',
            'cache_folder',
            'tpl_file_format',
            //'compress',
            //'event_emitter',
        ];

        foreach ($defaults as $key) {
            if (! isset($this->config[$key])) {
                throw new InvalidConfigException(sprintf("Missing a configuration key (%s)", $key));
            }
        }
    }
503034
def _validate_config(config_path):
    '''
    
    '''
    log.debug('Checking configuration file: %s', config_path)

    if not os.path.isfile(config_path):
        message = 'Unable to get configuration file: {}'.format(config_path)
        log.error(message)
        raise SaltInvocationError(message)
    log.debug('Found configuration file: %s', config_path)
506710
def validate(config):
    '''
    
    '''
    _config = {}
    list(map(_config.update, config))

    if not isinstance(config, list):
        return False, ('Configuration for avahi_announce '
                       'beacon must be a list.')

    elif not all(x in _config for x in ('servicetype',
                                        'port',
                                        'txt')):
        return False, ('Configuration for avahi_announce beacon '
                       'must contain servicetype, port and txt items.')
    return True, 'Valid beacon configuration.'
227780
def setConfiguration(self, configuration):
        
        """
        if isinstance(configuration, Configuration):
           configuration = configuration.value

        self.dev.set_configuration(configuration)
1222063
def validate_config(cls, config):
        
        if "discovery" not in config:
            raise ValueError("No discovery method defined.")

        if not any([item in config for item in ["port", "ports"]]):
            raise ValueError("No port(s) defined.")

        cls.validate_check_configs(config)
115534
protected function validateConfig()
    {
        $this->queueDriver = $this->createQueueDriver();
        $this->requiredFields = $this->queueDriver->getRequiredConfig();
        $this->config = array_merge($this->queueDriver->getDefaultConfig(), $this->config);
        parent::validateConfig();
    }
335835
def validate_config(cls, config):
        
        if "config_file" not in config:
            raise ValueError("No config file path given")
        if "socket_file" not in config:
            raise ValueError("No control socket path given")
        if "pid_file" not in config:
            raise ValueError("No PID file path given")
        if "stats" in config and "port" not in config["stats"]:
            raise ValueError("Stats interface defined, but no port given")
        if "proxies" in config:
            cls.validate_proxies_config(config["proxies"])

        return config
980238
static void validateConfigurations(Configuration conf) throws ValidationException {
        if (null == conf.getHandlers()) {
            Log.error(
                    "Handler should not be null, One or more handler implementation shuld be configured in the configuration",
                    ErrorGuide.getGuide(ErrorGuide.EMPTY_HANDLERS));
            throw new ValidationException("Configuration error", ValidationException.VALIDATION_LEVEL_INVALID);
        }
        if (null == conf.getLayout()) {
            Log.error("Layout should not be null, A layout implementation shuld be configured in the configuration",
                    ErrorGuide.getGuide(ErrorGuide.EMPTY_LAYOUT));
            throw new ValidationException("Configuration error", ValidationException.VALIDATION_LEVEL_INVALID);
        }

    }
939384
def check_configuration(ctx, base_key, needed_keys):
    

    # check for valid configuration
    if base_key not in ctx.keys():
        exit("[{}ERROR{}] missing configuration for '{}'"
             .format(ERROR_COLOR, RESET_COLOR, base_key))
        # TODO: offer to create configuration file
    if ctx.releaser is None:
        exit("[{}ERROR{}] empty configuration for '{}' found"
             .format(ERROR_COLOR, RESET_COLOR, base_key))
        # TODO: offer to create configuration file

    # TODO: allow use of default values
    for my_key in needed_keys:
        if my_key not in ctx[base_key].keys():
            exit("[{}ERROR{}] missing configuration key '{}.{}'"
                 .format(ERROR_COLOR, RESET_COLOR, base_key, my_key))
1120256
def main():
    """"""
    __async__ = True
    logging.basicConfig(format="%(levelname)-10s %(message)s",
                        level=logging.DEBUG)

    if len(sys.argv) != 2:
        logging.error("Must specify configuration file")
        sys.exit()
    config = configparser.ConfigParser()
    config.read(sys.argv[1])

    password = config.get('default', 'password')
    if __async__:
        client = Client(config.get('default', 'host'),
                        config.getint('default', 'port'), password, _callback)
    else:
        client = Client(config.get('default', 'host'),
                        config.getint('default', 'port'),
                        password)
        status = client.messages()
        msg = status[0]
        print(msg)
        print(client.mp3(msg['sha'].encode('utf-8')))
    while True:
        continue
932740
def ready(self):
        """"""
        super(ElasticAppConfig, self).ready()
        _validate_config(settings.get_setting("strict_validation"))
        _connect_signals()
734621
def _validate_config(self):
        
        # exit if no backend specified
        if not self.backend:
            return
        # exit if no required config keys
        if len(self.REQUIRED_CONFIG_KEYS) < 1:
            return

        self.config = self.config or {}  # default to empty dict of no config
        required_keys_set = set(self.REQUIRED_CONFIG_KEYS)
        config_keys_set = set(self.config.keys())
        missing_required_keys = required_keys_set - config_keys_set
        unrecognized_keys = config_keys_set - required_keys_set

        # if any missing required key raise ValidationError
        if len(missing_required_keys) > 0:
            # converts list in comma separated string
            missing_keys_string = ', '.join(missing_required_keys)
            # django error
            raise ValidationError(_('Missing required config keys: "%s"') % missing_keys_string)
        elif len(unrecognized_keys) > 0:
            # converts list in comma separated string
            unrecognized_keys_string = ', '.join(unrecognized_keys)
            # django error
            raise ValidationError(_('Unrecognized config keys: "%s"') % unrecognized_keys_string)
709314
def check_config(self, config):
        
        validation = ""
        required = ["name", "currency", "IBAN", "BIC"]

        for config_item in required:
            if config_item not in config:
                validation += config_item.upper() + "_MISSING "

        if not validation:
            return True
        else:
            raise Exception("Config file did not validate. " + validation)
803497
def validate(config):
    '''
    
    '''
    # Must be a list of dicts.
    if not isinstance(config, list):
        return False, 'Configuration for napalm beacon must be a list.'
    for mod in config:
        fun = mod.keys()[0]
        fun_cfg = mod.values()[0]
        if not isinstance(fun_cfg, dict):
            return False, 'The match structure for the {} execution function output must be a dictionary'.format(fun)
        if fun not in __salt__:
            return False, 'Execution function {} is not availabe!'.format(fun)
    return True, 'Valid configuration for the napal beacon!'
1184450
public void validate() {
    StringBuilder validationErrorBuilder = new StringBuilder("Process engine configuration is invalid: \n");
    boolean isValid = true;    
    
    if(datasourceJndiName == null || datasourceJndiName.isEmpty()) {
      isValid = false;
      validationErrorBuilder.append(" property 'datasource' cannot be null \n");      
    }
    if(engineName == null || engineName.isEmpty()) {
      isValid = false;
      validationErrorBuilder.append(" property 'engineName' cannot be null \n");
    }

    for (int i = 0; i < pluginConfigurations.size(); i++) {
      ProcessEnginePluginXml pluginConfiguration = pluginConfigurations.get(i);
      if (pluginConfiguration.getPluginClass() == null || pluginConfiguration.getPluginClass().isEmpty()) {
        isValid = false;
        validationErrorBuilder.append(" property 'class' in plugin[" + i + "] cannot be null \n");
      }
    }
    
    if(!isValid) {
      throw new ProcessEngineException(validationErrorBuilder.toString());
    }
  }