Fix sonar issues 77/121377/5
authorMalarvizhi Paramasivam <malarvizhi.44@wipro.com>
Mon, 17 May 2021 06:10:15 +0000 (11:40 +0530)
committerMalarvizhi Paramasivam <malarvizhi.44@wipro.com>
Tue, 1 Jun 2021 11:21:32 +0000 (16:51 +0530)
Issue-ID: OPTFRA-946
Signed-off-by: Malarvizhi Paramasivam <malarvizhi.44@wipro.com>
Change-Id: I6ccf61b6e07187f879d52c4c3b9f53b4188adf4a
Signed-off-by: Malarvizhi Paramasivam <malarvizhi.44@wipro.com>
osdf/adapters/aaf/aaf_authentication.py
osdf/adapters/dcae/des.py
osdf/utils/interfaces.py
tox.ini

index 2a72c30..b9aa510 100644 (file)
 #
 
 import base64
-import re
-from datetime import datetime, timedelta
+from datetime import datetime
+from datetime import timedelta
 from flask import request
+import re
 
 from osdf.config.base import osdf_config
-from osdf.logging.osdf_logging import error_log, debug_log
+from osdf.logging.osdf_logging import debug_log
+from osdf.logging.osdf_logging import error_log
 from osdf.utils.interfaces import RestClient
 
 AUTHZ_PERMS_USER = '{}/authz/perms/user/{}'
@@ -101,8 +103,8 @@ def get_aaf_permissions(uid, passwd):
 
 
 def remote_api(passwd, uid):
-    headers = {"Accept": "application/Users+xml;q=1.0;charset=utf-8;version=2.0,text/xml;q=1.0;version=2.0",
-               "Accept": "application/Users+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0"}
+    headers = {"Accept": "application/Users+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,"
+                         "*/*;q=1.0"}
     url = AUTHZ_PERMS_USER.format(deploy_config['aaf_url'], uid)
     rc = RestClient(userid=uid, passwd=passwd, headers=headers, url=url, log_func=debug_log.debug,
                     req_id='aaf_user_id')
index 17517d7..57cb128 100644 (file)
@@ -17,7 +17,6 @@
 #
 
 import requests
-from requests.exceptions import HTTPError
 
 from osdf.config.base import osdf_config
 from osdf.utils.interfaces import RestClient
@@ -46,5 +45,3 @@ def extract_data(service_id, request_data):
         return response_json.get("result")
     except requests.RequestException as e:
         raise DESException("Request exception was encountered {}".format(e))
-    except HTTPError as ex:
-        raise DESException("Response code other than 200. Response code: {}".format(ex.response.status_code))
index 93264b2..a0a564e 100644 (file)
@@ -104,7 +104,7 @@ class RestClient(object):
 
         res_code = str(res.status_code)
         if not any(res_code.startswith(x) for x in map(str, ok_codes)):
-            raise res.raise_for_status()
+            raise BaseException(res.raise_for_status())
 
         if raw_response:
             return res
diff --git a/tox.ini b/tox.ini
index fb975e7..6dc85e0 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -30,10 +30,10 @@ whitelist_externals=bash
 commands = bash -c "pylint --reports=y osdf apps runtime| tee pylint.out"
 
 [testenv:py3]
-basepython=python3.6
+basepython=python3
 
 [testenv:flake8diff]
-basepython=python3.6
+basepython=python3
 whitelist_externals=bash
 deps = hacking>=2.0.0
 commands =