]> git.ipfire.org Git - ipfire.org.git/blobdiff - src/backend/zeiterfassung.py
Use Python's internal asyncio stuff instead of Tornado's
[ipfire.org.git] / src / backend / zeiterfassung.py
index aa0173e2b740d7cf2d75e14d1e7337e463b572ec..fef5e00b1fa85abd0bf00ab549a59f84dad30d0b 100644 (file)
@@ -4,7 +4,6 @@ import hashlib
 import hmac
 import json
 import tornado.httpclient
-import tornado.gen
 import urllib.parse
 
 from .misc import Object
@@ -23,13 +22,6 @@ class ZeiterfassungClient(Object):
                if not all((self.url, self.api_key, self.api_secret)):
                        raise RuntimeError("%s is not configured" % self.__class__.__name__)
 
-               # Create HTTPClient
-               self.http_client = tornado.httpclient.AsyncHTTPClient(
-                       defaults = {
-                               "User-Agent" : "IPFireWebApp",
-                       }
-               )
-
        def _make_signature(self, method, path, body):
                # Empty since we only support POST
                canonical_query = ""
@@ -44,8 +36,7 @@ class ZeiterfassungClient(Object):
 
                return h.hexdigest()
 
-       @tornado.gen.coroutine
-       def send_request(self, path, **kwargs):
+       async def send_request(self, path, **kwargs):
                url = urllib.parse.urljoin(self.url, path)
 
                # Query arguments are all keyword arguments
@@ -63,9 +54,7 @@ class ZeiterfassungClient(Object):
                )
 
                # Send the request
-               response = yield self.http_client.fetch(request)
+               response = await self.backend.http_client.fetch(request)
 
                # Decode the JSON response
-               d = json.loads(response.body.decode())
-
-               raise tornado.gen.Return(d)
+               return json.loads(response.body.decode())