Loading lib/galaxy/files/sources/_pyfilesystem2.py +24 −13 Original line number Diff line number Diff line Loading @@ -12,9 +12,14 @@ from typing import ( ) import fs import fs.errors from fs.base import FS from typing_extensions import Unpack from galaxy.exceptions import ( AuthenticationRequired, MessageException, ) from . import ( BaseFilesSource, FilesSourceOptions, Loading Loading @@ -42,7 +47,7 @@ class PyFilesystem2FilesSource(BaseFilesSource): def _list(self, path="/", recursive=False, user_context=None, opts: Optional[FilesSourceOptions] = None): """Return dictionary of 'Directory's and 'File's.""" try: with self._open_fs(user_context=user_context, opts=opts) as h: if recursive: res: List[Dict[str, Any]] = [] Loading @@ -55,6 +60,12 @@ class PyFilesystem2FilesSource(BaseFilesSource): res = h.scandir(path, namespaces=["details"]) to_dict = functools.partial(self._resource_info_to_dict, path) return list(map(to_dict, res)) except fs.errors.PermissionDenied as e: raise AuthenticationRequired( f"Permission Denied. Reason: {e}. Please check your credentials in your preferences for {self.label}." ) except fs.errors.FSError as e: raise MessageException(f"Problem listing file source path {path}. Reason: {e}") from e def _realize_to(self, source_path, native_path, user_context=None, opts: Optional[FilesSourceOptions] = None): with open(native_path, "wb") as write_file: Loading lib/galaxy/files/sources/dropbox.py +15 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,10 @@ from typing import ( Union, ) from galaxy.exceptions import ( AuthenticationRequired, MessageException, ) from . import ( FilesSourceOptions, FilesSourceProperties, Loading @@ -27,8 +31,17 @@ class DropboxFilesSource(PyFilesystem2FilesSource): if "accessToken" in props: props["access_token"] = props.pop("accessToken") try: handle = DropboxFS(**{**props, **extra_props}) return handle except Exception as e: # This plugin might raise dropbox.dropbox_client.BadInputException # which is not a subclass of fs.errors.FSError if "OAuth2" in str(e): raise AuthenticationRequired( f"Permission Denied. Reason: {e}. Please check your credentials in your preferences for {self.label}." ) raise MessageException(f"Error connecting to Dropbox. Reason: {e}") __all__ = ("DropboxFilesSource",) lib/galaxy/managers/remote_files.py +9 −2 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ from typing import ( from galaxy import exceptions from galaxy.files import ( ConfiguredFileSources, FileSourcePath, ProvidesUserFileSourcesUserContext, ) from galaxy.files.sources import ( Loading Loading @@ -94,10 +95,10 @@ class RemoteFilesManager: opts=opts, ) except exceptions.MessageException: log.warning(f"Problem listing file source path {file_source_path}", exc_info=True) log.warning(self._get_error_message(file_source_path), exc_info=True) raise except Exception: message = f"Problem listing file source path {file_source_path}" message = self._get_error_message(file_source_path) log.warning(message, exc_info=True) raise exceptions.InternalServerError(message) if format == RemoteFilesFormat.flat: Loading Loading @@ -131,6 +132,9 @@ class RemoteFilesManager: return index def _get_error_message(self, file_source_path: FileSourcePath) -> str: return f"Problem listing file source path {file_source_path.file_source.get_uri_root()}{file_source_path.path}" def get_files_source_plugins( self, user_context: ProvidesUserContext, Loading Loading @@ -162,6 +166,9 @@ class RemoteFilesManager: file_source = file_source_path.file_source try: result = file_source.create_entry(entry_data.dict(), user_context=user_file_source_context) except exceptions.MessageException: log.warning(f"Problem creating entry {entry_data.name} in file source {entry_data.target}", exc_info=True) raise except Exception: message = f"Problem creating entry {entry_data.name} in file source {entry_data.target}" log.warning(message, exc_info=True) Loading Loading
lib/galaxy/files/sources/_pyfilesystem2.py +24 −13 Original line number Diff line number Diff line Loading @@ -12,9 +12,14 @@ from typing import ( ) import fs import fs.errors from fs.base import FS from typing_extensions import Unpack from galaxy.exceptions import ( AuthenticationRequired, MessageException, ) from . import ( BaseFilesSource, FilesSourceOptions, Loading Loading @@ -42,7 +47,7 @@ class PyFilesystem2FilesSource(BaseFilesSource): def _list(self, path="/", recursive=False, user_context=None, opts: Optional[FilesSourceOptions] = None): """Return dictionary of 'Directory's and 'File's.""" try: with self._open_fs(user_context=user_context, opts=opts) as h: if recursive: res: List[Dict[str, Any]] = [] Loading @@ -55,6 +60,12 @@ class PyFilesystem2FilesSource(BaseFilesSource): res = h.scandir(path, namespaces=["details"]) to_dict = functools.partial(self._resource_info_to_dict, path) return list(map(to_dict, res)) except fs.errors.PermissionDenied as e: raise AuthenticationRequired( f"Permission Denied. Reason: {e}. Please check your credentials in your preferences for {self.label}." ) except fs.errors.FSError as e: raise MessageException(f"Problem listing file source path {path}. Reason: {e}") from e def _realize_to(self, source_path, native_path, user_context=None, opts: Optional[FilesSourceOptions] = None): with open(native_path, "wb") as write_file: Loading
lib/galaxy/files/sources/dropbox.py +15 −2 Original line number Diff line number Diff line Loading @@ -8,6 +8,10 @@ from typing import ( Union, ) from galaxy.exceptions import ( AuthenticationRequired, MessageException, ) from . import ( FilesSourceOptions, FilesSourceProperties, Loading @@ -27,8 +31,17 @@ class DropboxFilesSource(PyFilesystem2FilesSource): if "accessToken" in props: props["access_token"] = props.pop("accessToken") try: handle = DropboxFS(**{**props, **extra_props}) return handle except Exception as e: # This plugin might raise dropbox.dropbox_client.BadInputException # which is not a subclass of fs.errors.FSError if "OAuth2" in str(e): raise AuthenticationRequired( f"Permission Denied. Reason: {e}. Please check your credentials in your preferences for {self.label}." ) raise MessageException(f"Error connecting to Dropbox. Reason: {e}") __all__ = ("DropboxFilesSource",)
lib/galaxy/managers/remote_files.py +9 −2 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ from typing import ( from galaxy import exceptions from galaxy.files import ( ConfiguredFileSources, FileSourcePath, ProvidesUserFileSourcesUserContext, ) from galaxy.files.sources import ( Loading Loading @@ -94,10 +95,10 @@ class RemoteFilesManager: opts=opts, ) except exceptions.MessageException: log.warning(f"Problem listing file source path {file_source_path}", exc_info=True) log.warning(self._get_error_message(file_source_path), exc_info=True) raise except Exception: message = f"Problem listing file source path {file_source_path}" message = self._get_error_message(file_source_path) log.warning(message, exc_info=True) raise exceptions.InternalServerError(message) if format == RemoteFilesFormat.flat: Loading Loading @@ -131,6 +132,9 @@ class RemoteFilesManager: return index def _get_error_message(self, file_source_path: FileSourcePath) -> str: return f"Problem listing file source path {file_source_path.file_source.get_uri_root()}{file_source_path.path}" def get_files_source_plugins( self, user_context: ProvidesUserContext, Loading Loading @@ -162,6 +166,9 @@ class RemoteFilesManager: file_source = file_source_path.file_source try: result = file_source.create_entry(entry_data.dict(), user_context=user_file_source_context) except exceptions.MessageException: log.warning(f"Problem creating entry {entry_data.name} in file source {entry_data.target}", exc_info=True) raise except Exception: message = f"Problem creating entry {entry_data.name} in file source {entry_data.target}" log.warning(message, exc_info=True) Loading