]> git.ipfire.org Git - pbs.git/commitdiff
httpclient: Store a reference to the Backend object
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 15 May 2023 14:54:21 +0000 (14:54 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 15 May 2023 14:54:21 +0000 (14:54 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/httpclient.py

index d79beff485d623c676bb90e3b39c4f4c24beacf0..5d4c29f07026ad2833f2b8597d5363b76c2a4a5d 100644 (file)
@@ -27,9 +27,6 @@ import urllib.parse
 from . import base
 from .decorators import *
 
-# Import version
-from .__version__ import VERSION as __version__
-
 # Setup logging
 log = logging.getLogger("pbs.httpclient")
 
@@ -44,12 +41,18 @@ class HTTPClient(tornado.curl_httpclient.CurlAsyncHTTPClient):
                This is a wrapper over Tornado's HTTP client that performs some extra
                logging and makes it easier to compose a request.
        """
+       def __init__(self, backend, *args, **kwargs):
+               super().__init__(*args, **kwargs)
+
+               # Store a reference to the backend
+               self.backend = backend
+
        async def fetch(self, request):
                """
                        Sends a request
                """
                # Set User-Agent
-               request.user_agent = "PakfireBuildService/%s" % __version__
+               request.user_agent = "PakfireBuildService/%s" % self.backend.version
 
                # Log what we are sending
                log.debug("Sending %s request to %s:" % (request.method, request.url))