From 852ebddf3b5c23138c0652bd1c91273e248f61f3 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sun, 12 Apr 2026 20:49:20 +0800 Subject: [PATCH] Fix callback issues in v2.2.58 --- gns3/compute_manager.py | 2 +- gns3/controller.py | 2 +- gns3/http_client.py | 9 +++++---- gns3/template_manager.py | 2 +- tests/test_http_client.py | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gns3/compute_manager.py b/gns3/compute_manager.py index 23d2d8c7..068ecdc4 100644 --- a/gns3/compute_manager.py +++ b/gns3/compute_manager.py @@ -217,7 +217,7 @@ class ComputeManager(QtCore.QObject): if compute_id in self._computes: del self._computes[compute_id] - self._controller.delete("/computes/{compute_id}".format(compute_id=compute_id)) + self._controller.delete("/computes/{compute_id}".format(compute_id=compute_id), None) self.deleted_signal.emit(compute_id) def updateList(self, computes): diff --git a/gns3/controller.py b/gns3/controller.py index 4721accf..7a2ace45 100644 --- a/gns3/controller.py +++ b/gns3/controller.py @@ -247,7 +247,7 @@ class Controller(QtCore.QObject): def createHTTPQuery(self, method, path, *args, **kwargs): """ - Forward the query to the HTTP client or controller depending of the path + Forward the query to the HTTP client or controller depending on the path """ if self._http_client: diff --git a/gns3/http_client.py b/gns3/http_client.py index 2ae09e26..7c67bb81 100644 --- a/gns3/http_client.py +++ b/gns3/http_client.py @@ -580,7 +580,7 @@ class HTTPClient(QtCore.QObject): :param body: params to send (dictionary) :param callback: callback method to call when the server replies :param context: Pass a context to the response callback - :param downloadProgressCallback: Callback called when received something, it can be an incomplete response + :param downloadProgressCallback: callback called when received something, it can be an incomplete response :param showProgress: Display progress to the user :param networkManager: The network manager to use. If None use default :param progressText: Text display to user in progress dialog. None for auto generated @@ -606,7 +606,7 @@ class HTTPClient(QtCore.QObject): request = self._addAuth(request) request.setRawHeader(b"User-Agent", "GNS3 QT Client v{version}".format(version=__version__).encode()) - # By default QT doesn't support GET with body even if it's in the RFC that's why we need to use sendCustomRequest + # By default, QT doesn't support GET with body even if it's in the RFC that's why we need to use sendCustomRequest body = self._addBodyToRequest(body, request) if not networkManager: @@ -616,12 +616,13 @@ class HTTPClient(QtCore.QObject): response = networkManager.sendCustomRequest(request, method.encode(), body) except SystemError as e: log.error("Can't send query: {}".format(str(e))) - return + return None if context: context = copy.copy(context) else: - context = {"query_id": str(uuid.uuid4())} + context = dict() + context["query_id"] = str(uuid.uuid4()) response.finished.connect(qpartial(self._processResponse, response, server, callback, context, body, ignoreErrors)) response.errorOccurred.connect(qpartial(self._processError, response, server, callback, context, body, ignoreErrors)) diff --git a/gns3/template_manager.py b/gns3/template_manager.py index ff25d750..4c0e7389 100644 --- a/gns3/template_manager.py +++ b/gns3/template_manager.py @@ -81,7 +81,7 @@ class TemplateManager(QtCore.QObject): if template_id in self._templates and not self._templates[template_id].builtin(): template = self._templates[template_id] log.debug("Delete template '{}' (ID={})".format(template.name(), template_id)) - self._controller.delete("/templates/{template_id}".format(template_id=template_id)) + self._controller.delete("/templates/{template_id}".format(template_id=template_id), None) def deleteTemplateCallback(self, result, error=False, **kwargs): """ diff --git a/tests/test_http_client.py b/tests/test_http_client.py index 6a45687d..980a2200 100644 --- a/tests/test_http_client.py +++ b/tests/test_http_client.py @@ -136,7 +136,7 @@ def test_post_not_connected(http_client, http_request, network_manager, response assert callback.called args, kwargs = callback.call_args - assert kwargs["context"]["query_id"] == 42 + assert kwargs["context"]["toto"] == 42 def test_post_not_connected_connection_failed(http_client, http_request, network_manager, response):