def checkConfig(self, fromaddr, relayhost="localhost", lookup=None, extraRecipients=None, sendToInterestedUsers=True, extraHeaders=None, useTls=False, useSmtps=False, smtpUser=None, smtpPassword=None, smtpPort=25, dumpMailsToLog=False, generators=None): if ESMTPSenderFactory is None: config.error("twisted-mail is not installed - cannot " "send mail") if generators is None: generators = self._create_default_generators() super().checkConfig(generators=generators) if extraRecipients is None: extraRecipients = [] if not isinstance(extraRecipients, (list, tuple)): config.error("extraRecipients must be a list or tuple") else: for r in extraRecipients: if not isinstance(r, str) or not VALID_EMAIL.search(r): config.error( "extra recipient {} is not a valid email".format(r)) if lookup is not None: if not isinstance(lookup, str): assert interfaces.IEmailLookup.providedBy(lookup) if extraHeaders: if not isinstance(extraHeaders, dict): config.error("extraHeaders must be a dictionary") if useSmtps: ssl.ensureHasSSL(self.__class__.__name__)
def checkConfig(self, host, nick, channels, pm_to_nicks=None, port=6667, allowForce=False, tags=None, password=None, notify_events=None, showBlameList=True, useRevisions=False, useSSL=False, lostDelay=None, failedDelay=None, useColors=True, allowShutdown=False, **kwargs): deprecated_params = list(kwargs) if deprecated_params: config.error("%s are deprecated" % (",".join(deprecated_params))) if allowForce not in (True, False): config.error("allowForce must be boolean, not %r" % (allowForce, )) if allowShutdown not in (True, False): config.error("allowShutdown must be boolean, not %r" % (allowShutdown, )) if useSSL: # SSL client needs a ClientContextFactory for some SSL mumbo-jumbo ssl.ensureHasSSL(self.__class__.__name__)
def checkConfig(self, host, nick, channels, pm_to_nicks=None, port=6667, allowForce=None, tags=None, password=None, notify_events=None, showBlameList=True, useRevisions=False, useSSL=False, useSASL=False, lostDelay=None, failedDelay=None, useColors=True, allowShutdown=None, noticeOnChannel=False, authz=None, **kwargs): deprecated_params = list(kwargs) if deprecated_params: config.error(f'{",".join(deprecated_params)} are deprecated') # deprecated if allowForce is not None: if authz is not None: config.error( "If you specify authz, you must not use allowForce anymore" ) if allowForce not in (True, False): config.error( f"allowForce must be boolean, not {repr(allowForce)}") log.msg('IRC: allowForce is deprecated: use authz instead') if allowShutdown is not None: if authz is not None: config.error( "If you specify authz, you must not use allowShutdown anymore" ) if allowShutdown not in (True, False): config.error( f"allowShutdown must be boolean, not {repr(allowShutdown)}" ) log.msg('IRC: allowShutdown is deprecated: use authz instead') # ### if noticeOnChannel not in (True, False): config.error( f"noticeOnChannel must be boolean, not {repr(noticeOnChannel)}" ) if useSSL: # SSL client needs a ClientContextFactory for some SSL mumbo-jumbo ssl.ensureHasSSL(self.__class__.__name__) if authz is not None: for acl in authz.values(): if not isinstance(acl, (list, tuple, bool)): config.error( "authz values must be bool or a list of nicks")
def test_ConfigError(self): ssl.ssl_import_error = "lib xxx do not exist" ssl.has_ssl = False self.patch(config, "_errors", mock.Mock()) ssl.ensureHasSSL("myplugin") config._errors.addError.assert_called_with( "TLS dependencies required for myplugin are not installed : " "lib xxx do not exist\n pip install 'buildbot[tls]'")
def checkConfig(self, fromaddr, mode=("failing", "passing", "warnings"), tags=None, builders=None, addLogs=False, relayhost="localhost", buildSetSummary=False, subject="Buildbot %(result)s in %(title)s on %(builder)s", lookup=None, extraRecipients=None, sendToInterestedUsers=True, messageFormatter=None, extraHeaders=None, addPatch=True, useTls=False, useSmtps=False, smtpUser=None, smtpPassword=None, smtpPort=25, name=None, schedulers=None, branches=None, watchedWorkers='all', messageFormatterMissingWorker=None): if ESMTPSenderFactory is None: config.error("twisted-mail is not installed - cannot " "send mail") super(MailNotifier, self).checkConfig(mode, tags, builders, buildSetSummary, messageFormatter, subject, addLogs, addPatch, name, schedulers, branches, watchedWorkers, messageFormatterMissingWorker) if extraRecipients is None: extraRecipients = [] if not isinstance(extraRecipients, (list, tuple)): config.error("extraRecipients must be a list or tuple") else: for r in extraRecipients: if not isinstance(r, str) or not VALID_EMAIL.search(r): config.error("extra recipient %r is not a valid email" % (r, )) if lookup is not None: if not isinstance(lookup, string_types): assert interfaces.IEmailLookup.providedBy(lookup) if extraHeaders: if not isinstance(extraHeaders, dict): config.error("extraHeaders must be a dictionary") if useSmtps: ssl.ensureHasSSL(self.__class__.__name__)
def test_ConfigError(self): old_error = ssl.ssl_import_error old_has_ssl = ssl.has_ssl try: ssl.ssl_import_error = "lib xxx do not exist" ssl.has_ssl = False with capture_config_errors() as errors: ssl.ensureHasSSL("myplugin") self.assertConfigError( errors, "TLS dependencies required for myplugin are not installed : " "lib xxx do not exist\n pip install 'buildbot[tls]'") finally: ssl.ssl_import_error = old_error ssl.has_ssl = old_has_ssl
def checkConfig(self, host, nick, channels, pm_to_nicks=None, port=6667, allowForce=False, tags=None, password=None, notify_events=None, showBlameList=True, useRevisions=False, useSSL=False, lostDelay=None, failedDelay=None, useColors=True, allowShutdown=False, **kwargs ): deprecated_params = list(kwargs) if deprecated_params: config.error("%s are deprecated" % (",".join(deprecated_params))) if allowForce not in (True, False): config.error("allowForce must be boolean, not %r" % (allowForce,)) if allowShutdown not in (True, False): config.error("allowShutdown must be boolean, not %r" % (allowShutdown,)) if useSSL: # SSL client needs a ClientContextFactory for some SSL mumbo-jumbo ssl.ensureHasSSL(self.__class__.__name__)
def checkConfig(self, fromaddr, mode=("failing", "passing", "warnings"), tags=None, builders=None, addLogs=False, relayhost="localhost", buildSetSummary=False, subject="Buildbot %(result)s in %(title)s on %(builder)s", lookup=None, extraRecipients=None, sendToInterestedUsers=True, messageFormatter=None, extraHeaders=None, addPatch=True, useTls=False, useSmtps=False, smtpUser=None, smtpPassword=None, smtpPort=25, schedulers=None, branches=None, watchedWorkers='all', messageFormatterMissingWorker=None): if ESMTPSenderFactory is None: config.error("twisted-mail is not installed - cannot " "send mail") super(MailNotifier, self).checkConfig( mode=mode, tags=tags, builders=builders, buildSetSummary=buildSetSummary, messageFormatter=messageFormatter, subject=subject, addLogs=addLogs, addPatch=addPatch, schedulers=schedulers, branches=branches, watchedWorkers=watchedWorkers, messageFormatterMissingWorker=messageFormatterMissingWorker) if extraRecipients is None: extraRecipients = [] if not isinstance(extraRecipients, (list, tuple)): config.error("extraRecipients must be a list or tuple") else: for r in extraRecipients: if not isinstance(r, str) or not VALID_EMAIL.search(r): config.error( "extra recipient {} is not a valid email".format(r)) if lookup is not None: if not isinstance(lookup, str): assert interfaces.IEmailLookup.providedBy(lookup) if extraHeaders: if not isinstance(extraHeaders, dict): config.error("extraHeaders must be a dictionary") if useSmtps: ssl.ensureHasSSL(self.__class__.__name__)
def checkConfig(self, fromaddr, mode=("failing", "passing", "warnings"), tags=None, builders=None, addLogs=False, relayhost="localhost", buildSetSummary=False, subject="buildbot %(result)s in %(title)s on %(builder)s", lookup=None, extraRecipients=None, sendToInterestedUsers=True, messageFormatter=None, extraHeaders=None, addPatch=True, useTls=False, useSmtps=False, smtpUser=None, smtpPassword=None, smtpPort=25, name=None, schedulers=None, branches=None): if ESMTPSenderFactory is None: config.error("twisted-mail is not installed - cannot " "send mail") if extraRecipients is None: extraRecipients = [] if not isinstance(extraRecipients, (list, tuple)): config.error("extraRecipients must be a list or tuple") else: for r in extraRecipients: if not isinstance(r, str) or not VALID_EMAIL.search(r): config.error("extra recipient %r is not a valid email" % (r, )) for m in self.computeShortcutModes(mode): if m not in self.possible_modes: if m == "all": config.error( "mode 'all' is not valid in an iterator and must be passed in as a separate string" ) else: config.error("mode %s is not a valid mode" % (m, )) if name is None: self.name = "MailNotifier" if tags is not None: self.name += "_tags_" + "+".join(tags) if builders is not None: self.name += "_builders_" + "+".join(builders) if schedulers is not None: self.name += "_schedulers_" + "+".join(schedulers) if branches is not None: self.name += "_branches_" + "+".join(branches) if '\n' in subject: config.error('Newlines are not allowed in email subjects') if lookup is not None: if not isinstance(lookup, string_types): assert interfaces.IEmailLookup.providedBy(lookup) if extraHeaders: if not isinstance(extraHeaders, dict): config.error("extraHeaders must be a dictionary") if useSmtps: ssl.ensureHasSSL(self.__class__.__name__) # you should either limit on builders or tags, not both if builders is not None and tags is not None: config.error("Please specify only builders or tags to include - " + "not both.")
def checkConfig(self, fromaddr, mode=("failing", "passing", "warnings"), tags=None, builders=None, addLogs=False, relayhost="localhost", buildSetSummary=False, subject="buildbot %(result)s in %(title)s on %(builder)s", lookup=None, extraRecipients=None, sendToInterestedUsers=True, messageFormatter=None, extraHeaders=None, addPatch=True, useTls=False, useSmtps=False, smtpUser=None, smtpPassword=None, smtpPort=25, name=None, schedulers=None, branches=None): if ESMTPSenderFactory is None: config.error("twisted-mail is not installed - cannot " "send mail") if extraRecipients is None: extraRecipients = [] if not isinstance(extraRecipients, (list, tuple)): config.error("extraRecipients must be a list or tuple") else: for r in extraRecipients: if not isinstance(r, str) or not VALID_EMAIL.search(r): config.error( "extra recipient %r is not a valid email" % (r,)) for m in self.computeShortcutModes(mode): if m not in self.possible_modes: if m == "all": config.error( "mode 'all' is not valid in an iterator and must be passed in as a separate string") else: config.error( "mode %s is not a valid mode" % (m,)) if name is None: self.name = "MailNotifier" if tags is not None: self.name += "_tags_" + "+".join(tags) if builders is not None: self.name += "_builders_" + "+".join(builders) if schedulers is not None: self.name += "_schedulers_" + "+".join(schedulers) if branches is not None: self.name += "_branches_" + "+".join(branches) if '\n' in subject: config.error( 'Newlines are not allowed in email subjects') if lookup is not None: if not isinstance(lookup, string_types): assert interfaces.IEmailLookup.providedBy(lookup) if extraHeaders: if not isinstance(extraHeaders, dict): config.error("extraHeaders must be a dictionary") if useSmtps: ssl.ensureHasSSL(self.__class__.__name__) # you should either limit on builders or tags, not both if builders is not None and tags is not None: config.error( "Please specify only builders or tags to include - " + "not both.")