From 3bc78f61df3f3c3364fe0aa570f683bd232111d2 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 19 Dec 2016 11:11:51 +0100 Subject: [PATCH] Fix TypeError: __init__() got multiple values for argument 'handler' with recent aiohttp Fix #841 --- gns3server/web/request_handler.py | 28 ---------------------------- gns3server/web/web_server.py | 9 +++++++-- 2 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 gns3server/web/request_handler.py 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) diff --git a/gns3server/web/web_server.py b/gns3server/web/web_server.py index 1b27d832..e955cdd6 100644 --- a/gns3server/web/web_server.py +++ b/gns3server/web/web_server.py @@ -34,7 +34,6 @@ import time import atexit from .route import Route -from .request_handler import RequestHandler from ..config import Config from ..compute import MODULES from ..compute.port_manager import PortManager @@ -262,6 +261,11 @@ class WebServer: 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) @@ -314,7 +318,8 @@ class WebServer: m.port_manager = PortManager.instance() log.info("Starting server on {}:{}".format(self._host, self._port)) - self._handler = self._app.make_handler(handler=RequestHandler) + + self._handler = self._app.make_handler() if self._run_application(self._handler, ssl_context) is False: self._loop.stop() return