From 0e0521c61f190c88b235900a4667ed54883b8b1c Mon Sep 17 00:00:00 2001 From: skyline75489 Date: Fri, 17 Jul 2020 20:32:06 +0800 Subject: [PATCH] Handle None console type --- console/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/console/views.py b/console/views.py index e1df4f2..0c1c925 100644 --- a/console/views.py +++ b/console/views.py @@ -48,11 +48,14 @@ def console(request): if ':' in ws_host: ws_host = re.sub(':[0-9]+', '', ws_host) - console_page = "console-" + console_type + "-" + view_type + ".html" if console_type == 'vnc' or console_type == 'spice': + console_page = "console-" + console_type + "-" + view_type + ".html" response = render(request, console_page, locals()) else: - console_error = f"Console type: {console_type} no support" + if console_type is None: + console_error = f"Fail to get console. Please check the console configuration of your VM." + else: + console_error = f"Console type: {console_type} no support" response = render(request, 'console-vnc-lite.html', locals()) response.set_cookie('token', token)