From b4794554286192695514f810b3e5d9fcb07ce7ac Mon Sep 17 00:00:00 2001 From: NichtJens Date: Tue, 1 Jun 2021 09:34:39 +0200 Subject: [PATCH] some more cleanup --- scilog/httpclient.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scilog/httpclient.py b/scilog/httpclient.py index 9d433e7..6457e8d 100644 --- a/scilog/httpclient.py +++ b/scilog/httpclient.py @@ -7,15 +7,15 @@ from .authmixin import AuthMixin, AuthError, HEADER_JSON def authenticated(func): @functools.wraps(func) - def authenticated_call(*args, **kwargs): - if not issubclass(type(args[0]), HttpClient): + def authenticated_call(client, *args, **kwargs): + if not isinstance(client, HttpClient): raise AttributeError("First argument must be an instance of HttpClient") if "headers" in kwargs: kwargs["headers"] = kwargs["headers"].copy() else: kwargs["headers"] = {} - kwargs["headers"]["Authorization"] = args[0].token - return func(*args, **kwargs) + kwargs["headers"]["Authorization"] = client.token + return func(client, *args, **kwargs) return authenticated_call @@ -51,8 +51,7 @@ class HttpClient(AuthMixin): @authenticated def post_request(self, url, payload=None, headers=None, timeout=10): - response = requests.post(url, json=payload, headers=headers, timeout=timeout, verify=self._verify_certificate).json() - return response + return requests.post(url, json=payload, headers=headers, timeout=timeout, verify=self._verify_certificate).json() def _login(self, payload=None, headers=None, timeout=10): return requests.post(self.address + "/users/login", json=payload, headers=headers, timeout=timeout, verify=self._verify_certificate).json()