Commit 578fc968 authored by Lucas Carvalho's avatar Lucas Carvalho

The parameter shacache can be None as well.

Because the user can just use the 'select' method to retrieve the information
from shadir server.
parent 144e6947
...@@ -29,30 +29,31 @@ class NetworkcacheClient(object): ...@@ -29,30 +29,31 @@ class NetworkcacheClient(object):
- SHACACHE - SHACACHE
''' '''
def __init__(self, shacache, shadir=None): def __init__(self, shacache=None, shadir=None):
''' Set the initial values. ''' ''' Set the initial values. '''
# ShaCache Properties # ShaCache Properties
shacache_urlparse = urlparse(shacache) if shacache is not None:
self.shacache_host = shacache_urlparse.hostname shacache_urlparse = urlparse(shacache)
if shacache_urlparse.port is not None: self.shacache_host = shacache_urlparse.hostname
self.shacache_host += ':%s' % shacache_urlparse.port 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 self.shacache_header_dict = {'Content-Type': 'application/json'}
shacache_passwd = shacache_urlparse.password shacache_user = shacache_urlparse.username
if shacache_user is not None: shacache_passwd = shacache_urlparse.password
authentication_string = '%s:%s' % (shacache_user, shacache_passwd) if shacache_user is not None:
base64string = base64.encodestring(authentication_string).strip() authentication_string = '%s:%s' % (shacache_user, shacache_passwd)
self.shacache_header_dict['Authorization'] = 'Basic %s' % base64string base64string = base64.encodestring(authentication_string).strip()
self.shacache_header_dict['Authorization'] = 'Basic %s' % base64string
self.shacache_path = '/'
if shacache_urlparse.path not in ('', '/'): self.shacache_path = '/'
self.shacache_path = shacache_urlparse.path if shacache_urlparse.path not in ('', '/'):
self.shacache_path = shacache_urlparse.path
shacache_urlparse = urlparse(shacache)
self.shacache_host = shacache_urlparse.hostname shacache_urlparse = urlparse(shacache)
if shacache_urlparse.port is not None: self.shacache_host = shacache_urlparse.hostname
self.shacache_host += ':%s' % shacache_urlparse.port if shacache_urlparse.port is not None:
self.shacache_host += ':%s' % shacache_urlparse.port
# ShaDir Properties # ShaDir Properties
if shadir is not None: if shadir is not None:
......
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