In my app i need to select multiple files. So, i was starting to go with the gr.FileExplorer module. I am on a Windows machine. This worked well until my selection included a folder that i do not have the correct permissions for. In general the app continuous to work, but an error shows in the terminal and the module fails to work properly ( folders are not expandable anymore and change events are not firing anymore). Try to find some kind of workaround, but failed to do so.
The module itself does not give me the opportunity to handle this error in any way.
Have you searched existing issues? 🔎
[X] I have searched and found no existing issues
Reproduction
import gradio as gr
import os
def handle_files(files):
# This function will process the list of files
file_info = [d for d in files]
return file_info
with gr.Blocks() as demo:
gr.Markdown('## Select folder or files to read into index')
with gr.Row():
files = gr.FileExplorer(
glob="*",
# value=["themes/utils"],
root_dir="/Users/" + os.getlogin(),
interactive=True,
ignore_glob="**/__init__.py",
)
output=gr.Textbox(label="Selected files & folders:")
files.change(handle_files, files, output)
if __name__ == "__main__":
demo.launch()
Screenshot
No response
Logs
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\uvicorn\protocols\http\httptools_impl.py", line 411, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\uvicorn\middleware\proxy_headers.py", line 69, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\fastapi\applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\starlette\applications.py", line 123, in __call__
await self.middleware_stack(scope, receive, send)
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\starlette\middleware\errors.py", line 186, in __call__
raise exc
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\starlette\middleware\errors.py", line 164, in __call__
await self.app(scope, receive, _send)
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\gradio\route_utils.py", line 713, in __call__
await self.simple_response(scope, receive, send, request_headers=headers)
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\gradio\route_utils.py", line 729, in simple_response
await self.app(scope, receive, send)
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\starlette\middleware\exceptions.py", line 65, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app
raise exc
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\starlette\routing.py", line 756, in __call__
await self.middleware_stack(scope, receive, send)
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\starlette\routing.py", line 776, in app
await route.handle(scope, receive, send)
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\starlette\routing.py", line 297, in handle
await self.app(scope, receive, send)
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\starlette\routing.py", line 77, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app
raise exc
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
await app(scope, receive, sender)
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\starlette\routing.py", line 72, in app
response = await func(request)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\fastapi\routing.py", line 278, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\fastapi\routing.py", line 191, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\gradio\routes.py", line 1042, in component_server
return fn(body.data)
^^^^^^^^^^^^^
File "C:\Users\XXXXXX\AppData\Roaming\Python\Python312\site-packages\gradio\components\file_explorer.py", line 175, in ls
subdir_items = sorted(os.listdir(full_subdir_path))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [WinError 5] Access denied: 'c:\\Users\\XXXXXX\\Eigene Dateien'
Describe the bug
In my app i need to select multiple files. So, i was starting to go with the gr.FileExplorer module. I am on a Windows machine. This worked well until my selection included a folder that i do not have the correct permissions for. In general the app continuous to work, but an error shows in the terminal and the module fails to work properly ( folders are not expandable anymore and change events are not firing anymore). Try to find some kind of workaround, but failed to do so.
The module itself does not give me the opportunity to handle this error in any way.
Have you searched existing issues? 🔎
Reproduction
Screenshot
No response
Logs
System Info
Severity
Blocking usage of gradio