def _developer_mode_changes(self, rw_config): """ This function is called when you append the config called developer_config.py. This allows you to run a job outside of the Release Engineering infrastructure. What this functions accomplishes is: * read-buildbot-config is removed from the list of actions * --installer-url is set * --test-url is set if needed * every url is substituted by another external to the Release Engineering network """ c = self.config orig_config = copy.deepcopy(c) self.warning("When you use developer_config.py, we drop " \ "'read-buildbot-config' from the list of actions.") if "read-buildbot-config" in rw_config.actions: rw_config.actions.remove("read-buildbot-config") self.actions = tuple(rw_config.actions) def _replace_url(url, changes): for from_, to_ in changes: if url.startswith(from_): new_url = url.replace(from_, to_) self.info("Replacing url %s -> %s" % (url, new_url)) return new_url return url if c.get("installer_url") is None: self.exception( "You must use --installer-url with developer_config.py") if c.get("require_test_zip"): if not c.get('test_url') and not c.get('test_packages_url'): self.exception( "You must use --test-url or --test-packages-url with developer_config.py" ) c["installer_url"] = _replace_url(c["installer_url"], c["replace_urls"]) if c.get("test_url"): c["test_url"] = _replace_url(c["test_url"], c["replace_urls"]) if c.get("test_packages_url"): c["test_packages_url"] = _replace_url(c["test_packages_url"], c["replace_urls"]) for key, value in self.config.iteritems(): if type(value) == str and value.startswith("http"): self.config[key] = _replace_url(value, c["replace_urls"]) # Any changes to c means that we need credentials if not c == orig_config: get_credentials()
def _developer_mode_changes(self, rw_config): """ This function is called when you append the config called developer_config.py. This allows you to run a job outside of the Release Engineering infrastructure. What this functions accomplishes is: * read-buildbot-config is removed from the list of actions * --installer-url is set * --test-url is set if needed * every url is substituted by another external to the Release Engineering network """ c = self.config orig_config = copy.deepcopy(c) self.warning("When you use developer_config.py, we drop " "'read-buildbot-config' from the list of actions.") if "read-buildbot-config" in rw_config.actions: rw_config.actions.remove("read-buildbot-config") self.actions = tuple(rw_config.actions) def _replace_url(url, changes): for from_, to_ in changes: if url.startswith(from_): new_url = url.replace(from_, to_) self.info("Replacing url %s -> %s" % (url, new_url)) return new_url return url if c.get("installer_url") is None: self.exception("You must use --installer-url with developer_config.py") if c.get("require_test_zip"): if not c.get('test_url') and not c.get('test_packages_url'): self.exception("You must use --test-url or --test-packages-url with developer_config.py") c["installer_url"] = _replace_url(c["installer_url"], c["replace_urls"]) if c.get("test_url"): c["test_url"] = _replace_url(c["test_url"], c["replace_urls"]) if c.get("test_packages_url"): c["test_packages_url"] = _replace_url(c["test_packages_url"], c["replace_urls"]) for key, value in self.config.iteritems(): if type(value) == str and value.startswith("http"): self.config[key] = _replace_url(value, c["replace_urls"]) # Any changes to c means that we need credentials if not c == orig_config: get_credentials()
def _urlopen_basic_auth(url, **kwargs): self.info("We want to download this file %s" % url) if not hasattr(self, "https_username"): self.info("NOTICE: Files downloaded from outside of " "Release Engineering network require LDAP " "credentials.") self.https_username, self.https_password = get_credentials() # This creates a password manager passman = urllib2.HTTPPasswordMgrWithDefaultRealm() # Because we have put None at the start it will use this username/password combination from here on passman.add_password(None, url, self.https_username, self.https_password) authhandler = urllib2.HTTPBasicAuthHandler(passman) return urllib2.build_opener(authhandler).open(url, **kwargs)