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

Switch to urllib2.

parent 0a2ef6d5
...@@ -19,7 +19,7 @@ import httplib ...@@ -19,7 +19,7 @@ import httplib
import json import json
import os import os
import tempfile import tempfile
import urllib import urllib2
import urlparse import urlparse
import M2Crypto import M2Crypto
import socket import socket
...@@ -150,9 +150,9 @@ class NetworkcacheClient(object): ...@@ -150,9 +150,9 @@ class NetworkcacheClient(object):
''' '''
sha_cache_url = os.path.join(self.shacache_url, sha512sum) sha_cache_url = os.path.join(self.shacache_url, sha512sum)
file_descriptor = tempfile.NamedTemporaryFile() file_descriptor = tempfile.NamedTemporaryFile()
path, headers = urllib.urlretrieve(sha_cache_url, file_descriptor.name) request = urllib2.Request(url=sha_cache_url, data=None,
file_descriptor.seek(0) headers=self.shadir_header_dict)
return file_descriptor return urllib2.urlopen(request)
def select(self, urlmd5): def select(self, urlmd5):
''' Download a file from shacache by selecting the entry in shadir ''' Download a file from shacache by selecting the entry in shadir
...@@ -160,9 +160,9 @@ class NetworkcacheClient(object): ...@@ -160,9 +160,9 @@ class NetworkcacheClient(object):
''' '''
url = os.path.join(self.shadir_url, urlmd5) url = os.path.join(self.shadir_url, urlmd5)
file_descriptor = tempfile.NamedTemporaryFile() file_descriptor = tempfile.NamedTemporaryFile()
path, headers = urllib.urlretrieve(url, file_descriptor.name) request = urllib2.Request(url=url, data=None,
file_descriptor.seek(0) headers=self.shadir_header_dict)
data = file_descriptor.read() data = urllib2.urlopen(request).read()
# Filtering... # Filtering...
data_list = json.loads(data) data_list = json.loads(data)
if len(data_list) > 1 and not \ if len(data_list) > 1 and not \
...@@ -233,11 +233,7 @@ class NetworkcacheClient(object): ...@@ -233,11 +233,7 @@ class NetworkcacheClient(object):
def _fetchCertificateFileFromUrl(self, certification_file_url): def _fetchCertificateFileFromUrl(self, certification_file_url):
""" Download the certification files from the url. """ """ Download the certification files from the url. """
file_descriptor = tempfile.NamedTemporaryFile() return urllib2.urlopen(certification_file_url)
path, headers = urllib.urlretrieve(certification_file_url, file_descriptor.name)
file_descriptor.seek(0)
return file_descriptor
class DirectoryNotFound(Exception): 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