From 4e61cc811e3847331f112a572689aaba2f703c01 Mon Sep 17 00:00:00 2001 From: grossmj Date: Sat, 10 Apr 2021 12:28:50 +0930 Subject: [PATCH] Improvements for get symbol dimensions endpoint. Ref #1885 --- gns3server/handlers/api/controller/symbol_handler.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gns3server/handlers/api/controller/symbol_handler.py b/gns3server/handlers/api/controller/symbol_handler.py index cb7139f7..f0c2d9eb 100644 --- a/gns3server/handlers/api/controller/symbol_handler.py +++ b/gns3server/handlers/api/controller/symbol_handler.py @@ -22,7 +22,6 @@ import urllib.parse from gns3server.web.route import Route from gns3server.controller import Controller -from gns3server.utils.picture import get_size import logging log = logging.getLogger(__name__) @@ -50,16 +49,16 @@ class SymbolHandler: status_codes={ 200: "Symbol dimensions returned" }) - async def raw(request, response): + async def get_dimensions(request, response): controller = Controller.instance() symbol_id = urllib.parse.unquote(request.match_info["symbol_id"]) try: width, height, _ = controller.symbols.get_size(symbol_id) - symbol_dimensions = { 'width': width, 'height': height } + symbol_dimensions = {'width': width, 'height': height} response.json(symbol_dimensions) - except (KeyError, OSError) as e: - log.warning("Could not get symbol file: {}".format(e)) + except (KeyError, OSError, ValueError) as e: + log.warning("Could not get symbol dimensions: {}".format(e)) response.set_status(404) @Route.get(