mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 17:28:08 +00:00
Improvements for get symbol dimensions endpoint. Ref #1885
This commit is contained in:
parent
c9c6a5a762
commit
4e61cc811e
@ -22,7 +22,6 @@ import urllib.parse
|
|||||||
|
|
||||||
from gns3server.web.route import Route
|
from gns3server.web.route import Route
|
||||||
from gns3server.controller import Controller
|
from gns3server.controller import Controller
|
||||||
from gns3server.utils.picture import get_size
|
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -50,7 +49,7 @@ class SymbolHandler:
|
|||||||
status_codes={
|
status_codes={
|
||||||
200: "Symbol dimensions returned"
|
200: "Symbol dimensions returned"
|
||||||
})
|
})
|
||||||
async def raw(request, response):
|
async def get_dimensions(request, response):
|
||||||
|
|
||||||
controller = Controller.instance()
|
controller = Controller.instance()
|
||||||
symbol_id = urllib.parse.unquote(request.match_info["symbol_id"])
|
symbol_id = urllib.parse.unquote(request.match_info["symbol_id"])
|
||||||
@ -58,8 +57,8 @@ class SymbolHandler:
|
|||||||
width, height, _ = controller.symbols.get_size(symbol_id)
|
width, height, _ = controller.symbols.get_size(symbol_id)
|
||||||
symbol_dimensions = {'width': width, 'height': height}
|
symbol_dimensions = {'width': width, 'height': height}
|
||||||
response.json(symbol_dimensions)
|
response.json(symbol_dimensions)
|
||||||
except (KeyError, OSError) as e:
|
except (KeyError, OSError, ValueError) as e:
|
||||||
log.warning("Could not get symbol file: {}".format(e))
|
log.warning("Could not get symbol dimensions: {}".format(e))
|
||||||
response.set_status(404)
|
response.set_status(404)
|
||||||
|
|
||||||
@Route.get(
|
@Route.get(
|
||||||
|
Loading…
Reference in New Issue
Block a user