Skip to content

Commit

Permalink
added server info method
Browse files Browse the repository at this point in the history
  • Loading branch information
jreadey committed Jan 16, 2024
1 parent bfa6d84 commit d0c2aa8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions h5pyd/_hl/httpconn.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def __init__(
self._lambda = None
self._api_key = api_key
self._s = None # Sessions
self._server_info = None
if use_cache:
self._cache = {}
self._objdb = {}
Expand Down Expand Up @@ -372,6 +373,32 @@ def getHeaders(self, username=None, password=None, headers=None):

return headers

def serverInfo(self):
if self._server_info:
return self._server_info

if self._endpoint is None:
raise IOError("object not initialized")

# make an about request
rsp = self.GET("/about")
if rsp.status_code != 200:
raise IOError(rsp.status_code, rsp.reason)
server_info = rsp.json()
print("server_info:", server_info)
if server_info:
self._server_info = server_info
return server_info

def server_version(self):
server_info = self.serverInfo()
if "hsds_version" in server_info:
server_version = server_info["hsds_version"]
else:
# no standard way to get version for other implements...
server_version = None
return server_version

def verifyCert(self):
# default to validate CERT for https requests, unless
# the H5PYD_VERIFY_CERT environment variable is set and True
Expand Down

0 comments on commit d0c2aa8

Please sign in to comment.