From 49f1ee2e32b4893817b698d6925ef6c2b05464bc Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 19 Dec 2016 10:10:47 +0100 Subject: [PATCH 1/2] Support aiohttp 1.2 (but not compatible with previous versions) Fix #840 --- gns3server/web/request_handler.py | 2 +- requirements.txt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gns3server/web/request_handler.py b/gns3server/web/request_handler.py index 17e0ab90..e5adf01e 100644 --- a/gns3server/web/request_handler.py +++ b/gns3server/web/request_handler.py @@ -19,7 +19,7 @@ import aiohttp.web import logging -class RequestHandler(aiohttp.web.RequestHandler): +class RequestHandler(aiohttp.web_server.RequestHandler): def log_access(self, message, environ, response, time): diff --git a/requirements.txt b/requirements.txt index 59e6145b..b58003eb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,7 @@ jsonschema>=2.4.0 -aiohttp>=0.21.5 +aiohttp>=1.2.0 +aiohttp_cors>=0.4.0 +yarl>=0.7.0 Jinja2>=2.7.3 raven>=5.2.0 psutil>=3.0.0 From c7d878ed9e3c39f1ecd6ea4cf7160921ed6478a2 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 19 Dec 2016 11:11:51 +0100 Subject: [PATCH 2/2] Fix TypeError: __init__() got multiple values for argument 'handler' with recent aiohttp Fix #841 --- gns3server/server.py | 8 ++++++-- gns3server/web/request_handler.py | 28 ---------------------------- 2 files changed, 6 insertions(+), 30 deletions(-) delete mode 100644 gns3server/web/request_handler.py diff --git a/gns3server/server.py b/gns3server/server.py index 34c7fa17..1bfeea64 100644 --- a/gns3server/server.py +++ b/gns3server/server.py @@ -30,7 +30,6 @@ import time import atexit from .web.route import Route -from .web.request_handler import RequestHandler from .config import Config from .modules import MODULES from .modules.port_manager import PortManager @@ -199,6 +198,11 @@ class Server: Starts the server. """ + server_logger = logging.getLogger('aiohttp.server') + # In debug mode we don't use the standard request log but a more complete in response.py + if log.getEffectiveLevel() == logging.DEBUG: + server_logger.setLevel(logging.CRITICAL) + logger = logging.getLogger("asyncio") logger.setLevel(logging.ERROR) @@ -239,7 +243,7 @@ class Server: m.port_manager = self._port_manager log.info("Starting server on {}:{}".format(self._host, self._port)) - self._handler = app.make_handler(handler=RequestHandler) + self._handler = app.make_handler() server = self._run_application(self._handler, ssl_context) self._loop.run_until_complete(server) self._signal_handling() diff --git a/gns3server/web/request_handler.py b/gns3server/web/request_handler.py deleted file mode 100644 index e5adf01e..00000000 --- a/gns3server/web/request_handler.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2015 GNS3 Technologies Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -import aiohttp.web -import logging - - -class RequestHandler(aiohttp.web_server.RequestHandler): - - def log_access(self, message, environ, response, time): - - # In debug mode we don't use the standard request log but a more complete in response.py - if self.logger.getEffectiveLevel() != logging.DEBUG: - super().log_access(message, environ, response, time)