diff --git a/jupyter-openbis-extension/connection.py b/jupyter-openbis-extension/connection.py index d25658183b6c462fb743d421480f7d3a945328fb..0e2039d1cf7476920d754904c12afc301378560c 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 +