def __send_multipart(self, url, body, progress_callback=None): '''Sends a Multipart object to an URL. Returns the resulting unparsed XML from Flickr. ''' LOG.debug("Uploading to %s" % url) request = urllib2.Request(url) request.add_data(str(body)) (header, value) = body.header() request.add_header(header, value) if not progress_callback: # Just use urllib2 if there is no progress callback # function response = urllib2.urlopen(request) return response.read() def __upload_callback(percentage, done, seen_header=[False]): '''Filters out the progress report on the HTTP header''' # Call the user's progress callback when we've filtered # out the HTTP header if seen_header[0]: return progress_callback(percentage, done) # Remember the first time we hit 'done'. if done: seen_header[0] = True response = reportinghttp.urlopen(request, __upload_callback) return response.read()
def __send_multipart(self, url, body, progress_callback=None): '''Sends a Multipart object to an URL. Returns the resulting unparsed XML from Flickr. ''' logging.info("Uploading to %s" % url) request = urllib2.Request(url) request.add_data(str(body)) (header, value) = body.header() request.add_header(header, value) headerTuple = body.header() if not progress_callback: # Just use urlfetch with timeout of 120 seconds response = urlfetch.fetch(url, str(body), 'POST', {headerTuple[0]: headerTuple[1]}, False, False, 120) return response.content def __upload_callback(percentage, done, seen_header=[False]): '''Filters out the progress report on the HTTP header''' # Call the user's progress callback when we've filtered # out the HTTP header if seen_header[0]: return progress_callback(percentage, done) # Remember the first time we hit 'done'. if done: seen_header[0] = True response = reportinghttp.urlopen(request, __upload_callback) return response.read()
def __send_multipart(self, url, body, progress_callback=None): '''Sends a Multipart object to an URL. Returns the resulting XML from Flickr. ''' LOG.debug("Uploading to %s" % url) request = urllib2.Request(url) request.add_data(str(body)) (header, value) = body.header() request.add_header(header, value) if progress_callback: response = reportinghttp.urlopen(request, progress_callback) else: response = urllib2.urlopen(request) rspXML = response.read() return self.parse_xmlnode(rspXML)
def __send_multipart(self, url, body, progress_callback=None): u'''Sends a Multipart object to an URL. Returns the resulting XML from Flickr. ''' #$NON-NLS-1$ LOG.debug(u"Uploading to %s" % url) #$NON-NLS-1$ request = urllib2.Request(url) request.add_data(str(body)) (header, value) = body.header() request.add_header(header, value) if progress_callback: response = reportinghttp.urlopen(request, progress_callback) else: response = urllib2.urlopen(request) rspXML = response.read() return self.parse_xmlnode(rspXML)