From d0c2aa81daee221ed2e0b29bb246568e3f45f64d Mon Sep 17 00:00:00 2001 From: jreadey Date: Tue, 16 Jan 2024 02:15:13 +0000 Subject: [PATCH] added server info method --- h5pyd/_hl/httpconn.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/h5pyd/_hl/httpconn.py b/h5pyd/_hl/httpconn.py index eda2050..8219547 100644 --- a/h5pyd/_hl/httpconn.py +++ b/h5pyd/_hl/httpconn.py @@ -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 = {} @@ -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