mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
[PR #11573/f9e583da backport][stable-12] fix: remove HTTPStatus constructs introduced in Python 3.11 (#11575)
fix: remove HTTPStatus constructs introduced in Python 3.11 (#11573)
* fix: remove HTTPStatus constructs introduced in Python 3.11
* add changelog frag
(cherry picked from commit f9e583dae2)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
@@ -443,8 +443,7 @@ class RedfishUtils:
|
||||
"""
|
||||
msg = http_client.responses.get(error.code, "")
|
||||
data = None
|
||||
code = HTTPStatus(error.code)
|
||||
if code.is_client_error or code.is_server_error:
|
||||
if error.code >= HTTPStatus.BAD_REQUEST: # 4xx and 5xx errors
|
||||
try:
|
||||
body = error.read().decode("utf-8")
|
||||
data = json.loads(body)
|
||||
@@ -1893,17 +1892,15 @@ class RedfishUtils:
|
||||
else:
|
||||
# Error response body, which is a bit of a misnomer since it is used in successful action responses
|
||||
operation_results["status"] = "Completed"
|
||||
_status = HTTPStatus(response.status)
|
||||
if _status.is_client_error or _status.is_server_error:
|
||||
if response.status >= HTTPStatus.BAD_REQUEST: # 4xx and 5xx errors
|
||||
operation_results["status"] = "Exception"
|
||||
operation_results["messages"] = data.get("error", {}).get("@Message.ExtendedInfo", [])
|
||||
else:
|
||||
# No response body (or malformed); build based on status code
|
||||
operation_results["status"] = "Completed"
|
||||
_status = HTTPStatus(response.status)
|
||||
if _status == HTTPStatus.ACCEPTED:
|
||||
if response.status == HTTPStatus.ACCEPTED:
|
||||
operation_results["status"] = "New"
|
||||
elif _status.is_client_error or _status.is_server_error:
|
||||
elif response.status >= HTTPStatus.BAD_REQUEST: # 4xx and 5xx errors
|
||||
operation_results["status"] = "Exception"
|
||||
|
||||
# Clear out the handle if the operation is complete
|
||||
|
||||
Reference in New Issue
Block a user