From d28336f7ec1d5440948e7b3a795c1212c96ee16a Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Fri, 11 Nov 2016 22:58:13 +0800 Subject: webui: websocket.py: Ignore "configfile"; Allow set "userconfig" * The "workdir" and "configfile" should be both ignored * Update "_set_configs()" method to allow set "userconfig" --- fg21sim/webui/websocket.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fg21sim/webui/websocket.py b/fg21sim/webui/websocket.py index d205004..53d2da4 100644 --- a/fg21sim/webui/websocket.py +++ b/fg21sim/webui/websocket.py @@ -328,7 +328,8 @@ class FG21simWSHandler(tornado.websocket.WebSocketHandler): NOTE ---- - The ``userconfig`` and ``workdir`` options are ignored. + The ``userconfig`` needs special handle. + The ``workdir`` and ``configfile`` options should be ignored. Parameters ---------- @@ -338,8 +339,7 @@ class FG21simWSHandler(tornado.websocket.WebSocketHandler): to which config options will be set. NOTE: If want to set the ``userconfig`` option, an *absolute path* - must be provided (i.e., client should take care of the ``workdir`` - value and generate a absolute path for ``userconfig``). + must be provided. Returns ------- @@ -349,9 +349,14 @@ class FG21simWSHandler(tornado.websocket.WebSocketHandler): """ errors = {} for key, value in data.items(): - if key in ["userconfig", "workdir"]: - # Ignore "userconfig" and "workdir" + if key in ["workdir", "configfile"]: + # Ignore "workdir" and "configfile" continue + elif key == "userconfig": + if os.path.isabs(value): + self.configs.userconfig = value + else: + errors[key] = "Not an absolute path" else: try: self.configs.setn(key, value) -- cgit v1.2.2