def fetch(self, url, **kwargs): try: return requests.get(urljoin( self.host, url), timeout=self.config["response_timeout"], **kwargs) except requests.exceptions.ConnectionError: raise exceptions.SlaveDoesNotExist( "Unable to connect to the slave at {}".format(self.host))
def fetch(self, url, **kwargs): headers = {'User-Agent': get_user_agent()} try: return requests.get( urljoin(self.host, url), timeout=self.config["response_timeout"], headers=headers, **kwargs, ) except requests.exceptions.ConnectionError: raise exceptions.SlaveDoesNotExist( "Unable to connect to the slave at {}".format(self.host), )
def slave(self, fltr): lst = self.slaves(fltr) log.debug("master.slave({})".format(fltr)) if len(lst) == 0: raise exceptions.SlaveDoesNotExist( "Slave {} no longer exists.".format(fltr)) elif len(lst) > 1: raise exceptions.MultipleSlavesForIDError( "Multiple slaves matching filter %s. %s" % (fltr, ",".join([slave.id for slave in lst]))) return lst[0]