def _process_log_files(logdata): files = set( itertools.chain.from_iterable(ensure_collection(logdata.get(key, ""), set) for key in ("file", "files")) ) if not files: raise ConfigError("no files specified") return files
def _process_log_files(logdata): files = set( itertools.chain.from_iterable( ensure_collection(logdata.get(key, ''), set) for key in ('file', 'files'))) if not files: raise ConfigError('no files specified') return files
def _process_log_actions(logdata, name, auto_actions, available): if not any(x in logdata for x in ("action", "actions")): return auto_actions actions = set( itertools.chain.from_iterable(ensure_collection(logdata.get(key, ""), set) for key in ("action", "actions")) ) invalid = next((x for x in actions if x not in available), None) if invalid is not None: raise ConfigError("invalid action specified: {}".format(invalid)) return actions
def _process_log_actions(logdata, name, auto_actions, available): if not any(x in logdata for x in ('action', 'actions')): return auto_actions actions = set( itertools.chain.from_iterable( ensure_collection(logdata.get(key, ''), set) for key in ('action', 'actions'))) invalid = next((x for x in actions if x not in available), None) if invalid is not None: raise ConfigError('invalid action specified: {}'.format(invalid)) return actions
def __init__(self, data): self.host = data.get('host', 'localhost') self.port = data.get('port', 0) self.ssl = data.get('ssl', False) self.starttls = data.get('starttls', False) self.username = data.get('username') self.password = data.get('password') self.sender = data.get('from') or self._get_sender() try: self.recipients = sorted(ensure_collection(data['to'], set)) except KeyError: raise ConfigError('email recipient (to) missing') self.subject = data.get('subject', 'unusual system events') self.group_by_source = data.get('group', False) if self.ssl and self.starttls: raise ConfigError('ssl and starttls are mutually exclusive') if bool(self.username) != bool(self.password): raise ConfigError('username and password must both be set or unset')
def __init__(self, data): self.host = data.get('host', 'localhost') self.port = data.get('port', 0) self.ssl = data.get('ssl', False) self.starttls = data.get('starttls', False) self.username = data.get('username') self.password = data.get('password') self.sender = data.get('from') or self._get_sender() try: self.recipients = sorted(ensure_collection(data['to'], set)) except KeyError: raise ConfigError('email recipient (to) missing') self.subject = data.get('subject', 'unusual system events') self.group_by_source = data.get('group', False) if self.ssl and self.starttls: raise ConfigError('ssl and starttls are mutually exclusive') if bool(self.username) != bool(self.password): raise ConfigError( 'username and password must both be set or unset')
def _process_log_regexps(logdata, name, available): regexps = ensure_collection(logdata.get('regex', name), tuple) invalid = next((x for x in regexps if x not in available), None) if invalid is not None: raise ConfigError('invalid regex specified: {}'.format(invalid)) return regexps
def _process_log_regexps(logdata, name, available): regexps = ensure_collection(logdata.get("regex", name), tuple) invalid = next((x for x in regexps if x not in available), None) if invalid is not None: raise ConfigError("invalid regex specified: {}".format(invalid)) return regexps
def test_ensure_collection(value, collection_type, result): assert util.ensure_collection(value, collection_type) == result