Exit if config is invalid.
547862
def ensure_valid_environment_config(module_name, config):
    """"""
    if not config.get('namespace'):
        LOGGER.fatal("staticsite: module %s's environment configuration is "
                     "missing a namespace definition!",
                     module_name)
        sys.exit(1)
1229647
def validate_config_value(value, possible_values):
  
  if value not in possible_values:
    raise Exception('Invalid config value "%s". Possible values are '
                    '%s' % (value, ', '.join(e for e in possible_values)))
652858
def exit(self, status=0, message=None):
        '''
        
        '''
        self.exited = True
        if message is not None:
            self.mesgs.extend(message.split('\n'))
        raise s_exc.BadSyntax(mesg=message, prog=self.prog, status=status)
849288
def invalid_config_error_message(action, key, val):
    """"""
    if action in ('store_true', 'store_false'):
        return ("{0} is not a valid value for {1} option, "
                "please specify a boolean value like yes/no, "
                "true/false or 1/0 instead.").format(val, key)

    return ("{0} is not a valid value for {1} option, "
            "please specify a numerical value like 1/0 "
            "instead.").format(val, key)
590038
def validate(self, config):
        
        if not isinstance(config, dict):
            raise errors.SchemeValidationError(
                'Scheme can only validate a dictionary config, but was given '
                '{} (type: {})'.format(config, type(config))
            )

        for arg in self.args:
            # the option exists in the config
            if arg.name in config:
                arg.validate(config[arg.name])

            # the option does not exist in the config
            else:
                # if the option is not required, then it is fine to omit.
                # otherwise, its omission constitutes a validation error.
                if arg.required:
                    raise errors.SchemeValidationError(
                        'Option "{}" is required, but not found.'.format(arg.name)
                    )
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));
            }
        }
    }
961599
def discard_config(self):
        """"""
        if self.config_session is not None:
            commands = []
            commands.append('configure session {}'.format(self.config_session))
            commands.append('abort')
            self.device.run_commands(commands)
            self.config_session = None
1200283
function _validateConfig(config) {
    for (var i = 0; i < REQUIRED_CONFIG_VARIABLES.length; i++) {
        var key = REQUIRED_CONFIG_VARIABLES[i];
        var value = config.DubBotBase[key];
        if (!value || value === "UNSET") {
            throw new Error("No value has been set in config for key: DubBotBase." + key);
        }
    }
}
949405
def validate(self):
        """"""
        missing = []
        for k, v in self._map.items():
            attr = getattr(self, k, False)
            if not attr or attr == CONFIG_PLACEHOLDER:
                missing.append(v)
        if missing:
            return "Missing or invalid config values: {}".format(
                ", ".join(sorted(missing))
            )
939130
protected function _validateConfig()
    {
        foreach ($this->_config as $key => $value) {
            if (!isset($value)) {
                throw new \Exception('Incomplete configuration: ' . $key, 1);
            }
        }
    }
567285
def run_and_exit_if(opts, action, *names):
    
    for name in names:
        if name in opts:
            action()
            sys.exit(0)
727108
def validate(config):
    '''
    
    '''

    try:
        _validate(config)
        return True, 'Valid beacon configuration'
    except ValidationError as error:
        return False, str(error)
1058257
function validate(cosmiconfig) {
  if (!cosmiconfig) {
    printColumns(
      chalk.red(
        `Oops, no stylelint config found, we support cosmiconfig...${EOL}` +
          chalk.cyan('https://github.com/davidtheclark/cosmiconfig')
      )
    );

    return process.exit(1);
  }

  if (!argv.unused && !argv.deprecated && !argv.invalid && !argv.current && !argv.available) {
    printColumns(chalk.red(`Oops, one of the command line Options must be set...${EOL}`));
    yargs.showHelp();

    return process.exit(1);
  }

  return cosmiconfig;
}
662646
def cleanup(self):
        """"""
        self.exit_config_mode()
        self.write_channel("logout" + self.RETURN)
        count = 0
        while count <= 5:
            time.sleep(0.5)
            output = self.read_channel()
            if "Do you want to log out" in output:
                self._session_log_fin = True
                self.write_channel("y" + self.RETURN)
            # Don't automatically save the config (user's responsibility)
            elif "Do you want to save the current" in output:
                self._session_log_fin = True
                self.write_channel("n" + self.RETURN)

            try:
                self.write_channel(self.RETURN)
            except socket.error:
                break
            count += 1
252914
def validate(config):
    '''
    
    '''
    if not isinstance(config, list):
        return False, ('Configuration for network_settings '
                       'beacon must be a list.')
    else:
        _config = {}
        list(map(_config.update, config))

        interfaces = _config.get('interfaces', {})
        if isinstance(interfaces, list):
            #Old syntax
            return False, ('interfaces section for network_settings beacon'
                           ' must be a dictionary.')

        for item in interfaces:
            if not isinstance(_config['interfaces'][item], dict):
                return False, ('Interface attributes for network_settings beacon'
                               ' must be a dictionary.')
            if not all(j in ATTRS for j in _config['interfaces'][item]):
                return False, ('Invalid attributes in beacon configuration.')
    return True, 'Valid beacon configuration'
1068850
def exit(exit_code=0):
  
  """
  core.processExitHooks()

  if state.isExitHooked and not hasattr(sys, 'exitfunc'): # The function is called from the exit hook
    sys.stderr.flush()
    sys.stdout.flush()
    os._exit(exit_code) #pylint: disable=W0212

  sys.exit(exit_code)
712350
def validate(config):
    '''
    
    '''

    VALID_ITEMS = [
        'type', 'bytes_sent', 'bytes_recv', 'packets_sent',
        'packets_recv', 'errin', 'errout', 'dropin',
        'dropout'
    ]

    # Configuration for load beacon should be a list of dicts
    if not isinstance(config, list):
        return False, ('Configuration for network_info beacon must be a list.')
    else:

        _config = {}
        list(map(_config.update, config))

        for item in _config.get('interfaces', {}):
            if not isinstance(_config['interfaces'][item], dict):
                return False, ('Configuration for network_info beacon must '
                               'be a list of dictionaries.')
            else:
                if not any(j in VALID_ITEMS for j in _config['interfaces'][item]):
                    return False, ('Invalid configuration item in '
                                   'Beacon configuration.')
    return True, 'Valid beacon configuration'