Commit af2f5c36 authored by Łukasz Nowak's avatar Łukasz Nowak

Avoid playing with url.

HTTPConnection accept port as none, there is no need to play with it.
parent df7a4fa7
......@@ -36,10 +36,6 @@ class NetworkcacheClient(object):
# ShaCache Properties
if shacache is not None:
shacache_urlparse = urlparse(shacache)
self.shacache_host = shacache_urlparse.hostname
if shacache_urlparse.port is not None:
self.shacache_host += ':%s' % shacache_urlparse.port
self.shacache_header_dict = {'Content-Type': 'application/json'}
shacache_user = shacache_urlparse.username
shacache_passwd = shacache_urlparse.password
......@@ -53,8 +49,7 @@ class NetworkcacheClient(object):
self.shacache_path = shacache_urlparse.path
self.shacache_host = shacache_urlparse.hostname
if shacache_urlparse.port is not None:
self.shacache_host += ':%s' % shacache_urlparse.port
self.shacache_port = shacache_urlparse.port
self.shacache_url = shacache
# ShaDir Properties
......@@ -73,8 +68,7 @@ class NetworkcacheClient(object):
self.shadir_path = shadir_urlparse.path
self.shadir_host = shadir_urlparse.hostname
if shadir_urlparse.port is not None:
self.shadir_host += ':%s' % shadir_urlparse.port
self.shadir_port = shadir_urlparse.port
def upload(self, file_descriptor, directory_key=None, **kw):
''' Upload the file to the server.
......@@ -89,7 +83,8 @@ class NetworkcacheClient(object):
sha512sum = hashlib.sha512(file_content).hexdigest()
path = os.path.join(self.shacache_path, sha512sum)
shacache_connection = httplib.HTTPConnection(self.shacache_host)
shacache_connection = httplib.HTTPConnection(self.shacache_host,
self.shacache_port)
try:
shacache_connection.request('POST', path, file_content,
self.shacache_header_dict)
......@@ -119,7 +114,8 @@ class NetworkcacheClient(object):
signature = ''
data = [kw, signature]
shadir_connection = httplib.HTTPConnection(self.shadir_host)
shadir_connection = httplib.HTTPConnection(self.shadir_host,
self.shadir_port)
try:
shadir_connection.request('POST', path, json.dumps(data),
self.shadir_header_dict)
......@@ -157,7 +153,8 @@ class NetworkcacheClient(object):
if directory_key is not None:
path_info = os.path.join(self.shadir_path, directory_key)
shadir_connection = httplib.HTTPConnection(self.shadir_host)
shadir_connection = httplib.HTTPConnection(self.shadir_host,
self.shadir_port)
try:
shadir_connection.request('GET', path_info, headers=self.shadir_header_dict)
result = shadir_connection.getresponse()
......
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