feat: Enhance installation script and documentation for Python tkinter support
This commit updates the `install.sh` script to include the installation of Python tkinter, which is required for the native folder picker functionality. Additionally, the README.md is modified to reflect this new requirement, providing installation instructions for various operating systems. The documentation is further enhanced with troubleshooting tips for users encountering issues with the folder picker, ensuring a smoother setup experience.
This commit is contained in:
+47
-4
@@ -466,12 +466,55 @@ def browse_folder() -> dict:
|
||||
root.destroy()
|
||||
|
||||
if folder_path:
|
||||
# Normalize path to absolute
|
||||
abs_path = os.path.abspath(folder_path)
|
||||
# Normalize path to absolute - use multiple methods to ensure full path
|
||||
# Handle network paths (UNC paths on Windows, mounted shares on Linux)
|
||||
|
||||
# Check if it's a Windows UNC path (\\server\share or //server/share)
|
||||
# UNC paths are already absolute, but realpath may not work correctly with them
|
||||
is_unc_path = folder_path.startswith('\\\\') or folder_path.startswith('//')
|
||||
|
||||
if is_unc_path:
|
||||
# For UNC paths, normalize separators but don't use realpath
|
||||
# (realpath may not work correctly with UNC paths on Windows)
|
||||
# os.path.normpath() handles UNC paths correctly on Windows
|
||||
normalized_path = os.path.normpath(folder_path)
|
||||
else:
|
||||
# For regular paths (local or mounted network shares on Linux)
|
||||
# First convert to absolute, then resolve any symlinks, then normalize
|
||||
abs_path = os.path.abspath(folder_path)
|
||||
try:
|
||||
# Resolve any symlinks to get the real path
|
||||
# This may fail for some network paths, so wrap in try/except
|
||||
real_path = os.path.realpath(abs_path)
|
||||
except (OSError, ValueError):
|
||||
# If realpath fails (e.g., for some network paths), use abspath result
|
||||
real_path = abs_path
|
||||
# Normalize the path (remove redundant separators, etc.)
|
||||
normalized_path = os.path.normpath(real_path)
|
||||
|
||||
# Ensure we have a full absolute path (not just folder name)
|
||||
if not os.path.isabs(normalized_path):
|
||||
# If somehow still not absolute, try again with current working directory
|
||||
normalized_path = os.path.abspath(normalized_path)
|
||||
|
||||
# Verify the path exists and is a directory
|
||||
# Note: For network paths, this check might fail if network is temporarily down,
|
||||
# but if the user just selected it via the folder picker, it should be accessible
|
||||
if not os.path.exists(normalized_path):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Selected path does not exist: {normalized_path}",
|
||||
)
|
||||
if not os.path.isdir(normalized_path):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail=f"Selected path is not a directory: {normalized_path}",
|
||||
)
|
||||
|
||||
return {
|
||||
"path": abs_path,
|
||||
"path": normalized_path,
|
||||
"success": True,
|
||||
"message": f"Selected folder: {abs_path}"
|
||||
"message": f"Selected folder: {normalized_path}"
|
||||
}
|
||||
else:
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user