def __init__(self, name=None, slavename=None, slavenames=None, builddir=None, slavebuilddir=None, factory=None, category=None, nextSlave=None, nextBuild=None, locks=None, env=None): # name is required, and can't start with '_' if not name or type(name) not in (str, unicode): raise ValueError("builder's name is required") if name[0] == '_': raise ValueError("builder names must not start with an " "underscore: " + name) self.name = name # factory is required if factory is None: raise ValueError("builder's factory is required") self.factory = factory # slavenames can be a single slave name or a list, and should also # include slavename, if given if type(slavenames) is str: slavenames = [ slavenames ] if slavenames: if type(slavenames) is not list: raise TypeError("slavenames must be a list or a string") else: slavenames = [] if slavename: if type(slavename) != str: raise TypeError("slavename must be a string") slavenames = slavenames + [ slavename ] if not slavenames: raise ValueError("at least one slavename is required") self.slavenames = slavenames # builddir defaults to name if builddir is None: builddir = safeTranslate(name) self.builddir = builddir # slavebuilddir defaults to builddir if slavebuilddir is None: slavebuilddir = builddir self.slavebuilddir = slavebuilddir # remainder are optional assert category is None or isinstance(category, str) self.category = category self.nextSlave = nextSlave self.nextBuild = nextBuild self.locks = locks self.env = env
def watchfile_path(buildmaster_dir, build_name): """Deduce from build (factory) name the path to its watchfile. This function is normalized here for consistency accross the application. It has the side effect of creating intermediate directories, again for simple consistency. :return: absolute path from buildmaster dir """ watch_dir = os.path.join(buildmaster_dir, 'watch') if not os.path.exists(watch_dir): os.makedirs(watch_dir) return os.path.join(watch_dir, safeTranslate(build_name))
def _ComputeBuilders(builders, m_annotator): actual_builders = [] def cmp_fn(a, b): a_cat = builders['builders'][a].get('category') b_cat = builders['builders'][b].get('category') if a_cat != b_cat: return 1 if a_cat > b_cat else -1 if a != b: return 1 if a > b else -1 return 0 for builder_name in sorted(builders['builders'], cmp=cmp_fn): builder_data = builders['builders'][builder_name] has_schedulers = bool( builder_data.get('scheduler', builder_data.get('schedulers'))) # We will automatically merge all build requests for any # builder that can be scheduled; this is normally the behavior # we want for repo-triggered builders and cron-triggered builders. # You can override this behavior by setting the mergeRequests field though. merge_requests = builder_data.get('mergeRequests', has_schedulers) slavebuilddir = builder_data.get('slavebuilddir', util.safeTranslate(builder_name)) factory = m_annotator.BaseFactory( recipe=builder_data['recipe'], max_time=builder_data.get('builder_timeout_s'), factory_properties=builder_data.get('properties') ) actual_builders.append({ 'auto_reboot': builder_data.get('auto_reboot', True), 'mergeRequests': merge_requests, 'name': builder_name, 'factory': factory, 'slavebuilddir': slavebuilddir, 'slavenames': chromium_utils.GetSlaveNamesForBuilder(builders, builder_name), 'category': builder_data.get('category'), 'trybot': builder_data.get('trybot'), }) return actual_builders
def gen_name(self, *strings): """Returns the generated name based on the give strings """ strings = (self.name,) + strings # To make it clear exactly return safeTranslate("_".join(strings))
def get_change_filter(self, *args, **kwargs): p_filter = ChangeFilter( *args, projects=safeTranslate(self.name), **kwargs) return p_filter
def __init__(self, name=None, slavename=None, slavenames=None, builddir=None, slavebuilddir=None, factory=None, tags=None, category=None, nextSlave=None, nextBuild=None, locks=None, env=None, properties=None, collapseRequests=None, description=None, canStartBuild=None): # name is required, and can't start with '_' if not name or type(name) not in (str, unicode): error("builder's name is required") name = '<unknown>' elif name[0] == '_': error("builder names must not start with an underscore: '%s'" % name) try: self.name = util.ascii2unicode(name) except UnicodeDecodeError: error("builder names must be unicode or ASCII") # factory is required if factory is None: error("builder '%s' has no factory" % name) from buildbot.process.factory import BuildFactory if factory is not None and not isinstance(factory, BuildFactory): error("builder '%s's factory is not a BuildFactory instance" % name) self.factory = factory # slavenames can be a single slave name or a list, and should also # include slavename, if given if isinstance(slavenames, str): slavenames = [slavenames] if slavenames: if not isinstance(slavenames, list): error("builder '%s': slavenames must be a list or a string" % (name,)) else: slavenames = [] if slavename: if not isinstance(slavename, str): error("builder '%s': slavename must be a string" % (name,)) slavenames = slavenames + [slavename] if not slavenames: error("builder '%s': at least one slavename is required" % (name,)) self.slavenames = slavenames # builddir defaults to name if builddir is None: builddir = safeTranslate(name) self.builddir = builddir # slavebuilddir defaults to builddir if slavebuilddir is None: slavebuilddir = builddir self.slavebuilddir = slavebuilddir # remainder are optional if category and tags: error("builder '%s': builder categories are deprecated and " "replaced by tags; you should only specify tags" % (name,)) if category: warnDeprecated("0.9", "builder '%s': builder categories are " "deprecated and should be replaced with " "'tags=[cat]'" % (name,)) if not isinstance(category, str): error("builder '%s': category must be a string" % (name,)) tags = [category] if tags: if not isinstance(tags, list): error("builder '%s': tags must be a list" % (name,)) bad_tags = any((tag for tag in tags if not isinstance(tag, str))) if bad_tags: error("builder '%s': tags list contains something that is not a string" % (name,)) else: tags = [] self.tags = tags self.nextSlave = nextSlave if nextSlave and not callable(nextSlave): error('nextSlave must be a callable') self.nextBuild = nextBuild if nextBuild and not callable(nextBuild): error('nextBuild must be a callable') self.canStartBuild = canStartBuild if canStartBuild and not callable(canStartBuild): error('canStartBuild must be a callable') self.locks = locks or [] self.env = env or {} if not isinstance(self.env, dict): error("builder's env must be a dictionary") self.properties = properties or {} self.collapseRequests = collapseRequests self.description = description
def __init__(self, name=None, workername=None, workernames=None, builddir=None, workerbuilddir=None, factory=None, tags=None, nextWorker=None, nextBuild=None, locks=None, env=None, properties=None, collapseRequests=None, description=None, canStartBuild=None, defaultProperties=None): # name is required, and can't start with '_' if not name or type(name) not in (bytes, str): error("builder's name is required") name = '<unknown>' elif name[0] == '_' and name not in RESERVED_UNDERSCORE_NAMES: error( "builder names must not start with an underscore: '{}'".format( name)) try: self.name = util.bytes2unicode(name, encoding="ascii") except UnicodeDecodeError: error("builder names must be unicode or ASCII") # factory is required if factory is None: error("builder '{}' has no factory".format(name)) from buildbot.process.factory import BuildFactory if factory is not None and not isinstance(factory, BuildFactory): error( "builder '{}'s factory is not a BuildFactory instance".format( name)) self.factory = factory # workernames can be a single worker name or a list, and should also # include workername, if given if isinstance(workernames, str): workernames = [workernames] if workernames: if not isinstance(workernames, list): error("builder '{}': workernames must be a list or a string". format(name)) else: workernames = [] if workername: if not isinstance(workername, str): error(("builder '{}': workername must be a string but it is {}" ).format(name, repr(workername))) workernames = workernames + [workername] if not workernames: error("builder '{}': at least one workername is required".format( name)) self.workernames = workernames # builddir defaults to name if builddir is None: builddir = safeTranslate(name) builddir = bytes2unicode(builddir) self.builddir = builddir # workerbuilddir defaults to builddir if workerbuilddir is None: workerbuilddir = builddir self.workerbuilddir = workerbuilddir # remainder are optional if tags: if not isinstance(tags, list): error("builder '{}': tags must be a list".format(name)) bad_tags = any((tag for tag in tags if not isinstance(tag, str))) if bad_tags: error( "builder '{}': tags list contains something that is not a string" .format(name)) if len(tags) != len(set(tags)): dupes = " ".join({x for x in tags if tags.count(x) > 1}) error("builder '{}': tags list contains duplicate tags: {}". format(name, dupes)) else: tags = [] self.tags = tags self.nextWorker = nextWorker if nextWorker and not callable(nextWorker): error('nextWorker must be a callable') self.nextBuild = nextBuild if nextBuild and not callable(nextBuild): error('nextBuild must be a callable') self.canStartBuild = canStartBuild if canStartBuild and not callable(canStartBuild): error('canStartBuild must be a callable') self.locks = locks or [] self.env = env or {} if not isinstance(self.env, dict): error("builder's env must be a dictionary") self.properties = properties or {} self.defaultProperties = defaultProperties or {} self.collapseRequests = collapseRequests self.description = description
def test_unicode_bad(self): self.assertEqual(util.safeTranslate(unicode("speed=slow;quality=high")), str("speed_slow_quality_high"))
def test_str_good(self): self.assertEqual(util.safeTranslate(str("full")), str("full"))
def __init__( self, name=None, slavename=None, slavenames=None, builddir=None, slavebuilddir=None, factory=None, category=None, nextSlave=None, nextBuild=None, locks=None, env=None, properties=None, mergeRequests=None, description=None, canStartBuild=None, ): # name is required, and can't start with '_' if not name or type(name) not in (str, unicode): error("builder's name is required") name = "<unknown>" elif name[0] == "_": error("builder names must not start with an underscore: '%s'" % name) self.name = name # factory is required if factory is None: error("builder '%s' has no factory" % name) from buildbot.process.factory import BuildFactory if factory is not None and not isinstance(factory, BuildFactory): error("builder '%s's factory is not a BuildFactory instance" % name) self.factory = factory # slavenames can be a single slave name or a list, and should also # include slavename, if given if type(slavenames) is str: slavenames = [slavenames] if slavenames: if not isinstance(slavenames, list): error("builder '%s': slavenames must be a list or a string" % (name,)) else: slavenames = [] if slavename: if type(slavename) != str: error("builder '%s': slavename must be a string" % (name,)) slavenames = slavenames + [slavename] if not slavenames: error("builder '%s': at least one slavename is required" % (name,)) self.slavenames = slavenames # builddir defaults to name if builddir is None: builddir = safeTranslate(name) self.builddir = builddir # slavebuilddir defaults to builddir if slavebuilddir is None: slavebuilddir = builddir self.slavebuilddir = slavebuilddir # remainder are optional if category is not None and not isinstance(category, str): error("builder '%s': category must be a string" % (name,)) self.category = category or "" self.nextSlave = nextSlave if nextSlave and not callable(nextSlave): error("nextSlave must be a callable") self.nextBuild = nextBuild if nextBuild and not callable(nextBuild): error("nextBuild must be a callable") self.canStartBuild = canStartBuild if canStartBuild and not callable(canStartBuild): error("canStartBuild must be a callable") self.locks = locks or [] self.env = env or {} if not isinstance(self.env, dict): error("builder's env must be a dictionary") self.properties = properties or {} self.mergeRequests = mergeRequests self.description = description
def __init__(self, name=None, slavename=None, slavenames=None, builddir=None, slavebuilddir=None, factory=None, category=None, nextSlave=None, nextBuild=None, locks=None, env=None, properties=None, mergeRequests=None, description=None, canStartBuild=None): # name is required, and can't start with '_' if not name or type(name) not in (str, unicode): error("builder's name is required") name = '<unknown>' elif name[0] == '_': error("builder names must not start with an underscore: '%s'" % name) self.name = name # factory is required if factory is None: error("builder '%s' has no factory" % name) from buildbot.process.factory import BuildFactory if factory is not None and not isinstance(factory, BuildFactory): error("builder '%s's factory is not a BuildFactory instance" % name) self.factory = factory # slavenames can be a single slave name or a list, and should also # include slavename, if given if type(slavenames) is str: slavenames = [slavenames] if slavenames: if not isinstance(slavenames, list): error("builder '%s': slavenames must be a list or a string" % (name, )) else: slavenames = [] if slavename: if type(slavename) != str: error("builder '%s': slavename must be a string" % (name, )) slavenames = slavenames + [slavename] if not slavenames: error("builder '%s': at least one slavename is required" % (name, )) self.slavenames = slavenames # builddir defaults to name if builddir is None: builddir = safeTranslate(name) self.builddir = builddir # slavebuilddir defaults to builddir if slavebuilddir is None: slavebuilddir = builddir self.slavebuilddir = slavebuilddir # remainder are optional if category is not None and not isinstance(category, str): error("builder '%s': category must be a string" % (name, )) self.category = category or '' self.nextSlave = nextSlave if nextSlave and not callable(nextSlave): error('nextSlave must be a callable') self.nextBuild = nextBuild if nextBuild and not callable(nextBuild): error('nextBuild must be a callable') self.canStartBuild = canStartBuild if canStartBuild and not callable(canStartBuild): error('canStartBuild must be a callable') self.locks = locks or [] self.env = env or {} if not isinstance(self.env, dict): error("builder's env must be a dictionary") self.properties = properties or {} self.mergeRequests = mergeRequests self.description = description
def __init__(self, name=None, slavename=None, slavenames=None, builddir=None, slavebuilddir=None, factory=None, tags=None, category=None, nextSlave=None, nextBuild=None, locks=None, env=None, properties=None, mergeRequests=None, description=None, canStartBuild=None): # name is required, and can't start with '_' if not name or type(name) not in (str, unicode): error("builder's name is required") name = '<unknown>' elif name[0] == '_': error("builder names must not start with an underscore: '%s'" % name) try: self.name = util.ascii2unicode(name) except UnicodeDecodeError: error("builder names must be unicode or ASCII") # factory is required if factory is None: error("builder '%s' has no factory" % name) from buildbot.process.factory import BuildFactory if factory is not None and not isinstance(factory, BuildFactory): error("builder '%s's factory is not a BuildFactory instance" % name) self.factory = factory # slavenames can be a single slave name or a list, and should also # include slavename, if given if isinstance(slavenames, str): slavenames = [slavenames] if slavenames: if not isinstance(slavenames, list): error("builder '%s': slavenames must be a list or a string" % (name, )) else: slavenames = [] if slavename: if not isinstance(slavename, str): error("builder '%s': slavename must be a string" % (name, )) slavenames = slavenames + [slavename] if not slavenames: error("builder '%s': at least one slavename is required" % (name, )) self.slavenames = slavenames # builddir defaults to name if builddir is None: builddir = safeTranslate(name) self.builddir = builddir # slavebuilddir defaults to builddir if slavebuilddir is None: slavebuilddir = builddir self.slavebuilddir = slavebuilddir # remainder are optional if category and tags: error("builder '%s': builder categories are deprecated and " "replaced by tags; you should only specify tags" % (name, )) if category: warnDeprecated( "0.9", "builder '%s': builder categories are " "deprecated and should be replaced with " "'tags=[cat]'" % (name, )) if not isinstance(category, str): error("builder '%s': category must be a string" % (name, )) tags = [category] if tags: if not isinstance(tags, list): error("builder '%s': tags must be a list" % (name, )) bad_tags = any((tag for tag in tags if not isinstance(tag, str))) if bad_tags: error( "builder '%s': tags list contains something that is not a string" % (name, )) self.tags = tags self.nextSlave = nextSlave if nextSlave and not callable(nextSlave): error('nextSlave must be a callable') self.nextBuild = nextBuild if nextBuild and not callable(nextBuild): error('nextBuild must be a callable') self.canStartBuild = canStartBuild if canStartBuild and not callable(canStartBuild): error('canStartBuild must be a callable') self.locks = locks or [] self.env = env or {} if not isinstance(self.env, dict): error("builder's env must be a dictionary") self.properties = properties or {} self.mergeRequests = mergeRequests self.description = description
def _ComputeBuilders(builders, m_annotator, active_master_cls): actual_builders = [] def cmp_fn(a, b): a_cat = builders['builders'][a].get('category') b_cat = builders['builders'][b].get('category') if a_cat != b_cat: return 1 if a_cat > b_cat else -1 if a != b: return 1 if a > b else -1 return 0 for builder_name in sorted(builders['builders'], cmp=cmp_fn): builder_data = builders['builders'][builder_name] has_schedulers = bool( builder_data.get('scheduler', builder_data.get('schedulers'))) # We will automatically merge all build requests for any # builder that can be scheduled; this is normally the behavior # we want for repo-triggered builders and cron-triggered builders. # You can override this behavior by setting the mergeRequests field though. merge_requests = builder_data.get('mergeRequests', has_schedulers) slavebuilddir = builder_data.get('slavebuilddir', util.safeTranslate(builder_name)) props = {} props.update(builders.get('default_properties', {}).copy()) if builder_data.get('use_remote_run'): props.update( builders.get('default_remote_run_properties', {}).copy()) props.update(builder_data.get('properties', {})) if builder_data.get('use_remote_run'): factory = remote_run_factory.RemoteRunFactory( active_master=active_master_cls, repository=builder_data.get( 'repository', builders.get('default_remote_run_repository')), recipe=builder_data['recipe'], max_time=builder_data.get('builder_timeout_s'), factory_properties=props, ) else: factory = m_annotator.BaseFactory( recipe=builder_data['recipe'], max_time=builder_data.get('builder_timeout_s'), factory_properties=props, ) actual_builders.append({ 'auto_reboot': builder_data.get('auto_reboot', True), 'mergeRequests': merge_requests, 'name': builder_name, 'factory': factory, 'slavebuilddir': slavebuilddir, 'slavenames': chromium_utils.GetSlaveNamesForBuilder(builders, builder_name), 'category': builder_data.get('category'), 'trybot': builder_data.get('trybot'), }) return actual_builders
def __init__(self, name=None, workername=None, workernames=None, builddir=None, workerbuilddir=None, factory=None, tags=None, category=None, nextWorker=None, nextBuild=None, locks=None, env=None, properties=None, collapseRequests=None, description=None, canStartBuild=None, defaultProperties=None): # name is required, and can't start with '_' if not name or type(name) not in (bytes, str): error("builder's name is required") name = '<unknown>' elif name[0] == '_' and name not in RESERVED_UNDERSCORE_NAMES: error( "builder names must not start with an underscore: '{}'".format( name)) try: self.name = util.bytes2unicode(name, encoding="ascii") except UnicodeDecodeError: error("builder names must be unicode or ASCII") # factory is required if factory is None: error("builder '{}' has no factory".format(name)) from buildbot.process.factory import BuildFactory if factory is not None and not isinstance(factory, BuildFactory): error( "builder '{}'s factory is not a BuildFactory instance".format( name)) self.factory = factory # workernames can be a single worker name or a list, and should also # include workername, if given if isinstance(workernames, str): workernames = [workernames] if workernames: if not isinstance(workernames, list): error("builder '{}': workernames must be a list or a string". format(name)) else: workernames = [] if workername: if not isinstance(workername, str): error(("builder '{}': workername must be a string but it is {}" ).format(name, repr(workername))) workernames = workernames + [workername] if not workernames: error("builder '{}': at least one workername is required".format( name)) self.workernames = workernames # builddir defaults to name if builddir is None: builddir = safeTranslate(name) builddir = bytes2unicode(builddir) self.builddir = builddir # workerbuilddir defaults to builddir if workerbuilddir is None: workerbuilddir = builddir self.workerbuilddir = workerbuilddir # remainder are optional if category and tags: error(( "builder '{}': builder categories are deprecated and " "replaced by tags; you should only specify tags").format(name)) if category: warnDeprecated("0.9", ("builder '{}': builder categories are " "deprecated and should be replaced with " "'tags=[cat]'").format(name)) if not isinstance(category, str): error("builder '{}': category must be a string".format(name)) tags = [category] if tags: if not isinstance(tags, list): error("builder '{}': tags must be a list".format(name)) bad_tags = any((tag for tag in tags if not isinstance(tag, str))) if bad_tags: error( "builder '{}': tags list contains something that is not a string" .format(name)) if len(tags) != len(set(tags)): dupes = " ".join({x for x in tags if tags.count(x) > 1}) error("builder '{}': tags list contains duplicate tags: {}". format(name, dupes)) else: tags = [] self.tags = tags self.nextWorker = nextWorker if nextWorker and not callable(nextWorker): error('nextWorker must be a callable') # Keeping support of the previous nextWorker API if nextWorker: argCount = self._countFuncArgs(nextWorker) if (argCount == 2 or (isinstance(nextWorker, MethodType) and argCount == 3)): warnDeprecated( "0.9", "nextWorker now takes a " "3rd argument (build request)") self.nextWorker = lambda x, y, z: nextWorker( x, y) # pragma: no cover self.nextBuild = nextBuild if nextBuild and not callable(nextBuild): error('nextBuild must be a callable') self.canStartBuild = canStartBuild if canStartBuild and not callable(canStartBuild): error('canStartBuild must be a callable') self.locks = locks or [] self.env = env or {} if not isinstance(self.env, dict): error("builder's env must be a dictionary") self.properties = properties or {} self.defaultProperties = defaultProperties or {} self.collapseRequests = collapseRequests self.description = description
def __init__( self, name=None, workername=None, workernames=None, builddir=None, workerbuilddir=None, factory=None, tags=None, category=None, nextWorker=None, nextBuild=None, locks=None, env=None, properties=None, collapseRequests=None, description=None, canStartBuild=None, slavename=None, # deprecated, use `workername` instead slavenames=None, # deprecated, use `workernames` instead # deprecated, use `workerbuilddir` instead slavebuilddir=None, nextSlave=None, # deprecated, use `nextWorker` instead ): # Deprecated API support. if slavename is not None: reportDeprecatedWorkerNameUsage( "'slavename' keyword argument is deprecated, " "use 'workername' instead") assert workername is None workername = slavename if slavenames is not None: reportDeprecatedWorkerNameUsage( "'slavenames' keyword argument is deprecated, " "use 'workernames' instead") assert workernames is None workernames = slavenames if slavebuilddir is not None: reportDeprecatedWorkerNameUsage( "'slavebuilddir' keyword argument is deprecated, " "use 'workerbuilddir' instead") assert workerbuilddir is None workerbuilddir = slavebuilddir if nextSlave is not None: reportDeprecatedWorkerNameUsage( "'nextSlave' keyword argument is deprecated, " "use 'nextWorker' instead") assert nextWorker is None nextWorker = nextSlave # name is required, and can't start with '_' if not name or type(name) not in (str, unicode): error("builder's name is required") name = '<unknown>' elif name[0] == '_': error("builder names must not start with an underscore: '%s'" % name) try: self.name = util.ascii2unicode(name) except UnicodeDecodeError: error("builder names must be unicode or ASCII") # factory is required if factory is None: error("builder '%s' has no factory" % name) from buildbot.process.factory import BuildFactory if factory is not None and not isinstance(factory, BuildFactory): error("builder '%s's factory is not a BuildFactory instance" % name) self.factory = factory # workernames can be a single worker name or a list, and should also # include workername, if given if isinstance(workernames, str): workernames = [workernames] if workernames: if not isinstance(workernames, list): error("builder '%s': workernames must be a list or a string" % (name, )) else: workernames = [] if workername: if not isinstance(workername, str): error("builder '%s': workername must be a string" % (name, )) workernames = workernames + [workername] if not workernames: error("builder '%s': at least one workername is required" % (name, )) self.workernames = workernames self._registerOldWorkerAttr("workernames") # builddir defaults to name if builddir is None: builddir = safeTranslate(name) self.builddir = builddir # workerbuilddir defaults to builddir if workerbuilddir is None: workerbuilddir = builddir self.workerbuilddir = workerbuilddir self._registerOldWorkerAttr("workerbuilddir") # remainder are optional if category and tags: error("builder '%s': builder categories are deprecated and " "replaced by tags; you should only specify tags" % (name, )) if category: warnDeprecated( "0.9", "builder '%s': builder categories are " "deprecated and should be replaced with " "'tags=[cat]'" % (name, )) if not isinstance(category, str): error("builder '%s': category must be a string" % (name, )) tags = [category] if tags: if not isinstance(tags, list): error("builder '%s': tags must be a list" % (name, )) bad_tags = any((tag for tag in tags if not isinstance(tag, str))) if bad_tags: error( "builder '%s': tags list contains something that is not a string" % (name, )) else: tags = [] self.tags = tags self.nextWorker = nextWorker self._registerOldWorkerAttr("nextWorker") if nextWorker and not callable(nextWorker): error('nextWorker must be a callable') # Keeping support of the previous nextWorker API if nextWorker and (nextWorker.func_code.co_argcount == 2 or (isinstance(nextWorker, MethodType) and nextWorker.func_code.co_argcount == 3)): warnDeprecated( "0.9", "nextWorker now takes a 3rd argument (build request)") self.nextWorker = lambda x, y, z: nextWorker(x, y ) # pragma: no cover self.nextBuild = nextBuild if nextBuild and not callable(nextBuild): error('nextBuild must be a callable') self.canStartBuild = canStartBuild if canStartBuild and not callable(canStartBuild): error('canStartBuild must be a callable') self.locks = locks or [] self.env = env or {} if not isinstance(self.env, dict): error("builder's env must be a dictionary") self.properties = properties or {} self.collapseRequests = collapseRequests self.description = description
def __init__(self, name=None, slavename=None, startSlavenames=None, slavenames=None, builddir=None, slavebuilddir=None, factory=None, category=None, nextSlave=None, nextBuild=None, locks=None, env=None, properties=None, mergeRequests=None, project=None, friendly_name=None, tags=[], description=None, canStartBuild=None, excludeGlobalFactory=False, customBuildUrls=None, build_tags=None, mergeProperties=None): # name is required, and can't start with '_' if not name or not isinstance(name, basestring): error("builder's name is required") name = '<unknown>' elif name[0] == '_': error("builder names must not start with an underscore: '%s'" % name) self.name = name # friendly_name is not required if friendly_name is None: self.friendly_name = name elif not isinstance(friendly_name, basestring): error("builder's friendly name must be a valid string" % friendly_name) self.friendly_name = name else: self.friendly_name = friendly_name # factory is required if factory is None: error("builder '%s' has no factory" % name) from buildbot.process.factory import BuildFactory if factory is not None and not isinstance(factory, BuildFactory): error("builder '%s's factory is not a BuildFactory instance" % name) self.factory = factory # slavenames can be a single slave name or a list, and should also # include slavename, if given if type(slavenames) is str: slavenames = [slavenames] if slavenames: if not isinstance(slavenames, list): error("builder '%s': slavenames must be a list or a string" % (name, )) else: slavenames = [] if slavename: if type(slavename) != str: error("builder '%s': slavename must be a string" % (name, )) slavenames = slavenames + [slavename] if not slavenames: error("builder '%s': at least one slavename is required" % (name, )) self.slavenames = slavenames if startSlavenames: if not isinstance(startSlavenames, list): error("builder '%s': startSlavenames must be a list" % (name, )) for sn in startSlavenames: if sn != 'Not Available' and sn in self.slavenames: error( "builder '%s': startSlavenames must not contain slaves from slavenames list" % (name, )) self.startSlavenames = startSlavenames if not isinstance(excludeGlobalFactory, bool): error("builder's excludeGlobalFactory must be a bool") self.excludeGlobalFactory = excludeGlobalFactory if not project: error("builder '%s' has no project" % name) # builddir defaults to name if builddir is None: builddir = safeTranslate(name) self.builddir = builddir # slavebuilddir defaults to builddir if slavebuilddir is None: slavebuilddir = builddir self.slavebuilddir = slavebuilddir # remainder are optional if category is not None and not isinstance(category, str): error("builder '%s': category must be a string" % (name, )) self.category = category or '' self.nextSlave = nextSlave if nextSlave and not callable(nextSlave): error('nextSlave must be a callable') self.nextBuild = nextBuild if nextBuild and not callable(nextBuild): error('nextBuild must be a callable') self.canStartBuild = canStartBuild if canStartBuild and not callable(canStartBuild): error('canStartBuild must be a callable') self.locks = locks or [] self.env = env or {} if not isinstance(self.env, dict): error("builder's env must be a dictionary") self.properties = properties or {} self.mergeRequests = mergeRequests self.project = project self.tags = tags self.build_tags = build_tags # Additional properties that must match to allow buildrequests of # this config to be merged self.mergeProperties = mergeProperties or [] self.description = description self.customBuildUrls = customBuildUrls or {} self._validateCustomBuildUrls()
def _mod_builders(project): for builder in project["builders"]: builddir_name = safeTranslate( project["name"]) + builder.name builder.builddir = os.path.join( "build_data", builddir_name)
def test_str_pathological(self): # if you needed proof this wasn't for use with sensitive data self.assertEqual(util.safeTranslate(str("p\ath\x01ogy")), str("p\ath\x01ogy")) # bad chars still here!
def test_str_good(self): self.assertEqual(util.safeTranslate(str("full")), b"full")
def __init__(self, name=None, slavename=None, slavenames=None, builddir=None, slavebuilddir=None, factory=None, category=None, nextSlave=None, nextBuild=None, locks=None, env=None, properties=None, mergeRequests=None): # name is required, and can't start with '_' if not name or type(name) not in (str, unicode): raise ValueError("builder's name is required") if name[0] == '_': raise ValueError("builder names must not start with an " "underscore: " + name) self.name = name # factory is required if factory is None: raise ValueError("builder's factory is required") self.factory = factory # slavenames can be a single slave name or a list, and should also # include slavename, if given if type(slavenames) is str: slavenames = [ slavenames ] if slavenames: if type(slavenames) is not list: raise TypeError("slavenames must be a list or a string") else: slavenames = [] if slavename: if type(slavename) != str: raise TypeError("slavename must be a string") slavenames = slavenames + [ slavename ] if not slavenames: raise ValueError("at least one slavename is required") self.slavenames = slavenames # builddir defaults to name if builddir is None: builddir = safeTranslate(name) self.builddir = builddir # slavebuilddir defaults to builddir if slavebuilddir is None: slavebuilddir = builddir self.slavebuilddir = slavebuilddir # remainder are optional assert category is None or isinstance(category, str) self.category = category self.nextSlave = nextSlave self.nextBuild = nextBuild self.locks = locks self.env = env self.properties = properties self.mergeRequests = mergeRequests
def test_str_bad(self): self.assertEqual(util.safeTranslate(str("speed=slow;quality=high")), b"speed_slow_quality_high")
def test_unicode_good(self): self.assertEqual(util.safeTranslate(u"full"), str("full"))
def test_str_pathological(self): # if you needed proof this wasn't for use with sensitive data self.assertEqual(util.safeTranslate(str("p\ath\x01ogy")), b"p\ath\x01ogy") # bad chars still here!
def test_unicode_pathological(self): self.assertEqual(util.safeTranslate(u"\u0109"), str("\xc4\x89")) # yuck!
def test_unicode_good(self): self.assertEqual(util.safeTranslate(u"full"), b"full")
def __init__(self, name=None, workername=None, workernames=None, builddir=None, workerbuilddir=None, factory=None, tags=None, category=None, nextWorker=None, nextBuild=None, locks=None, env=None, properties=None, collapseRequests=None, description=None, canStartBuild=None, slavename=None, # deprecated, use `workername` instead slavenames=None, # deprecated, use `workernames` instead # deprecated, use `workerbuilddir` instead slavebuilddir=None, nextSlave=None, # deprecated, use `nextWorker` instead ): # Deprecated API support. if slavename is not None: reportDeprecatedWorkerNameUsage( "'slavename' keyword argument is deprecated, " "use 'workername' instead") assert workername is None workername = slavename if slavenames is not None: reportDeprecatedWorkerNameUsage( "'slavenames' keyword argument is deprecated, " "use 'workernames' instead") assert workernames is None workernames = slavenames if slavebuilddir is not None: reportDeprecatedWorkerNameUsage( "'slavebuilddir' keyword argument is deprecated, " "use 'workerbuilddir' instead") assert workerbuilddir is None workerbuilddir = slavebuilddir if nextSlave is not None: reportDeprecatedWorkerNameUsage( "'nextSlave' keyword argument is deprecated, " "use 'nextWorker' instead") assert nextWorker is None nextWorker = nextSlave # name is required, and can't start with '_' if not name or type(name) not in (str, text_type): error("builder's name is required") name = '<unknown>' elif name[0] == '_': error( "builder names must not start with an underscore: '%s'" % name) try: self.name = util.ascii2unicode(name) except UnicodeDecodeError: error("builder names must be unicode or ASCII") # factory is required if factory is None: error("builder '%s' has no factory" % name) from buildbot.process.factory import BuildFactory if factory is not None and not isinstance(factory, BuildFactory): error("builder '%s's factory is not a BuildFactory instance" % name) self.factory = factory # workernames can be a single worker name or a list, and should also # include workername, if given if isinstance(workernames, str): workernames = [workernames] if workernames: if not isinstance(workernames, list): error("builder '%s': workernames must be a list or a string" % (name,)) else: workernames = [] if workername: if not isinstance(workername, str): error("builder '%s': workername must be a string" % (name,)) workernames = workernames + [workername] if not workernames: error("builder '%s': at least one workername is required" % (name,)) self.workernames = workernames self._registerOldWorkerAttr("workernames") # builddir defaults to name if builddir is None: builddir = safeTranslate(name) self.builddir = builddir # workerbuilddir defaults to builddir if workerbuilddir is None: workerbuilddir = builddir self.workerbuilddir = workerbuilddir self._registerOldWorkerAttr("workerbuilddir") # remainder are optional if category and tags: error("builder '%s': builder categories are deprecated and " "replaced by tags; you should only specify tags" % (name,)) if category: warnDeprecated("0.9", "builder '%s': builder categories are " "deprecated and should be replaced with " "'tags=[cat]'" % (name,)) if not isinstance(category, str): error("builder '%s': category must be a string" % (name,)) tags = [category] if tags: if not isinstance(tags, list): error("builder '%s': tags must be a list" % (name,)) bad_tags = any((tag for tag in tags if not isinstance(tag, str))) if bad_tags: error( "builder '%s': tags list contains something that is not a string" % (name,)) if len(tags) != len(set(tags)): dupes = " ".join(set([x for x in tags if tags.count(x) > 1])) error( "builder '%s': tags list contains duplicate tags: %s" % (name, dupes)) else: tags = [] self.tags = tags self.nextWorker = nextWorker self._registerOldWorkerAttr("nextWorker") if nextWorker and not callable(nextWorker): error('nextWorker must be a callable') # Keeping support of the previous nextWorker API if nextWorker and (nextWorker.func_code.co_argcount == 2 or (isinstance(nextWorker, MethodType) and nextWorker.func_code.co_argcount == 3)): warnDeprecated( "0.9", "nextWorker now takes a 3rd argument (build request)") self.nextWorker = lambda x, y, z: nextWorker( x, y) # pragma: no cover self.nextBuild = nextBuild if nextBuild and not callable(nextBuild): error('nextBuild must be a callable') self.canStartBuild = canStartBuild if canStartBuild and not callable(canStartBuild): error('canStartBuild must be a callable') self.locks = locks or [] self.env = env or {} if not isinstance(self.env, dict): error("builder's env must be a dictionary") self.properties = properties or {} self.collapseRequests = collapseRequests self.description = description
def test_unicode_bad(self): self.assertEqual( util.safeTranslate(text_type("speed=slow;quality=high")), b"speed_slow_quality_high")
def __init__(self, name=None, workername=None, workernames=None, builddir=None, workerbuilddir=None, factory=None, tags=None, category=None, nextWorker=None, nextBuild=None, locks=None, env=None, properties=None, collapseRequests=None, description=None, canStartBuild=None, defaultProperties=None ): # name is required, and can't start with '_' if not name or type(name) not in (bytes, str): error("builder's name is required") name = '<unknown>' elif name[0] == '_' and name not in RESERVED_UNDERSCORE_NAMES: error( "builder names must not start with an underscore: '%s'" % name) try: self.name = util.bytes2unicode(name, encoding="ascii") except UnicodeDecodeError: error("builder names must be unicode or ASCII") # factory is required if factory is None: error("builder '%s' has no factory" % name) from buildbot.process.factory import BuildFactory if factory is not None and not isinstance(factory, BuildFactory): error("builder '%s's factory is not a BuildFactory instance" % name) self.factory = factory # workernames can be a single worker name or a list, and should also # include workername, if given if isinstance(workernames, str): workernames = [workernames] if workernames: if not isinstance(workernames, list): error("builder '%s': workernames must be a list or a string" % (name,)) else: workernames = [] if workername: if not isinstance(workername, str): error("builder '%s': workername must be a string but it is %r" % ( name, workername)) workernames = workernames + [workername] if not workernames: error("builder '%s': at least one workername is required" % (name,)) self.workernames = workernames # builddir defaults to name if builddir is None: builddir = safeTranslate(name) builddir = bytes2unicode(builddir) self.builddir = builddir # workerbuilddir defaults to builddir if workerbuilddir is None: workerbuilddir = builddir self.workerbuilddir = workerbuilddir # remainder are optional if category and tags: error("builder '%s': builder categories are deprecated and " "replaced by tags; you should only specify tags" % (name,)) if category: warnDeprecated("0.9", "builder '%s': builder categories are " "deprecated and should be replaced with " "'tags=[cat]'" % (name,)) if not isinstance(category, str): error("builder '%s': category must be a string" % (name,)) tags = [category] if tags: if not isinstance(tags, list): error("builder '%s': tags must be a list" % (name,)) bad_tags = any((tag for tag in tags if not isinstance(tag, str))) if bad_tags: error( "builder '%s': tags list contains something that is not a string" % (name,)) if len(tags) != len(set(tags)): dupes = " ".join({x for x in tags if tags.count(x) > 1}) error( "builder '%s': tags list contains duplicate tags: %s" % (name, dupes)) else: tags = [] self.tags = tags self.nextWorker = nextWorker if nextWorker and not callable(nextWorker): error('nextWorker must be a callable') # Keeping support of the previous nextWorker API if nextWorker: argCount = self._countFuncArgs(nextWorker) if (argCount == 2 or (isinstance(nextWorker, MethodType) and argCount == 3)): warnDeprecated( "0.9", "nextWorker now takes a " "3rd argument (build request)") self.nextWorker = lambda x, y, z: nextWorker( x, y) # pragma: no cover self.nextBuild = nextBuild if nextBuild and not callable(nextBuild): error('nextBuild must be a callable') self.canStartBuild = canStartBuild if canStartBuild and not callable(canStartBuild): error('canStartBuild must be a callable') self.locks = locks or [] self.env = env or {} if not isinstance(self.env, dict): error("builder's env must be a dictionary") self.properties = properties or {} self.defaultProperties = defaultProperties or {} self.collapseRequests = collapseRequests self.description = description
def test_unicode_pathological(self): self.assertEqual(util.safeTranslate(u"\u0109"), b"\xc4\x89") # yuck!