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

Follow the shadir spec.

Key is given by the library user. It has no internal meaning.
parent 08df4c6e
...@@ -80,7 +80,7 @@ class NetworkcacheClient(object): ...@@ -80,7 +80,7 @@ class NetworkcacheClient(object):
self.signature_certificate_url_list.append(value) self.signature_certificate_url_list.append(value)
def upload(self, file_descriptor, urlmd5=None, file_name=None, def upload(self, file_descriptor, urlmd5=None, file_name=None,
valid_until=None, architecture=None): valid_until=None, architecture=None, key=None):
''' Upload the file to the server. ''' Upload the file to the server.
If urlmd5 is None it must only upload to SHACACHE. If urlmd5 is None it must only upload to SHACACHE.
Otherwise, it must create a new entry on SHADIR. Otherwise, it must create a new entry on SHADIR.
...@@ -111,9 +111,9 @@ class NetworkcacheClient(object): ...@@ -111,9 +111,9 @@ class NetworkcacheClient(object):
'URL: %s. Response code: %s. Response data: %s' % \ 'URL: %s. Response code: %s. Response data: %s' % \
(self.shacache_host, result.status, data)) (self.shacache_host, result.status, data))
if urlmd5 is not None: if key is not None:
if file_name is None: if file_name is None:
raise ValueError('In case if urlmd5 is given file_name is required.') raise ValueError('In case if key is given file_name is required.')
kw = dict() kw = dict()
kw['file'] = file_name kw['file'] = file_name
kw['urlmd5'] = urlmd5 kw['urlmd5'] = urlmd5
...@@ -130,8 +130,8 @@ class NetworkcacheClient(object): ...@@ -130,8 +130,8 @@ class NetworkcacheClient(object):
shadir_connection = httplib.HTTPConnection(self.shadir_host, shadir_connection = httplib.HTTPConnection(self.shadir_host,
self.shadir_port) self.shadir_port)
try: try:
shadir_connection.request('POST', self.shadir_path, json.dumps(data), shadir_connection.request('PUT', '/'.join([self.shadir_path, key]),
self.shadir_header_dict) json.dumps(data), self.shadir_header_dict)
result = shadir_connection.getresponse() result = shadir_connection.getresponse()
data = result.read() data = result.read()
finally: finally:
......
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