From 05670257fdc6a8356bde2864a4a2f9168bab7820 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Tue, 21 Apr 2020 11:08:57 -0700 Subject: [PATCH] web_server: Suppress warnings that static directories don't exist When JSXC is not installed, currently we get warnings that jsxc directories are not found when we start the web server. Suppress warning that some of the static directories don't exist. Since there is no way to add/remove those tree mounts at will, we need to add them all before hand even if they don't exist now. If the directories becomes available later, CherryPy serves them just fine. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- plinth/web_server.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plinth/web_server.py b/plinth/web_server.py index b85283776..d4db2ceef 100644 --- a/plinth/web_server.py +++ b/plinth/web_server.py @@ -5,6 +5,7 @@ Setup CherryPy web server. import logging import os +import warnings import cherrypy @@ -73,7 +74,16 @@ def init(): def run(on_web_server_stop): """Start the web server and block it until exit.""" - cherrypy.engine.start() + with warnings.catch_warnings(): + # Suppress warning that some of the static directories don't exist. + # Since there is no way to add/remove those tree mounts at will, we + # need to add them all before hand even if they don't exist now. If the + # directories becomes available later, CherryPy serves them just fine. + warnings.filterwarnings( + 'ignore', '(.|\n)*is not an existing filesystem path(.|\n)*', + UserWarning) + cherrypy.engine.start() + cherrypy.engine.subscribe('stop', on_web_server_stop) cherrypy.engine.block()