dolfinus commented on code in PR #158:
URL: https://github.com/apache/atlas/pull/158#discussion_r1217880632


##########
intg/src/main/python/apache_atlas/client/base_client.py:
##########
@@ -68,51 +68,36 @@ def call_api(self, api, response_type=None, 
query_params=None, request_obj=None)
         if request_obj is not None:
             params['data'] = json.dumps(request_obj)
 
-        if log.isEnabledFor(logging.DEBUG):
-            log.debug("------------------------------------------------------")
-            log.debug("Call         : %s %s", api.method, path)
-            log.debug("Content-type : %s", api.consumes)
-            log.debug("Accept       : %s", api.produces)
-
-        response = None
-
-        if api.method == HTTPMethod.GET:
-            response = self.session.get(path, **params)
-        elif api.method == HTTPMethod.POST:
-            response = self.session.post(path, **params)
-        elif api.method == HTTPMethod.PUT:
-            response = self.session.put(path, **params)
-        elif api.method == HTTPMethod.DELETE:
-            response = self.session.delete(path, **params)
-
-        if response is not None:
-            log.debug("HTTP Status: %s", response.status_code)
-
-        if response is None:
-            return None
-        elif response.status_code == api.expected_status:
+        log.debug("------------------------------------------------------")
+        log.debug("Call         : %s %s", api.method, path)
+        log.debug("Content-type : %s", api.consumes)
+        log.debug("Accept       : %s", api.produces)
+
+        method = HTTPMethod(api.method)
+        response = self.session.request(method.value, path, **params)
+        log.debug("HTTP Status: %s", response.status_code)
+
+        if response.status_code == api.expected_status:
             if response_type is None:
                 return None
+                
+            if response.content is None:
+                return None
 
+            log.debug("<== __call_api(%s,%s,%s), result = %s", vars(api), 
params, request_obj, response)
             try:
-                if response.content is not None:
-                    if log.isEnabledFor(logging.DEBUG):
-                        log.debug("<== __call_api(%s,%s,%s), result = %s", 
vars(api), params, request_obj, response)
+                log.debug(response.json())
 
-                        log.debug(response.json())
-                    if response_type == str:
-                        return json.dumps(response.json())
+                if response_type == str:
+                    return json.dumps(response.json())
 
-                    return type_coerce(response.json(), response_type)
-                else:
-                    return None
+                return type_coerce(response.json(), response_type)
             except Exception as e:
-                log.exception("Exception occurred while parsing response with 
msg: %s", e)
+                log.exception("Exception occurred while parsing response")

Review Comment:
   `log.exception` already prints exception stacktrace and message



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@atlas.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to