def createAuthConfig(self): if 'auth' not in self.cfgdict: return authcfg = self.cfgdict['auth'] if 'type' not in authcfg: return createAuthConfigMethod = 'createAuthConfig' + authcfg['type'] if not hasattr(self, createAuthConfigMethod): config_error("auth type {} is not supported".format( authcfg['type'])) return auth = getattr(self, createAuthConfigMethod)(authcfg) if auth is None: return self.config['www']['auth'] = auth if 'authztype' not in authcfg: return createAuthzConfigMethod = 'createAuthzConfig' + authcfg['authztype'] if not hasattr(self, createAuthzConfigMethod): config_error("authz type {} is not supported".format( authcfg['authztype'])) return authz = getattr(self, createAuthzConfigMethod)(authcfg) if authz: self.config['www']['authz'] = authz
def createAuthConfig(self): if 'auth' not in self.cfgdict: return authcfg = self.cfgdict['auth'] if 'type' not in authcfg: return createAuthConfigMethod = 'createAuthConfig' + authcfg['type'] if not hasattr(self, createAuthConfigMethod): config_error("auth type {} is not supported".format(authcfg['type'])) return auth = getattr(self, createAuthConfigMethod)(authcfg) if auth is None: return self.config['www']['auth'] = auth if 'authztype' not in authcfg: return createAuthzConfigMethod = 'createAuthzConfig' + authcfg['authztype'] if not hasattr(self, createAuthzConfigMethod): config_error("authz type {} is not supported".format(authcfg['authztype'])) return authz = getattr(self, createAuthzConfigMethod)(authcfg) if authz: self.config['www']['authz'] = authz
def configAssertContains(self, cfg, names): hasError = False for n in names: if n not in cfg: config_error("auth requires parameter {} but only has {}".format(n, cfg)) hasError = True return not hasError
def fromDict(self, y): buildbot_travis.api.setCfg(y) self.cfgdict = y self.createWorkerConfig() self.importantManager = ImportantManager( y.setdefault("not_important_files", [])) self.defaultEnv = y.setdefault("env", {}) for k, v in self.defaultEnv.items(): if not (isinstance(v, list) or isinstance(v, basestring)): config_error( "'env' values must be strings or lists ; key %s is incorrect: %s" % (k, type(v))) for p in y.setdefault("projects", []): self.define_travis_builder(**p) self.defaultStages = y.setdefault("stages", []) for s in self.defaultStages: if not isinstance(s, basestring): config_error( "'stages' values must be strings ; stage %s is incorrect: %s" % (s, type(s))) PORT = int(os.environ.get('PORT', 8010)) self.config['buildbotURL'] = os.environ.get( 'buildbotURL', "http://localhost:%d/" % (PORT, )) db_url = os.environ.get('BUILDBOT_DB_URL') if db_url is not None: self.config.setdefault('db', {'db_url': db_url}) # minimalistic config to activate new web UI self.config['www'] = dict(port=PORT, change_hook_dialects=self.change_hook_dialects, plugins=dict(buildbot_travis={ 'supported_vcs': getSupportedVCSTypes()}), versions=[('buildbot_travis', getVersion(__file__))]) self.config.setdefault('protocols', {'pb': {'port': 9989}}) self.createAuthConfig()
def fromDict(self, y): buildbot_travis.api.setCfg(y) self.cfgdict = y self.importantManager = ImportantManager( y.get("not_important_files", [])) self.defaultEnv = y.get("env", {}) for k, v in self.defaultEnv.items(): if not (isinstance(v, list) or isinstance(v, basestring)): config_error( "'env' values must be strings or lists ; key %s is incorrect: %s" % (k, type(v))) for p in y.get("projects", []): self.define_travis_builder(**p) self.defaultStages = y.get("stages", []) for s in self.defaultStages: if not isinstance(s, basestring): config_error( "'stages' values must be strings ; stage %s is incorrect: %s" % (s, type(s))) PORT = int(os.environ.get('PORT', 8020)) self.config['buildbotURL'] = os.environ.get( 'buildbotURL', "http://localhost:%d/" % (PORT, )) # minimalistic config to activate new web UI self.config['www'] = dict( port=PORT, change_hook_dialects=self.change_hook_dialects, plugins=dict(buildbot_travis={ 'cfg': self.cfgdict, 'supported_vcs': getSupportedVCSTypes() }), versions=[('buildbot_travis', getVersion(__file__))])
def fromDict(self, y): buildbot_travis.api.setCfg(y) self.cfgdict = y self.createWorkerConfig() self.importantManager = ImportantManager( y.setdefault("not_important_files", [])) self.defaultEnv = y.setdefault("env", {}) for k, v in self.defaultEnv.items(): if not (isinstance(v, list) or isinstance(v, string_types)): config_error( "'env' values must be strings or lists ; key %s is incorrect: %s" % (k, type(v))) for p in y.setdefault("projects", []): self.define_travis_builder(**p) self.defaultStages = y.setdefault("stages", []) for s in self.defaultStages: if not isinstance(s, string_types): config_error( "'stages' values must be strings ; stage %s is incorrect: %s" % (s, type(s))) PORT = int(os.environ.get('PORT', 8010)) self.config['buildbotURL'] = os.environ.get( 'buildbotURL', "http://localhost:%d/" % (PORT, )) db_url = os.environ.get('BUILDBOT_DB_URL') if db_url is not None: self.config.setdefault('db', {'db_url': db_url}) # minimalistic config to activate new web UI self.config['www'] = dict( port=PORT, change_hook_dialects=self.change_hook_dialects, plugins=dict(buildbot_travis={ 'supported_vcs': getSupportedVCSTypes(), 'cfg': self.getCleanConfig() }, console_view=True, waterfall_view=True), versions=[('buildbot_travis', getVersion(__file__))]) # automatically enable installed plugins apps = get_plugins('www', None, load_now=True) for plugin_name in set(apps.names): if plugin_name not in ( 'base', 'wsgi_dashboards' ) and plugin_name not in self.config['www']['plugins']: self.config['www']['plugins'][plugin_name] = True self.config['www']['versions'].append(apps.info(plugin_name)) self.config.setdefault('protocols', {'pb': {'port': 9989}}) self.createAuthConfig()
def execCustomCode(self, code, required_variables): l = {} # execute the code with empty global, and a given local context (that we return) try: exec code in {}, l except Exception: config_error("custom code generated an exception {}:".format(traceback.format_exc())) raise for n in required_variables: if n not in l: config_error("custom code does not generate variable {}: {} {}".format(n, code, l)) return l
def execCustomCode(self, code, required_variables): loc = {} # execute the code with empty glocobal, and a given local context (that we return) try: exec(code, {}, loc) except Exception: config_error("custom code generated an exception {}:".format(traceback.format_exc())) raise for n in required_variables: if n not in loc: config_error("custom code does not generate variable {}: {} {}".format(n, code, loc)) return loc
def createWorkerConfig(self): self.config.setdefault('workers', []) if 'workers' not in self.cfgdict: return for _worker in self.cfgdict['workers']: createWorkerConfigMethod = 'createWorkerConfig' + _worker['type'] if not hasattr(self, createWorkerConfigMethod): config_error("_worker type {} is not supported".format(_worker['type'])) continue for i in xrange(_worker.get('number', 1)): name = _worker['name'] if _worker.get('number', 1) != 1: name = name + "_" + str(i + 1) # count one based self.config['workers'].append(getattr(self, createWorkerConfigMethod)(_worker, name))
def createWorkerConfig(self): self.config.setdefault('workers', []) if 'workers' not in self.cfgdict: return for _worker in self.cfgdict['workers']: createWorkerConfigMethod = 'createWorkerConfig' + _worker['type'] if not hasattr(self, createWorkerConfigMethod): config_error("_worker type {} is not supported".format(_worker['type'])) continue for i in range(_worker.get('number', 1)): name = _worker['name'] if _worker.get('number', 1) != 1: name = name + "_" + str(i + 1) # count one based self.config['workers'].append(getattr(self, createWorkerConfigMethod)(_worker, name))
def fromDict(self, y): buildbot_travis.api.setCfg(y) self.cfgdict = y self.createWorkerConfig() self.importantManager = ImportantManager( y.setdefault("not_important_files", [])) self.defaultEnv = y.setdefault("env", {}) for k, v in self.defaultEnv.items(): if not (isinstance(v, list) or isinstance(v, string_types)): config_error( "'env' values must be strings or lists ; key %s is incorrect: %s" % (k, type(v))) for p in y.setdefault("projects", []): self.define_travis_builder(**p) self.defaultStages = y.setdefault("stages", []) for s in self.defaultStages: if not isinstance(s, string_types): config_error( "'stages' values must be strings ; stage %s is incorrect: %s" % (s, type(s))) PORT = int(os.environ.get('PORT', 8010)) self.config['buildbotURL'] = os.environ.get( 'buildbotURL', "http://localhost:%d/" % (PORT, )) db_url = os.environ.get('BUILDBOT_DB_URL') if db_url is not None: self.config.setdefault('db', {'db_url': db_url}) # minimalistic config to activate new web UI self.config['www'] = dict( port=PORT, change_hook_dialects=self.change_hook_dialects, plugins=dict( buildbot_travis={ 'supported_vcs': getSupportedVCSTypes(), 'cfg': self.getCleanConfig() }), versions=[('buildbot_travis', getVersion(__file__))]) self.config.setdefault('protocols', {'pb': {'port': 9989}}) self.createAuthConfig()