From 8eb018ebfe11bb931cc5157b33c2334f5126937f Mon Sep 17 00:00:00 2001 From: vermeul <swen@ethz.ch> Date: Mon, 15 Jul 2019 15:49:54 +0200 Subject: [PATCH] bugfix notebook_dir: do not assume it is defined in jupyter_notebook_config.py --- jupyter-openbis-extension/connection.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/jupyter-openbis-extension/connection.py b/jupyter-openbis-extension/connection.py index d256581..0e2039d 100644 --- a/jupyter-openbis-extension/connection.py +++ b/jupyter-openbis-extension/connection.py @@ -71,6 +71,12 @@ class OpenBISConnection: class OpenBISConnections(IPythonHandler): + def _notebook_dir(self): + notebook_dir = os.getcwd() + if 'notebook_dir' in self.config.NotebookApp: + notebook_dir = self.config.NotebookApp.notebook_dir + return notebook_dir + def post(self): """create a new connection @@ -98,7 +104,7 @@ class OpenBISConnections(IPythonHandler): self.write({ 'status' : 200, 'connections' : connections, - 'notebook_dir' : self.config.NotebookApp.notebook_dir + 'notebook_dir' : self._notebook_dir() }) return @@ -107,6 +113,12 @@ class OpenBISConnectionHandler(IPythonHandler): """Handle the requests to /openbis/conn """ + def _notebook_dir(self): + notebook_dir = os.getcwd() + if 'notebook_dir' in self.config.NotebookApp: + notebook_dir = self.config.NotebookApp.notebook_dir + return notebook_dir + def put(self, connection_name): """reconnect to a current connection :return: an updated connection object @@ -142,11 +154,10 @@ class OpenBISConnectionHandler(IPythonHandler): "reason": "General Network Error" }) - self.write({ 'status' : 200, 'connection' : conn.get_info(), - '' : self.config.NotebookApp.notebook_dir + '' : self._notebook_dir() }) def get(self, connection_name): @@ -167,7 +178,8 @@ class OpenBISConnectionHandler(IPythonHandler): self.write({ 'status' : 200, 'connection' : conn.get_info(), - 'noteboook_dir' : self.config.NotebookApp.notebook_dir + 'noteboook_dir' : self._notebook_dir() }) return + -- GitLab