From b0ac98a7cd069ceffda15d018792bbff70acdaf7 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 26 Apr 2019 09:08:03 +0200 Subject: [PATCH] Clean up rest client --- scripts/rest_client.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/scripts/rest_client.py b/scripts/rest_client.py index 4e576d3cd..e01fc086e 100755 --- a/scripts/rest_client.py +++ b/scripts/rest_client.py @@ -40,8 +40,8 @@ INFO_COMMANDS = {"version": [], class FtRestClient(): def __init__(self, serverurl): - self.serverurl = serverurl + self.serverurl = serverurl self.session = requests.Session() def call(self, method, apipath, params: dict = None, data=None, files=None): @@ -62,19 +62,17 @@ class FtRestClient(): url = urlunparse((schema, netloc, path, params, query, fragment)) print(url) try: - - req = requests.Request(method, url, headers=hd, data=data, - # auth=self.session.auth - ) - reqp = req.prepare() - return self.session.send(reqp).json() - # return requests.get(url).json() + resp = self.session.request(method, url, headers=hd, data=data, + # auth=self.session.auth + ) + # return resp.text + return resp.json() except ConnectionError: logger.warning("Connection error") def call_command_noargs(self, command): logger.info(f"Running command `{command}` at {self.serverurl}") - r = self.call("GET", command) + r = self.call("POST", command) logger.info(r) def call_info(self, command, command_args):