def __init__(self, template_name=None, **kwargs): if template_name is not None: warn_deprecated( '0.9.1', "template_name is deprecated, use template_filename") kwargs['template_filename'] = template_name super().__init__(**kwargs)
def sendMessage(self, reports): build = reports[0]['builds'][0] if self.send.__func__ is not GiteaStatusPush.send: warn_deprecated('2.9.0', 'send() in reporters has been deprecated. Use sendMessage()') yield self.send(build) else: yield self._send_impl(reports)
def checkConfig(self, builders=None, debug=None, verify=None, wantProperties=False, wantSteps=False, wantPreviousBuild=False, wantLogs=False, generators=None, _has_old_arg_names=None): old_arg_names = { 'builders': builders is not None, 'wantProperties': wantProperties is not False, 'wantSteps': wantSteps is not False, 'wantPreviousBuild': wantPreviousBuild is not False, 'wantLogs': wantLogs is not False, } if _has_old_arg_names is not None: old_arg_names.update(_has_old_arg_names) passed_old_arg_names = [k for k, v in old_arg_names.items() if v] if passed_old_arg_names: old_arg_names_msg = ', '.join(passed_old_arg_names) if generators is not None: config.error(("can't specify generators and deprecated HTTPStatusPushBase " "arguments ({}) at the same time").format(old_arg_names_msg)) warn_deprecated('2.9.0', ('The arguments {} passed to {} have been deprecated. Use generators ' 'instead').format(old_arg_names_msg, self.__class__.__name__)) if generators is None: generators = self._create_generators_from_old_args(builders, wantProperties, wantSteps, wantPreviousBuild, wantLogs) super().checkConfig(generators=generators) httpclientservice.HTTPClientService.checkAvailable(self.__class__.__name__)
def warn_deprecated_if_oldstyle_subclass(self, name): if self.__class__.__name__ != name: warn_deprecated( '2.9.0', ('Subclassing old-style step {0} in {1} is deprecated, ' 'please migrate to new-style equivalent {0}NewStyle').format( name, self.__class__.__name__))
def __init__(self, owner, slug, branch=None, pollInterval=10 * 60, useTimestamps=True, category=None, project='', pullrequest_filter=True, encoding=_UNSPECIFIED, pollAtLaunch=False): self.owner = owner self.slug = slug self.branch = branch super().__init__(name='/'.join([owner, slug]), pollInterval=pollInterval, pollAtLaunch=pollAtLaunch) if encoding != _UNSPECIFIED: warn_deprecated( '2.6.0', 'encoding of BitbucketPullrequestPoller is deprecated.') if hasattr(pullrequest_filter, '__call__'): self.pullrequest_filter = pullrequest_filter else: self.pullrequest_filter = (lambda _: pullrequest_filter) self.lastChange = time.time() self.lastPoll = time.time() self.useTimestamps = useTimestamps self.category = category if callable(category) else bytes2unicode( category) self.project = bytes2unicode(project) self.initLock = defer.DeferredLock()
def addStep(self, step, **kwargs): if kwargs or (isinstance(step, type(BuildStep)) and issubclass(step, BuildStep)): warn_deprecated( "0.8.8", "Passing a BuildStep subclass to factory.addStep is " "deprecated. Please pass a BuildStep instance instead.") step = step(**kwargs) self.steps.append(interfaces.IBuildStepFactory(step))
def sendMessage(self, reports): # All reporters that subclass HttpStatusPushBase and are provided by Buildbot implement # sendMessage. So the only case when this function is called is when we have a custom # reporter that inherits from HttpStatusPushBase. warn_deprecated( '2.9.0', 'send() in reporters has been deprecated. Use sendMessage()') return self.send(reports[0]['builds'][0])
def addStep(self, step, **kwargs): if kwargs or (isinstance(step, type(buildstep.BuildStep)) and issubclass(step, buildstep.BuildStep)): warn_deprecated( "0.8.8", "Passing a BuildStep subclass to factory.addStep is " "deprecated. Please pass a BuildStep instance instead.") step = step(**kwargs) self.steps.append(buildstep.get_factory_from_step_or_factory(step))
def sendMessage(self, reports): if self.send.__func__ is not HttpStatusPush.send: warn_deprecated('2.9.0', 'send() in reporters has been deprecated. Use sendMessage()') yield self.send(reports[0]['builds'][0]) return response = yield self._http.post("", json=reports[0]['body']) if not self.isStatus2XX(response.code): log.msg("{}: unable to upload status: {}".format(response.code, response.content))
def __init__(self, **kwargs): if 'template_filename' in kwargs: warn_deprecated( '2.10.0', "template_filename is deprecated, supply the template as text") if 'subject_filename' in kwargs: warn_deprecated( '2.10.0', "subject_filename is deprecated, supply the template as text") super().__init__(**kwargs)
def checkConfig(self, mode=("failing", "passing", "warnings"), tags=None, builders=None, buildSetSummary=False, messageFormatter=None, subject="Buildbot %(result)s in %(title)s on %(builder)s", addLogs=False, addPatch=False, schedulers=None, branches=None, watchedWorkers=None, messageFormatterMissingWorker=None, generators=None, _has_old_arg_names=None): old_arg_names = { 'mode': mode != ("failing", "passing", "warnings"), 'tags': tags is not None, 'builders': builders is not None, 'buildSetSummary': buildSetSummary is not False, 'messageFormatter': messageFormatter is not None, 'subject': subject != "Buildbot %(result)s in %(title)s on %(builder)s", 'addLogs': addLogs is not False, 'addPatch': addPatch is not False, 'schedulers': schedulers is not None, 'branches': branches is not None, 'watchedWorkers': watchedWorkers is not None, 'messageFormatterMissingWorker': messageFormatterMissingWorker is not None, } if _has_old_arg_names is not None: old_arg_names.update(_has_old_arg_names) passed_old_arg_names = [k for k, v in old_arg_names.items() if v] if passed_old_arg_names: old_arg_names_msg = ', '.join(passed_old_arg_names) if generators is not None: config.error(("can't specify generators and deprecated notifier arguments ({}) " "at the same time").format(old_arg_names_msg)) warn_deprecated('2.9.0', ('The arguments {} passed to {} have been deprecated. Use generators ' 'instead').format(old_arg_names_msg, self.__class__.__name__)) if generators is None: generators = self.create_generators_from_old_args(mode, tags, builders, buildSetSummary, messageFormatter, subject, addLogs, addPatch, schedulers, branches, watchedWorkers, messageFormatterMissingWorker) for g in generators: g.check() if self.name is None: self.name = self.__class__.__name__ for g in generators: self.name += "_" + g.generate_name()
def __init__(self, master_or_worker, worker=None): # All the existing code passes just the name to the Connection, however we'll need to # support an older versions of buildbot-worker using two parameter signature for some time. if worker is None: worker = master_or_worker else: warn_deprecated( '3.2.0', 'LocalWorker: Using different version of buildbot-worker ' + 'than buildbot is not supported') super().__init__(worker.workername) self.worker = worker
def __init__(self, mode=("failing", "passing", "warnings"), tags=None, builders=None, schedulers=None, branches=None, subject=None, add_logs=False, add_patch=False, message_formatter=None): if subject is not None: warn_deprecated('3.5.0', 'BuildSetStatusGenerator subject parameter has been ' + 'deprecated: please configure subject in the message formatter') else: subject = "Buildbot %(result)s in %(title)s on %(builder)s" super().__init__(mode, tags, builders, schedulers, branches, subject, add_logs, add_patch) self.formatter = message_formatter if self.formatter is None: self.formatter = MessageFormatter()
def checkConfig(self, serverUrl, user=None, password=None, auth=None, format_fn=None, builders=None, wantProperties=False, wantSteps=False, wantPreviousBuild=False, wantLogs=False, generators=None, **kwargs): if user is not None and auth is not None: config.error("Only one of user/password or auth must be given") if user is not None: warn_deprecated( "0.9.1", "user/password is deprecated, use 'auth=(user, password)'") if (format_fn is not None) and not callable(format_fn): config.error("format_fn must be a function") old_arg_names = { 'format_fn': format_fn is not None, 'builders': builders is not None, 'wantProperties': wantProperties is not False, 'wantSteps': wantSteps is not False, 'wantPreviousBuild': wantPreviousBuild is not False, 'wantLogs': wantLogs is not False, } passed_old_arg_names = [k for k, v in old_arg_names.items() if v] if passed_old_arg_names: old_arg_names_msg = ', '.join(passed_old_arg_names) if generators is not None: config.error(( "can't specify generators and deprecated HTTPStatusPushBase " "arguments ({}) at the same time" ).format(old_arg_names_msg)) warn_deprecated('2.9.0', ( 'The arguments {} passed to {} have been deprecated. Use generators ' 'instead').format(old_arg_names_msg, self.__class__.__name__)) if generators is None: generators = self._create_generators_from_old_args( format_fn, builders, wantProperties, wantSteps, wantPreviousBuild, wantLogs) super().checkConfig(generators=generators, **kwargs)
def __init__( self, dbpool=None, test_type=None, test_info="", description=None, descriptionDone=None, autoCreateTables=False, textLimit=5, testNameLimit=16, parallel=4, logfiles=None, lazylogfiles=True, warningPattern="MTR's internal check of the test case '.*' failed", mtr_subdir="mysql-test", **kwargs): warn_deprecated( '2.9.0', 'The MTR step has been deprecated due to migration to new style ' 'steps and the build result APIs. It would be great if someone ' 'steps up and migrates the step to newer APIs and adds a proper ' 'test suite so that this situation never happens again.') if logfiles is None: logfiles = {} if description is None: description = ["testing"] if test_type: description.append(test_type) if descriptionDone is None: descriptionDone = ["test"] if test_type: descriptionDone.append(test_type) super().__init__(logfiles=logfiles, lazylogfiles=lazylogfiles, description=description, descriptionDone=descriptionDone, warningPattern=warningPattern, **kwargs) self.dbpool = dbpool self.test_type = test_type self.test_info = test_info self.autoCreateTables = autoCreateTables self.textLimit = textLimit self.testNameLimit = testNameLimit self.parallel = parallel self.mtr_subdir = mtr_subdir self.progressMetrics += ('tests', )
def __init__( self, owner, slug, branch=None, pollInterval=10 * 60, useTimestamps=True, category=None, project='', pullrequest_filter=True, encoding=_UNSPECIFIED, pollAtLaunch=False, auth=None, bitbucket_property_whitelist=None, ): self.owner = owner self.slug = slug self.branch = branch super().__init__(name='/'.join([owner, slug]), pollInterval=pollInterval, pollAtLaunch=pollAtLaunch) if encoding != _UNSPECIFIED: warn_deprecated( '2.6.0', 'encoding of BitbucketPullrequestPoller is deprecated.') if bitbucket_property_whitelist is None: bitbucket_property_whitelist = [] if hasattr(pullrequest_filter, '__call__'): self.pullrequest_filter = pullrequest_filter else: self.pullrequest_filter = (lambda _: pullrequest_filter) self.lastChange = time.time() self.lastPoll = time.time() self.useTimestamps = useTimestamps self.category = category if callable(category) else bytes2unicode( category) self.project = bytes2unicode(project) self.initLock = defer.DeferredLock() self.external_property_whitelist = bitbucket_property_whitelist if auth is not None: encoded_credentials = base64.b64encode(":".join(auth).encode()) self.headers = {b"Authorization": b"Basic " + encoded_credentials} else: self.headers = None
def create_block_device_mapping(self, mapping_definitions): if isinstance(mapping_definitions, list): for mapping_definition in mapping_definitions: ebs = mapping_definition.get('Ebs') if ebs: ebs.setdefault('DeleteOnTermination', True) return mapping_definitions warn_deprecated( '0.9.0', "Use of dict value to 'block_device_map' of EC2LatentWorker " "constructor is deprecated. Please use a list matching the AWS API " "https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_BlockDeviceMapping.html" ) return self._convert_deprecated_block_device_mapping( mapping_definitions)
def checkConfig(self, serverUrl, user=None, password=None, auth=None, format_fn=None, **kwargs): if user is not None and auth is not None: config.error("Only one of user/password or auth must be given") if user is not None: warn_deprecated( "0.9.1", "user/password is deprecated, use 'auth=(user, password)'") if (format_fn is not None) and not callable(format_fn): config.error("format_fn must be a function") super().checkConfig(**kwargs)
def __init__(self, template_dir=None, template_filename=None, template=None, template_name=None, subject_filename=None, subject=None, template_type=None, ctx=None, wantProperties=True, wantSteps=False, wantLogs=False): if template_name is not None: warn_deprecated('0.9.1', "template_name is deprecated, use template_filename") template_filename = template_name super().__init__(template_dir=template_dir, template_filename=template_filename, template=template, subject_filename=subject_filename, subject=subject, template_type=template_type, ctx=ctx) self.wantProperties = wantProperties self.wantSteps = wantSteps self.wantLogs = wantLogs
def __init__(self, command=None, logname=None, logfile=None, **kwargs): name = self.__class__.__name__ if command is None: config.error(f"the 'command' parameter of {name} must not be None") self.command = command self.logname = logname if logfile is not None: warn_deprecated('2.10.0', "{}: logfile is deprecated, use logname") if self.logname is not None: config.error(("{}: the 'logfile' parameter must not be specified when 'logname' " + "is set").format(name)) self.logname = logfile for k, v in kwargs.items(): if k not in self.resultConfig: config.error(f"the parameter '{k}' is not handled by ShellArg") setattr(self, k, v)
def checkConfig(self, vaultServer=None, vaultToken=None, secretsmount=None, apiVersion=1): warn_deprecated( "3.4.0", "Use of HashiCorpVaultSecretProvider is deprecated and will be " "removed in future releases. Use HashiCorpVaultKvSecretProvider instead" ) if not isinstance(vaultServer, str): config.error("vaultServer must be a string while it is {}".format( type(vaultServer))) if not isinstance(vaultToken, str): config.error("vaultToken must be a string while it is {}".format( type(vaultToken))) if apiVersion not in [1, 2]: config.error("apiVersion {} is not supported".format(apiVersion))
def getDbUrlFromConfig(config_dict, throwErrors=True): if 'db' in config_dict: db = config_dict['db'] if set(db.keys()) - set(['db_url', 'db_poll_interval' ]) and throwErrors: error("unrecognized keys in c['db']") config_dict = db if 'db_poll_interval' in config_dict and throwErrors: warn_deprecated( "0.8.7", "db_poll_interval is deprecated and will be ignored") # we don't attempt to parse db URLs here - the engine strategy will do # so. if 'db_url' in config_dict: return config_dict['db_url'] return DEFAULT_DB_URL
def checkConfig(self, name=None, pollInterval=60 * 10, pollAtLaunch=False, pollRandomDelayMin=0, pollRandomDelayMax=0, **kwargs): super().checkConfig(name=name, pollInterval=60 * 10, pollAtLaunch=False, pollRandomDelayMin=0, pollRandomDelayMax=0) warn_deprecated( '3.3.0', 'PollingChangeSource has been deprecated: ' + 'please use ReconfigurablePollingChangeSource') self.pollInterval = pollInterval self.pollAtLaunch = pollAtLaunch self.pollRandomDelayMin = pollRandomDelayMin self.pollRandomDelayMax = pollRandomDelayMax
def __init__(self, name, password, connection=None, hd_image=None, base_image=None, uri="system:///", xml=None, masterFQDN=None, **kwargs): super().__init__(name, password, **kwargs) if not libvirt: config.error( "The python module 'libvirt' is needed to use a LibVirtWorker") if connection is not None: warn_deprecated( '3.2.0', 'LibVirtWorker connection argument has been deprecated: ' + 'please use uri') if uri != "system:///": config.error( 'connection and uri arguments cannot be used together') uri = connection.uri self.uri = uri self.image = hd_image self.base_image = base_image self.xml = xml if masterFQDN: self.masterFQDN = masterFQDN else: self.masterFQDN = socket.getfqdn() self.cheap_copy = True self.graceful_shutdown = False
class HTTPClientService(service.SharedService): """ HTTPClientService is a SharedService class that fakes http requests for buildbot http service testing. This class is named the same as the real HTTPClientService so that it could replace the real class in tests. If a test creates this class earlier than the real one, fake is going to be used until the master is destroyed. Whenever a master wants to create real HTTPClientService, it will find an existing fake service with the same name and use it instead. """ quiet = False def __init__(self, base_url, auth=None, headers=None, debug=None, verify=None, skipEncoding=None): assert not base_url.endswith("/"), "baseurl should not end with /" super().__init__() self._base_url = base_url self._auth = auth self._headers = headers self._session = None self._expected = [] def updateHeaders(self, headers): if self._headers is None: self._headers = {} self._headers.update(headers) @classmethod def getFakeService(cls, master, case, *args, **kwargs): warn_deprecated( '2.9.0', 'getFakeService() has been deprecated, use getService()') return cls.getService(master, case, *args, **kwargs)
class HTTPClientService(service.SharedService): """A SharedService class that fakes http requests for buildbot http service testing. It is called HTTPClientService so that it substitute the real HTTPClientService if created earlier in the test. getName from the fake and getName from the real must return the same values. """ quiet = False def __init__(self, base_url, auth=None, headers=None, debug=None, verify=None, skipEncoding=None): assert not base_url.endswith("/"), "baseurl should not end with /" super().__init__() self._base_url = base_url self._auth = auth self._headers = headers self._session = None self._expected = [] def updateHeaders(self, headers): if self._headers is None: self._headers = {} self._headers.update(headers) @classmethod def getFakeService(cls, master, case, *args, **kwargs): warn_deprecated( '2.9.0', 'getFakeService() has been deprecated, use getService()') return cls.getService(master, case, *args, **kwargs)
def __init__(self, ctx=None, want_properties=True, wantProperties=None, want_steps=False, wantSteps=None, wantLogs=None, want_logs=False, want_logs_content=False): if ctx is None: ctx = {} self.context = ctx if wantProperties is not None: warn_deprecated( '3.4.0', f'{self.__class__.__name__}: wantProperties has been ' 'deprecated, use want_properties') self.want_properties = wantProperties else: self.want_properties = want_properties if wantSteps is not None: warn_deprecated( '3.4.0', f'{self.__class__.__name__}: wantSteps has been deprecated, ' + 'use want_steps') self.want_steps = wantSteps else: self.want_steps = want_steps if wantLogs is not None: warn_deprecated( '3.4.0', f'{self.__class__.__name__}: wantLogs has been deprecated, ' + 'use want_logs and want_logs_content') else: wantLogs = False self.want_logs = want_logs or wantLogs self.want_logs_content = want_logs_content or wantLogs
def isNewStyle(self): warn_deprecated('3.0.0', 'BuildStep.isNewStyle() always returns True') return True
def _changeCallback(self, key, msg, fileIsImportant, change_filter, onlyImportant): # ignore changes delivered while we're not running if not self._change_consumer: return # get a change object, since the API requires it chdict = yield self.master.db.changes.getChange(msg['changeid']) change = yield changes.Change.fromChdict(self.master, chdict) # filter it if change_filter: # There has been a change in how Gerrit handles branches in Buildbot 3.5 - ref-updated # events will now emit proper branch instead of refs/heads/<branch>. Below we detect # whether this breaks change filters. change_filter_may_be_broken = \ change.category == 'ref-updated' and not change.branch.startswith('refs/') if change_filter_may_be_broken: old_change = copy.deepcopy(change) old_change.branch = f'refs/heads/{old_change.branch}' old_filter_result = change_filter.filter_change(old_change) new_filter_result = change_filter.filter_change(change) if old_filter_result != new_filter_result and \ 'refs/heads/' in repr(change_filter.checks['branch']): warn_deprecated('3.5.0', 'Change filters must not expect ref-updated events from ' 'Gerrit to include refs/heads prefix for the branch attr.') if not old_filter_result: return else: if not new_filter_result: return else: if not change_filter.filter_change(change): return if change.codebase not in self.codebases: log.msg(format='change contains codebase %(codebase)s that is ' 'not processed by scheduler %(name)s', codebase=change.codebase, name=self.name) return if fileIsImportant: try: important = fileIsImportant(change) if not important and onlyImportant: return except Exception: log.err(failure.Failure(), f'in fileIsImportant check for {change}') return else: important = True # use change_consumption_lock to ensure the service does not stop # while this change is being processed d = self._change_consumption_lock.run( self.gotChange, change, important) d.addErrback(log.err, 'while processing change')
# This file is part of Buildbot. Buildbot is free software: you can # redistribute it and/or modify it under the terms of the GNU General Public # License as published by the Free Software Foundation, version 2. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # Copyright Buildbot Team Members from buildbot.status.worker_compat import WorkerStatus from buildbot.warnings import warn_deprecated # This file is here to allow few remaining users of status within Buildbot to use it # without triggering deprecation warnings _hush_pyflakes = [WorkerStatus] warn_deprecated( '0.9.0', 'buildbot.status.worker has been deprecated, consume the buildbot.data APIs' )