Skip to content
Snippets Groups Projects
Commit be57f2b8 authored by Swen Vermeul's avatar Swen Vermeul
Browse files

added general/filelist endpoint which returns all (visible) files in current working directory

parent 2d7f9b2a
No related branches found
No related tags found
No related merge requests found
......@@ -69,6 +69,15 @@ def load_jupyter_server_extension(nb_server_app):
host_pattern = '.*$'
base_url = web_app.settings['base_url']
# get the file list
web_app.add_handlers(
host_pattern,
[(url_path_join( base_url, '/general/filelist'),
FileListHandler
)]
)
# DataSet download
web_app.add_handlers(
host_pattern,
......@@ -81,10 +90,7 @@ def load_jupyter_server_extension(nb_server_app):
# DataSet upload
web_app.add_handlers( host_pattern, [(
url_path_join(
base_url,
'/openbis/dataset/(?P<connection_name>.*)'
),
url_path_join( base_url, '/openbis/dataset/(?P<connection_name>.*)' ),
DataSetUploadHandler
)]
)
......@@ -93,9 +99,7 @@ def load_jupyter_server_extension(nb_server_app):
web_app.add_handlers(
host_pattern,
[(
url_path_join(
base_url,
'/openbis/datasetTypes/(?P<connection_name>.*)'
url_path_join( base_url, '/openbis/datasetTypes/(?P<connection_name>.*)'
),
DataSetTypesHandler
)]
......@@ -352,6 +356,37 @@ class SampleHandler(IPythonHandler):
})
class FileListHandler(IPythonHandler):
def get(self, **params):
"""
Returns the file list of the current working directory
:param params:
:return: dictionary of files, key is the fully qualified name,
value is the relative name (for display)
"""
cwd = os.getcwd()
files = {}
for (dirpath, dirnames, filenames) in os.walk(cwd):
if filenames:
for filename in filenames:
# ignore hidden files
if filename.startswith('.'):
continue
# ignore hidden folders
if os.path.relpath(dirpath) != '.' \
and os.path.relpath(dirpath).startswith('.'):
continue
fqn = os.path.join(dirpath, filename)
files[fqn] = os.path.relpath(fqn, cwd)
self.set_status(200)
self.write({
"files": files
})
class DataSetDownloadHandler(IPythonHandler):
"""Handle the requests for /openbis/dataset/connection/permId"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment