On Friday August 14th. from 9 p.m. to 9:30 p.m., we will upgrade GitLab software and its cloud platform release. Service may not be available during this maintenance window. Please schedule your work accordingly.

Commit 02851e35 authored by Marcello Golfieri's avatar Marcello Golfieri

refactored output return code

parent af783313
......@@ -111,27 +111,28 @@ class Qapi:
else:
return ""
def _request_output(self, response, raw_output):
if response.status_code !=200:
raise Exception('Error, response was {}'.format(response.__dict__))
if raw_output:
return response.text
else:
return objectify.fromstring(response.text.encode("utf-8"))
def _post_xml(self, uri, params, headers=None, raw_output=False):
url = self.url + uri
headers = self.headers if not headers else headers
response = requests.post(url, data=params, headers=headers, auth=self.auth)
logging.info("POST: {}, params: {}, response: {}".format(url, params, response))
oxml = objectify.fromstring(response.text.encode("utf-8"))
if raw_output:
return response.text
else:
return oxml
return self._request_output(response, raw_output)
def _get_xml(self, uri, params, headers=None, raw_output=False):
url = self.url + uri + "/" + self._make_get_params(params)
headers = self.headers if not headers else headers
response = requests.get(url, headers=self.headers, auth=self.auth)
logging.info("GET: {}".format(url))
if raw_output:
return response.text
else:
oxml = objectify.fromstring(response.text.encode("utf-8"))
return oxml
return self._request_output(response, raw_output)
def get_rest_api_version(self):
return self._get_xml(
......@@ -328,11 +329,6 @@ class Qapi:
params = {"action": "list", "ids": qid, "details": "Basic", "echo_request": 1}
oxml = self._get_xml("/api/2.0/fo/knowledge_base/vuln", params)
return oxml
# try:
# qid_out = oxml.RESPONSE.VULN_LIST.getchildren()
# except AttributeError:
# return None
# return qid_out
def get_qid_summary_list(self, host):
vulns = self.get_host_vulnerabilities(host)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment