Commit 9b7aac9a authored by Łukasz Nowak's avatar Łukasz Nowak

Switch to urllib2.

parent 0a2ef6d5
......@@ -19,7 +19,7 @@ import httplib
import json
import os
import tempfile
import urllib
import urllib2
import urlparse
import M2Crypto
import socket
......@@ -150,9 +150,9 @@ class NetworkcacheClient(object):
'''
sha_cache_url = os.path.join(self.shacache_url, sha512sum)
file_descriptor = tempfile.NamedTemporaryFile()
path, headers = urllib.urlretrieve(sha_cache_url, file_descriptor.name)
file_descriptor.seek(0)
return file_descriptor
request = urllib2.Request(url=sha_cache_url, data=None,
headers=self.shadir_header_dict)
return urllib2.urlopen(request)
def select(self, urlmd5):
''' Download a file from shacache by selecting the entry in shadir
......@@ -160,9 +160,9 @@ class NetworkcacheClient(object):
'''
url = os.path.join(self.shadir_url, urlmd5)
file_descriptor = tempfile.NamedTemporaryFile()
path, headers = urllib.urlretrieve(url, file_descriptor.name)
file_descriptor.seek(0)
data = file_descriptor.read()
request = urllib2.Request(url=url, data=None,
headers=self.shadir_header_dict)
data = urllib2.urlopen(request).read()
# Filtering...
data_list = json.loads(data)
if len(data_list) > 1 and not \
......@@ -233,11 +233,7 @@ class NetworkcacheClient(object):
def _fetchCertificateFileFromUrl(self, certification_file_url):
""" Download the certification files from the url. """
file_descriptor = tempfile.NamedTemporaryFile()
path, headers = urllib.urlretrieve(certification_file_url, file_descriptor.name)
file_descriptor.seek(0)
return file_descriptor
return urllib2.urlopen(certification_file_url)
class DirectoryNotFound(Exception):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment