Commit 555902b4 authored by Julien Muchembled's avatar Julien Muchembled

os.path must not be used for url

parent b007f41a
......@@ -17,7 +17,6 @@ import base64
import hashlib
import httplib
import json
import os
import socket
import subprocess
import tempfile
......@@ -35,6 +34,12 @@ TIMEOUT = 60
UPLOAD_TIMEOUT = 60 * 60
def urljoin(a, b):
if not a.endswith('/'):
a += '/'
return a + b
class NetworkcacheClient(object):
'''
NetworkcacheClient is a wrapper for httplib.
......@@ -279,7 +284,7 @@ class NetworkcacheClient(object):
''' Download the file.
It uses http GET request method.
'''
sha_cache_url = os.path.join(self.shacache_url, sha512sum)
sha_cache_url = urljoin(self.shacache_url, sha512sum)
request = urllib2.Request(url=sha_cache_url, data=None,
headers=self.shadir_header_dict)
return urllib2.urlopen(request, timeout=TIMEOUT)
......@@ -288,7 +293,7 @@ class NetworkcacheClient(object):
''' Download a file from shacache by selecting the entry in shadir
Raise DirectoryNotFound if no trustable file is found.
'''
url = os.path.join(self.shadir_url, key)
url = urljoin(self.shadir_url, key)
request = urllib2.Request(url=url, data=None,
headers=self.shadir_header_dict)
data = urllib2.urlopen(request, timeout=TIMEOUT).read()
......@@ -327,7 +332,7 @@ class NetworkcacheClient(object):
def select_generic(self, key):
''' Select trustable entries from shadir.
'''
url = os.path.join(self.shadir_url, key)
url = urljoin(self.shadir_url, key)
request = urllib2.Request(url=url, data=None,
headers=self.shadir_header_dict)
data = urllib2.urlopen(request, timeout=TIMEOUT).read()
......
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