Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pyhs2/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ class Connection(object):
client = None
session = None

def __init__(self, host=None, port=10000, authMechanism=None, user=None, password=None, database=None, configuration=None, timeout=None):
def __init__(self, unix_socket=None, host=None, port=10000, authMechanism=None, user=None, password=None, database=None, configuration=None, timeout=None):
authMechanisms = set(['NOSASL', 'PLAIN', 'KERBEROS', 'LDAP'])
if authMechanism not in authMechanisms:
raise NotImplementedError('authMechanism is either not supported or not implemented')
#Must set a password for thrift, even if it doesn't need one
#Open issue with python-sasl
if authMechanism == 'PLAIN' and (password is None or len(password) == 0):
password = 'password'
socket = TSocket(host, port)
if unix_socket is not None:
socket = TSocket(unix_socket=unix_socket)
else:
socket = TSocket(host, port)
socket.setTimeout(timeout)
if authMechanism == 'NOSASL':
transport = TBufferedTransport(socket)
Expand Down Expand Up @@ -75,4 +78,4 @@ def cursor(self):

def close(self):
req = TCloseSessionReq(sessionHandle=self.session)
self.client.CloseSession(req)
self.client.CloseSession(req)