From 491c00403787fd4f4ea2e00831c851ef2a09e5e9 Mon Sep 17 00:00:00 2001 From: Rajeevalochana Kallur Date: Fri, 19 Apr 2024 11:07:39 +0530 Subject: [PATCH] version 5.0.0.0 --- src/redfish/__init__.py | 2 +- src/redfish/hpilo/risblobstore2.py | 6 ++---- src/redfish/rest/connections.py | 9 +++++++-- src/redfish/rest/containers.py | 3 +++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/redfish/__init__.py b/src/redfish/__init__.py index 7b7d4f9..c03bf37 100644 --- a/src/redfish/__init__.py +++ b/src/redfish/__init__.py @@ -1,7 +1,7 @@ """ Redfish restful library """ __all__ = ["rest", "ris", "hpilo"] -__version__ = "4.9.0.0" +__version__ = "5.0.0.0" import logging diff --git a/src/redfish/hpilo/risblobstore2.py b/src/redfish/hpilo/risblobstore2.py index cff9f3c..0ff5ff8 100644 --- a/src/redfish/hpilo/risblobstore2.py +++ b/src/redfish/hpilo/risblobstore2.py @@ -912,7 +912,7 @@ def initializecreds(username=None, password=None, log_dir=None): dll = BlobStore2.gethprestchifhandle() if LOGGER.isEnabledFor(logging.DEBUG): - logdir_c = create_string_buffer(log_dir.encode('UTF-8')) + logdir_c = create_string_buffer(log_dir.encode('utf-8')) dll.enabledebugoutput(logdir_c) dll.ChifInitialize(None) if username: @@ -925,16 +925,14 @@ def initializecreds(username=None, password=None, log_dir=None): usernew = create_string_buffer(username.encode("utf-8")) passnew = create_string_buffer(password.encode("utf-8")) - # LOGGER.debug("Calling initiate_credentials...") dll.initiate_credentials(usernew, passnew) - # LOGGER.debug("Calling ChifVerifyCredentials...") credreturn = dll.ChifVerifyCredentials() if not credreturn == BlobReturnCodes.SUCCESS: if credreturn == hpiloreturncodes.CHIFERR_AccessDenied: raise Blob2SecurityError() else: raise HpIloInitialError( - "Error %s occurred while trying " "to open a channel to iLO" % credreturn + "Error %s occurred while trying to open a channel to iLO" % credreturn ) else: dll.ChifDisableSecurity() diff --git a/src/redfish/rest/connections.py b/src/redfish/rest/connections.py index 7d50054..743d6f4 100644 --- a/src/redfish/rest/connections.py +++ b/src/redfish/rest/connections.py @@ -450,6 +450,9 @@ def rest_request(self, path="", method="GET", args=None, body=None, headers=None if isinstance(body, bytes): body = body.decode("utf-8") body = json.dumps(body) + elif isinstance(body, bytes): + headers["Content-Type"] = "application/octet-stream" + body = bytearray(body) else: headers["Content-Type"] = "application/x-www-form-urlencoded" body = urlencode(body) @@ -495,12 +498,14 @@ def rest_request(self, path="", method="GET", args=None, body=None, headers=None if body and len(body) > 0: if isinstance(body, bytearray): - str1 = bytearray(str1.encode("ASCII")) + body + str1 = bytearray(str1.encode("utf-8")) + body else: + #if isinstance(body, bytes): + # body = body.decode("utf-8") str1 += body if not isinstance(str1, bytearray): - str1 = bytearray(str1.encode("ASCII")) + str1 = bytearray(str1.encode("utf-8")) if LOGGER.isEnabledFor(logging.DEBUG): try: diff --git a/src/redfish/rest/containers.py b/src/redfish/rest/containers.py index cd2747c..5895306 100644 --- a/src/redfish/rest/containers.py +++ b/src/redfish/rest/containers.py @@ -313,8 +313,11 @@ def __init__(self, rest_request, resp_txt): resp_txt = "".join(map(chr, resp_txt)) self._respfh = StringIO(resp_txt) self._socket = _FakeSocket(bytearray(list(map(ord, self._respfh.read())))) + #self._respfh = BytesIO(resp_txt.encode('utf-8')) + #self._socket = _FakeSocket(bytearray(self._respfh.read())) response = http_client.HTTPResponse(self._socket) + #response = response.decode('utf-8') response.begin() response.data = response.read() response.headers = {ki[0]: ki[1] for ki in response.getheaders()}