2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/f8cf776ff12f/ Changeset: f8cf776ff12f Branch: stable User: greg Date: 2013-06-12 15:09:33 Summary: Make sure custom datatypes contained in newly installed tool shed repositories are loaded into the upload form's File Format select list. Also, when an installed repository is uninstalled, remove the appropriate datatype extensions from the upload form's select list. Affected #: 3 files diff -r 7105c53139d4b8649e6a3714bc117118989712a2 -r f8cf776ff12f480ff0be89bc7b92c0e9c7658b0e lib/galaxy/datatypes/registry.py --- a/lib/galaxy/datatypes/registry.py +++ b/lib/galaxy/datatypes/registry.py @@ -121,6 +121,8 @@ # TODO: Handle deactivating datatype converters, etc before removing from self.datatypes_by_extension. self.log.debug( "Removing datatype with extension '%s' from the registry." % extension ) del self.datatypes_by_extension[ extension ] + if extension in self.upload_file_formats: + self.upload_file_formats.remove( extension ) can_process_datatype = False else: can_process_datatype = ( extension and ( dtype or type_extension ) ) and ( extension not in self.datatypes_by_extension or override ) @@ -165,7 +167,7 @@ self.mimetypes_by_extension[ extension ] = mimetype if datatype_class.track_type: self.available_tracks.append( extension ) - if display_in_upload: + if display_in_upload and extension not in self.upload_file_formats: self.upload_file_formats.append( extension ) # Max file size cut off for setting optional metadata self.datatypes_by_extension[ extension ].max_optional_metadata_filesize = elem.get( 'max_optional_metadata_filesize', None ) diff -r 7105c53139d4b8649e6a3714bc117118989712a2 -r f8cf776ff12f480ff0be89bc7b92c0e9c7658b0e lib/tool_shed/util/datatype_util.py --- a/lib/tool_shed/util/datatype_util.py +++ b/lib/tool_shed/util/datatype_util.py @@ -2,6 +2,8 @@ import os import tempfile from galaxy import eggs +from galaxy.util import asbool +from tool_shed.util import tool_util from tool_shed.util import xml_util import tool_shed.util.shed_util_common as suc @@ -81,6 +83,12 @@ os.chmod( proprietary_datatypes_config, 0644 ) # Load proprietary datatypes app.datatypes_registry.load_datatypes( root_dir=app.config.root, config=proprietary_datatypes_config, deactivate=deactivate, override=override ) + if deactivate: + # Reload the upload tool to eliminate deactivated datatype extensions from the file_type select list. + tool_util.reload_upload_tools( app ) + else: + append_to_datatypes_registry_upload_file_formats( app, registration ) + tool_util.reload_upload_tools( app ) if datatype_files is not None: try: os.unlink( proprietary_datatypes_config ) @@ -88,6 +96,16 @@ pass return converter_path, display_path +def append_to_datatypes_registry_upload_file_formats( app, elem ): + # See if we have any datatypes that should be displayed in the upload tool's file_type select list. + for datatype_elem in elem.findall( 'datatype' ): + extension = datatype_elem.get( 'extension', None ) + display_in_upload = datatype_elem.get( 'display_in_upload', None ) + if extension is not None and display_in_upload is not None: + display_in_upload = asbool( str( display_in_upload ) ) + if display_in_upload and extension not in app.datatypes_registry.upload_file_formats: + app.datatypes_registry.upload_file_formats.append( extension ) + def create_repository_dict_for_proprietary_datatypes( tool_shed, name, owner, installed_changeset_revision, tool_dicts, converter_path=None, display_path=None ): return dict( tool_shed=tool_shed, repository_name=name, diff -r 7105c53139d4b8649e6a3714bc117118989712a2 -r f8cf776ff12f480ff0be89bc7b92c0e9c7658b0e lib/tool_shed/util/tool_util.py --- a/lib/tool_shed/util/tool_util.py +++ b/lib/tool_shed/util/tool_util.py @@ -13,6 +13,7 @@ from galaxy.tools.search import ToolBoxSearch from galaxy.web.form_builder import SelectField from tool_shed.util import xml_util +from galaxy.tools.actions.upload import UploadToolAction import tool_shed.util.shed_util_common as suc from xml.etree import ElementTree as XmlET @@ -849,6 +850,13 @@ return True return False +def reload_upload_tools( app ): + if hasattr( app, 'toolbox' ): + for tool_id in app.toolbox.tools_by_id: + tool = app.toolbox.tools_by_id[ tool_id ] + if isinstance( tool.tool_action, UploadToolAction ): + app.toolbox.reload_tool_by_id( tool_id ) + def remove_from_shed_tool_config( trans, shed_tool_conf_dict, guids_to_remove ): # A tool shed repository is being uninstalled so change the shed_tool_conf file. Parse the config file to generate the entire list # of config_elems instead of using the in-memory list since it will be a subset of the entire list if one or more repositories have https://bitbucket.org/galaxy/galaxy-central/commits/7228f6784623/ Changeset: 7228f6784623 User: greg Date: 2013-06-12 15:10:25 Summary: Merged from stable Affected #: 3 files diff -r 10bd58cc47c538522c37defc80334e805c60d13c -r 7228f6784623ccf84fe125918aa9b88a4336e481 lib/galaxy/datatypes/registry.py --- a/lib/galaxy/datatypes/registry.py +++ b/lib/galaxy/datatypes/registry.py @@ -121,6 +121,8 @@ # TODO: Handle deactivating datatype converters, etc before removing from self.datatypes_by_extension. self.log.debug( "Removing datatype with extension '%s' from the registry." % extension ) del self.datatypes_by_extension[ extension ] + if extension in self.upload_file_formats: + self.upload_file_formats.remove( extension ) can_process_datatype = False else: can_process_datatype = ( extension and ( dtype or type_extension ) ) and ( extension not in self.datatypes_by_extension or override ) @@ -165,7 +167,7 @@ self.mimetypes_by_extension[ extension ] = mimetype if datatype_class.track_type: self.available_tracks.append( extension ) - if display_in_upload: + if display_in_upload and extension not in self.upload_file_formats: self.upload_file_formats.append( extension ) # Max file size cut off for setting optional metadata self.datatypes_by_extension[ extension ].max_optional_metadata_filesize = elem.get( 'max_optional_metadata_filesize', None ) diff -r 10bd58cc47c538522c37defc80334e805c60d13c -r 7228f6784623ccf84fe125918aa9b88a4336e481 lib/tool_shed/util/datatype_util.py --- a/lib/tool_shed/util/datatype_util.py +++ b/lib/tool_shed/util/datatype_util.py @@ -2,6 +2,8 @@ import os import tempfile from galaxy import eggs +from galaxy.util import asbool +from tool_shed.util import tool_util from tool_shed.util import xml_util import tool_shed.util.shed_util_common as suc @@ -81,6 +83,12 @@ os.chmod( proprietary_datatypes_config, 0644 ) # Load proprietary datatypes app.datatypes_registry.load_datatypes( root_dir=app.config.root, config=proprietary_datatypes_config, deactivate=deactivate, override=override ) + if deactivate: + # Reload the upload tool to eliminate deactivated datatype extensions from the file_type select list. + tool_util.reload_upload_tools( app ) + else: + append_to_datatypes_registry_upload_file_formats( app, registration ) + tool_util.reload_upload_tools( app ) if datatype_files is not None: try: os.unlink( proprietary_datatypes_config ) @@ -88,6 +96,16 @@ pass return converter_path, display_path +def append_to_datatypes_registry_upload_file_formats( app, elem ): + # See if we have any datatypes that should be displayed in the upload tool's file_type select list. + for datatype_elem in elem.findall( 'datatype' ): + extension = datatype_elem.get( 'extension', None ) + display_in_upload = datatype_elem.get( 'display_in_upload', None ) + if extension is not None and display_in_upload is not None: + display_in_upload = asbool( str( display_in_upload ) ) + if display_in_upload and extension not in app.datatypes_registry.upload_file_formats: + app.datatypes_registry.upload_file_formats.append( extension ) + def create_repository_dict_for_proprietary_datatypes( tool_shed, name, owner, installed_changeset_revision, tool_dicts, converter_path=None, display_path=None ): return dict( tool_shed=tool_shed, repository_name=name, diff -r 10bd58cc47c538522c37defc80334e805c60d13c -r 7228f6784623ccf84fe125918aa9b88a4336e481 lib/tool_shed/util/tool_util.py --- a/lib/tool_shed/util/tool_util.py +++ b/lib/tool_shed/util/tool_util.py @@ -13,6 +13,7 @@ from galaxy.tools.search import ToolBoxSearch from galaxy.web.form_builder import SelectField from tool_shed.util import xml_util +from galaxy.tools.actions.upload import UploadToolAction import tool_shed.util.shed_util_common as suc from xml.etree import ElementTree as XmlET @@ -902,6 +903,13 @@ return True return False +def reload_upload_tools( app ): + if hasattr( app, 'toolbox' ): + for tool_id in app.toolbox.tools_by_id: + tool = app.toolbox.tools_by_id[ tool_id ] + if isinstance( tool.tool_action, UploadToolAction ): + app.toolbox.reload_tool_by_id( tool_id ) + def remove_from_shed_tool_config( trans, shed_tool_conf_dict, guids_to_remove ): # A tool shed repository is being uninstalled so change the shed_tool_conf file. Parse the config file to generate the entire list # of config_elems instead of using the in-memory list since it will be a subset of the entire list if one or more repositories have Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.