diff --git a/jupyter-openbis-extension/connection.py b/jupyter-openbis-extension/connection.py index 0e2039d1cf7476920d754904c12afc301378560c..632334c991b311da75efb5c669c9e1c8438fd9f5 100644 --- a/jupyter-openbis-extension/connection.py +++ b/jupyter-openbis-extension/connection.py @@ -73,7 +73,9 @@ class OpenBISConnections(IPythonHandler): def _notebook_dir(self): notebook_dir = os.getcwd() - if 'notebook_dir' in self.config.NotebookApp: + if 'SingleUserNotebookApp' in self.config and 'notebook_dir' in self.config.SingleUserNotebookApp: + notebook_dir = self.config.SingleUserNotebookApp.notebook_dir + elif 'notebook_dir' in self.config.NotebookApp: notebook_dir = self.config.NotebookApp.notebook_dir return notebook_dir @@ -115,7 +117,9 @@ class OpenBISConnectionHandler(IPythonHandler): def _notebook_dir(self): notebook_dir = os.getcwd() - if 'notebook_dir' in self.config.NotebookApp: + if 'SingleUserNotebookApp' in self.config and 'notebook_dir' in self.config.SingleUserNotebookApp: + notebook_dir = self.config.SingleUserNotebookApp.notebook_dir + elif 'notebook_dir' in self.config.NotebookApp: notebook_dir = self.config.NotebookApp.notebook_dir return notebook_dir diff --git a/jupyter-openbis-extension/dataset.py b/jupyter-openbis-extension/dataset.py index 97bb0855eb2d4f088a9980be0002d8a774890e34..4e81dddb2b9cc5e9d03debac62400dee8670d2be 100644 --- a/jupyter-openbis-extension/dataset.py +++ b/jupyter-openbis-extension/dataset.py @@ -114,6 +114,14 @@ class DataSetTypesHandler(IPythonHandler): class DataSetUploadHandler(IPythonHandler): """Handle the POST requests for /openbis/dataset/connection_name""" + def _notebook_dir(self): + notebook_dir = os.getcwd() + if 'SingleUserNotebookApp' in self.config and 'notebook_dir' in self.config.SingleUserNotebookApp: + notebook_dir = self.config.SingleUserNotebookApp.notebook_dir + elif 'notebook_dir' in self.config.NotebookApp: + notebook_dir = self.config.NotebookApp.notebook_dir + return notebook_dir + def upload_data(self, conn, data): if not conn.is_session_active(): try: @@ -165,13 +173,15 @@ class DataSetUploadHandler(IPythonHandler): }) filenames = [] + notebook_dir = self._notebook_dir() for filename in data.get('files'): filename = unquote(filename) - if os.path.isfile(filename): - filenames.append(filename) + full_filename_path = os.path.join(notebook_dir, filename) + if os.path.isfile(full_filename_path): + filenames.append(full_filename_path) else: errors.append({ - "file": "File not found: {}".format(filename) + "file": "File not found: {}".format(full_filename_path) }) try: