(self, req)
Perform a http request andapply HTTP Basic authentication headers,
        if an username and password are supplied in settings.
Perform a http request andapply HTTP Basic authentication headers,
        if an username and password are supplied in settings.
Perform a http request andapply HTTP Basic authentication headers if an username and password are supplied in settings .
def _http_request(self, req):
        """
        Perform a http request andapply HTTP Basic authentication headers,
        if an username and password are supplied in settings.
        """
        if self._username and self._password:
            base64string = base64.encodestring('%s:%s' % (self._username, self._password))[:-1]
            req.add_header("Authorization", "Basic %s" % base64string)

        try:
            return urllib2.urlopen(req).read()
        except urllib2.URLError, e:
            clsname = self.__class__.__name__
            name = clsname.replace('MediaBackend', '')
            
            self.log.warning("Couldn't connect to %s at %s, are you sure it's running?", name, self.host_string())
            return None
def _http_request ( self , req ) : if self . _username and self . _password : base64string = base64 . encodestring ( '%s:%s' % ( self . _username , self . _password ) ) [ : - 1 ] req . add_header ( "Authorization" , "Basic %s" % base64string ) try : return urllib2 . urlopen ( req ) . read ( ) except urllib2 . URLError , e : clsname = self . __class__ . __name__ name = clsname . replace ( 'MediaBackend' , '' ) self . log . warning ( "Couldn't connect to %s at %s, are you sure it's running?" , name , self . host_string ( ) ) return None