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):
- SHACACHE
'''
def __init__(self, shacache, shadir=None):
def __init__(self, shacache=None, shadir=None):
''' Set the initial values. '''
# ShaCache Properties
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
if shacache_user is not None:
authentication_string = '%s:%s' % (shacache_user, shacache_passwd)
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 = shacache_urlparse.path
shacache_urlparse = urlparse(shacache)
self.shacache_host = shacache_urlparse.hostname
if shacache_urlparse.port is not None:
self.shacache_host += ':%s' % shacache_urlparse.port
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
if shacache_user is not None:
authentication_string = '%s:%s' % (shacache_user, shacache_passwd)
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 = shacache_urlparse.path
shacache_urlparse = urlparse(shacache)
self.shacache_host = shacache_urlparse.hostname
if shacache_urlparse.port is not None:
self.shacache_host += ':%s' % shacache_urlparse.port
# ShaDir Properties
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