def sendStreamplug(self, fileout, veohID, hrange): print time.asctime(), "Sending streamplug stream for URL: ", veohID url = veohID opener = HTTPRangeHandler(proxies=PROXIES) opener.addheaders = [('Range', 'bytes=' + str(hrange) + "-")] response = opener.open(veohID) buf = "INIT" print time.asctime(), "Sending data..." try: while (buf != None and len(buf) > 0): buf = response.read(8 * 1024) fileout.write(buf) fileout.flush() response.close() fileout.close() print time.asctime(), "Closing connection" except socket.error, e: print time.asctime(), "Client Closed the connection." try: response.close() fileout.close() except Exception, e: return
def openURL(self, url, headers, data=None): opener = HTTPRangeHandler(proxies=PROXIES) opener.addheaders = headers response = opener.open(url, data) return response