From 47433369470988967bdd5facf29a0d5176744d4b Mon Sep 17 00:00:00 2001 From: BizstatsAI <61969752+bizstatsai@users.noreply.github.com> Date: Wed, 11 Mar 2020 13:19:01 +0530 Subject: [PATCH] Fix python 3 HTTP Status errors caused by RestClientUtils In cdap-authentication-clients/python/cdap_auth_client/rest_client_utils.py python2 uses httplib >>> import httplib as hl >>> hl.OK 200 >>> type(hl.OK) python3 uses http.client >>> import http.client as hl >>> hl.OK >>> type(hl.OK) >>> hl.OK.value 200 >>> type(hl.OK.value) To fix this we changed rest_client_utils.py#34 from def verify_response_code(response_code): if response_code is hl.OK: LOG.debug("Success operation result code.") return else: RestClientUtils.check_status(response_code) to def verify_response_code(response_code): if (hl.__name__ is 'httplib' and response_code is hl.OK) or (hl.__name__ is 'http.client' and response_code is hl.OK.value): LOG.debug("Success operation result code.") return else: RestClientUtils.check_status(response_code) --- .../python/cdap_auth_client/rest_client_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdap-authentication-clients/python/cdap_auth_client/rest_client_utils.py b/cdap-authentication-clients/python/cdap_auth_client/rest_client_utils.py index 3e2eb27..362033a 100644 --- a/cdap-authentication-clients/python/cdap_auth_client/rest_client_utils.py +++ b/cdap-authentication-clients/python/cdap_auth_client/rest_client_utils.py @@ -31,7 +31,7 @@ class RestClientUtils: @staticmethod def verify_response_code(response_code): - if response_code is hl.OK: + if (hl.__name__ is 'httplib' and response_code is hl.OK) or (hl.__name__ is 'http.client' and response_code is hl.OK.value): LOG.debug("Success operation result code.") return else: