MCPcopy Create free account
hub / github.com/BaseXdb/basex / __init__

Method __init__

basex-api/src/main/python/BaseXClient/BaseXClient.py:101–135  ·  view source on GitHub ↗

Create and return session with host, port, user name and password

(self, host, port, user, password,
                 receive_bytes_encoding='utf-8',
                 send_bytes_encoding='utf-8')

Source from the content-addressed store, hash-verified

99 """
100
101 def __init__(self, host, port, user, password,
102 receive_bytes_encoding='utf-8',
103 send_bytes_encoding='utf-8'):
104 """Create and return session with host, port, user name and password"""
105
106 self.__info = None
107
108 # create server connection
109 self.__swrapper = SocketWrapper(
110 socket.socket(socket.AF_INET, socket.SOCK_STREAM),
111 receive_bytes_encoding=receive_bytes_encoding,
112 send_bytes_encoding=send_bytes_encoding)
113
114 self.__swrapper.connect((host, port))
115
116 # receive timestamp
117 response = self.recv_c_str().split(':')
118
119 # send username and hashed password/timestamp
120 hfun = hashlib.md5()
121
122 if len(response) > 1:
123 code = "%s:%s:%s" % (user, response[0], password)
124 nonce = response[1]
125 else:
126 code = password
127 nonce = response[0]
128
129 hfun.update(hashlib.md5(code.encode('us-ascii')).hexdigest().encode('us-ascii'))
130 hfun.update(nonce.encode('us-ascii'))
131 self.send(user + chr(0) + hfun.hexdigest())
132
133 # evaluate success flag
134 if not self.server_response_success():
135 raise IOError('Access Denied.')
136
137 def execute(self, com):
138 """Execute a command and return the result"""

Callers

nothing calls this directly

Calls 9

recv_c_strMethod · 0.95
sendMethod · 0.95
SocketWrapperClass · 0.85
connectMethod · 0.45
splitMethod · 0.45
md5Method · 0.45
updateMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected