commit/galaxy-central: 2 new changesets

2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/6a8584218f61/ Changeset: 6a8584218f61 Branch: next-stable User: greg Date: 2013-06-03 18:05:24 Summary: Fix for handling tool panel section selection when installting tool shed repositories. Affected #: 5 files diff -r 3df028d4cab449f4ee2b5db771ec545d88e3440e -r 6a8584218f61c5cf7aa129677a7548c610cd0cca lib/tool_shed/galaxy_install/repository_util.py --- a/lib/tool_shed/galaxy_install/repository_util.py +++ b/lib/tool_shed/galaxy_install/repository_util.py @@ -388,25 +388,9 @@ tool_shed_url = installation_dict[ 'tool_shed_url' ] # Handle contained tools. if includes_tools_for_display_in_tool_panel and ( new_tool_panel_section or tool_panel_section ): - if new_tool_panel_section: - section_id = new_tool_panel_section.lower().replace( ' ', '_' ) - tool_panel_section_key = 'section_%s' % str( section_id ) - if tool_panel_section_key in trans.app.toolbox.tool_panel: - # Appending a tool to an existing section in trans.app.toolbox.tool_panel - log.debug( "Appending to tool panel section: %s" % new_tool_panel_section ) - tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] - else: - # Appending a new section to trans.app.toolbox.tool_panel - log.debug( "Loading new tool panel section: %s" % new_tool_panel_section ) - elem = XmlET.Element( 'section' ) - elem.attrib[ 'name' ] = new_tool_panel_section - elem.attrib[ 'id' ] = section_id - elem.attrib[ 'version' ] = '' - tool_section = tools.ToolSection( elem ) - trans.app.toolbox.tool_panel[ tool_panel_section_key ] = tool_section - else: - tool_panel_section_key = 'section_%s' % tool_panel_section - tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] + tool_panel_section_key, tool_section = tool_util.handle_tool_panel_section( trans, + tool_panel_section=tool_panel_section, + new_tool_panel_section=new_tool_panel_section ) else: tool_panel_section_key = None tool_section = None diff -r 3df028d4cab449f4ee2b5db771ec545d88e3440e -r 6a8584218f61c5cf7aa129677a7548c610cd0cca lib/tool_shed/util/datatype_util.py --- a/lib/tool_shed/util/datatype_util.py +++ b/lib/tool_shed/util/datatype_util.py @@ -34,7 +34,7 @@ relative_path_to_datatype_file_name = None datatype_files = datatypes_config_root.find( 'datatype_files' ) datatype_class_modules = [] - if datatype_files: + if datatype_files is not None: # The <datatype_files> tag set contains any number of <datatype_file> tags. # <datatype_files> # <datatype_file name="gmap.py"/> @@ -74,14 +74,14 @@ os.write( fd, '<?xml version="1.0"?>\n' ) os.write( fd, '<datatypes>\n' ) os.write( fd, '%s' % xml_util.xml_to_string( registration ) ) - if sniffers: + if sniffers is not None: os.write( fd, '%s' % xml_util.xml_to_string( sniffers ) ) os.write( fd, '</datatypes>\n' ) os.close( fd ) 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 datatype_files: + if datatype_files is not None: try: os.unlink( proprietary_datatypes_config ) except: diff -r 3df028d4cab449f4ee2b5db771ec545d88e3440e -r 6a8584218f61c5cf7aa129677a7548c610cd0cca lib/tool_shed/util/metadata_util.py --- a/lib/tool_shed/util/metadata_util.py +++ b/lib/tool_shed/util/metadata_util.py @@ -435,14 +435,14 @@ root = tree.getroot() repository_datatype_code_files = [] datatype_files = root.find( 'datatype_files' ) - if datatype_files: + if datatype_files is not None: for elem in datatype_files.findall( 'datatype_file' ): name = elem.get( 'name', None ) repository_datatype_code_files.append( name ) metadata_dict[ 'datatype_files' ] = repository_datatype_code_files datatypes = [] registration = root.find( 'registration' ) - if registration: + if registration is not None: for elem in registration.findall( 'datatype' ): converters = [] display_app_containers = [] diff -r 3df028d4cab449f4ee2b5db771ec545d88e3440e -r 6a8584218f61c5cf7aa129677a7548c610cd0cca lib/tool_shed/util/repository_dependency_util.py --- a/lib/tool_shed/util/repository_dependency_util.py +++ b/lib/tool_shed/util/repository_dependency_util.py @@ -203,22 +203,15 @@ else: # We're installing a new tool shed repository that does not yet have a database record. This repository is a repository dependency # of a different repository being installed. - if new_tool_panel_section: - section_id = new_tool_panel_section.lower().replace( ' ', '_' ) - tool_panel_section_key = 'section_%s' % str( section_id ) - elif tool_panel_section: - tool_panel_section_key = 'section_%s' % tool_panel_section - else: - tool_panel_section_key = None + tool_panel_section_key, tool_section = tool_util.handle_tool_panel_section( trans, + tool_panel_section=tool_panel_section, + new_tool_panel_section=new_tool_panel_section ) + else: # We're installing a new tool shed repository that does not yet have a database record. - if new_tool_panel_section: - section_id = new_tool_panel_section.lower().replace( ' ', '_' ) - tool_panel_section_key = 'section_%s' % str( section_id ) - elif tool_panel_section: - tool_panel_section_key = 'section_%s' % tool_panel_section - else: - tool_panel_section_key = None + tool_panel_section_key, tool_section = tool_util.handle_tool_panel_section( trans, + tool_panel_section=tool_panel_section, + new_tool_panel_section=new_tool_panel_section ) tool_shed_repository = suc.create_or_update_tool_shed_repository( app=trans.app, name=name, description=description, @@ -239,7 +232,7 @@ tool_panel_section_keys.append( tool_panel_section_key ) filtered_repo_info_dicts.append( repo_info_dict ) # Build repository dependency relationships even if the user chose to not install repository dependencies. - build_repository_dependency_relationships( trans, all_repo_info_dicts, all_created_or_updated_tool_shed_repositories ) + build_repository_dependency_relationships( trans, all_repo_info_dicts, all_created_or_updated_tool_shed_repositories ) return created_or_updated_tool_shed_repositories, tool_panel_section_keys, all_repo_info_dicts, filtered_repo_info_dicts, message def generate_message_for_invalid_repository_dependencies( metadata_dict ): diff -r 3df028d4cab449f4ee2b5db771ec545d88e3440e -r 6a8584218f61c5cf7aa129677a7548c610cd0cca lib/tool_shed/util/tool_util.py --- a/lib/tool_shed/util/tool_util.py +++ b/lib/tool_shed/util/tool_util.py @@ -458,6 +458,31 @@ fh.close() return sample_files, deleted_sample_files +def get_or_create_tool_section( trans, tool_panel_section_id, new_tool_panel_section=None ): + tool_panel_section_key = 'section_%s' % str( tool_panel_section_id ) + if tool_panel_section_key in trans.app.toolbox.tool_panel: + # Appending a tool to an existing section in trans.app.toolbox.tool_panel + tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] + log.debug( "Appending to tool panel section: %s" % str( tool_section.name ) ) + else: + # Appending a new section to trans.app.toolbox.tool_panel + try: + new_tool_panel_section_name = new_tool_panel_section.name + except: + new_tool_panel_section_name = new_tool_panel_section + if new_tool_panel_section_name: + elem = XmlET.Element( 'section' ) + elem.attrib[ 'name' ] = new_tool_panel_section_name + elem.attrib[ 'id' ] = tool_panel_section_id + elem.attrib[ 'version' ] = '' + tool_section = galaxy.tools.ToolSection( elem ) + trans.app.toolbox.tool_panel[ tool_panel_section_key ] = tool_section + log.debug( "Loading new tool panel section: %s" % str( tool_section.name ) ) + else: + log.debug( "Unable to create new tool pane section using received new_tool_panel_section: %s" % str( new_tool_panel_section )) + return None, None + return tool_panel_section_key, tool_section + def get_tool_path_install_dir( partial_install_dir, shed_tool_conf_dict, tool_dict, config_elems ): for elem in config_elems: if elem.tag == 'tool': @@ -614,8 +639,8 @@ if 'tools' in metadata: # This forces everything to be loaded into the same section (or no section) in the tool panel. if no_changes_checked: - # Make sure the no_changes checkbox overrides the new_tool_panel_section if the user checked the checkbox and - # entered something into the field. + # Make sure the no_changes check box overrides the new_tool_panel_section if the user checked the check box and entered something + # into the field. new_tool_panel_section = None if 'tool_panel_section' in metadata: tool_panel_dict = metadata[ 'tool_panel_section' ] @@ -630,42 +655,29 @@ original_section_id = tool_section_dict[ 'id' ] original_section_name = tool_section_dict[ 'name' ] if original_section_id: - tool_panel_section_key = 'section_%s' % str( original_section_id ) - if tool_panel_section_key in trans.app.toolbox.tool_panel: - tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] - else: - # The section in which the tool was originally loaded used to be in the tool panel, but no longer is. - elem = XmlET.Element( 'section' ) - elem.attrib[ 'name' ] = original_section_name - elem.attrib[ 'id' ] = original_section_id - elem.attrib[ 'version' ] = '' - tool_section = galaxy.tools.ToolSection( elem ) - trans.app.toolbox.tool_panel[ tool_panel_section_key ] = tool_section + tool_panel_section_key, tool_section = get_or_create_tool_section( trans, + tool_panel_section_id=original_section_id, + new_tool_panel_section=new_tool_panel_section ) else: # The user elected to change the tool panel section to contain the tools. - if new_tool_panel_section: - section_id = new_tool_panel_section.lower().replace( ' ', '_' ) - tool_panel_section_key = 'section_%s' % str( section_id ) - if tool_panel_section_key in trans.app.toolbox.tool_panel: - # Appending a tool to an existing section in trans.app.toolbox.tool_panel - log.debug( "Appending to tool panel section: %s" % new_tool_panel_section ) - tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] - else: - # Appending a new section to trans.app.toolbox.tool_panel - log.debug( "Loading new tool panel section: %s" % new_tool_panel_section ) - elem = XmlET.Element( 'section' ) - elem.attrib[ 'name' ] = new_tool_panel_section - elem.attrib[ 'id' ] = section_id - elem.attrib[ 'version' ] = '' - tool_section = galaxy.tools.ToolSection( elem ) - trans.app.toolbox.tool_panel[ tool_panel_section_key ] = tool_section - elif tool_panel_section: - tool_panel_section_key = 'section_%s' % tool_panel_section - tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] - else: - tool_section = None + tool_panel_section_key, tool_section = handle_tool_panel_section( trans, + tool_panel_section=tool_panel_section, + new_tool_panel_section=new_tool_panel_section ) return tool_section, new_tool_panel_section, tool_panel_section_key +def handle_tool_panel_section( trans, tool_panel_section=None, new_tool_panel_section=None ): + if new_tool_panel_section: + section_id = new_tool_panel_section.lower().replace( ' ', '_' ) + tool_panel_section_key, tool_section = get_or_create_tool_section( trans, + tool_panel_section_id=section_id, + new_tool_panel_section=new_tool_panel_section ) + elif tool_panel_section: + tool_panel_section_key = 'section_%s' % str( tool_panel_section ) + tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] + else: + return None, None + return tool_panel_section_key, tool_section + def handle_tool_versions( app, tool_version_dicts, tool_shed_repository ): """ Using the list of tool_version_dicts retrieved from the tool shed (one per changeset revison up to the currently installed changeset revision), https://bitbucket.org/galaxy/galaxy-central/commits/83213accd759/ Changeset: 83213accd759 User: greg Date: 2013-06-03 18:05:49 Summary: Merged from next-stable Affected #: 5 files diff -r 1380f4546418736a0645267868de615ac6d1b0e1 -r 83213accd759e752538c025275557d3dfc5d1433 lib/tool_shed/galaxy_install/repository_util.py --- a/lib/tool_shed/galaxy_install/repository_util.py +++ b/lib/tool_shed/galaxy_install/repository_util.py @@ -388,25 +388,9 @@ tool_shed_url = installation_dict[ 'tool_shed_url' ] # Handle contained tools. if includes_tools_for_display_in_tool_panel and ( new_tool_panel_section or tool_panel_section ): - if new_tool_panel_section: - section_id = new_tool_panel_section.lower().replace( ' ', '_' ) - tool_panel_section_key = 'section_%s' % str( section_id ) - if tool_panel_section_key in trans.app.toolbox.tool_panel: - # Appending a tool to an existing section in trans.app.toolbox.tool_panel - log.debug( "Appending to tool panel section: %s" % new_tool_panel_section ) - tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] - else: - # Appending a new section to trans.app.toolbox.tool_panel - log.debug( "Loading new tool panel section: %s" % new_tool_panel_section ) - elem = XmlET.Element( 'section' ) - elem.attrib[ 'name' ] = new_tool_panel_section - elem.attrib[ 'id' ] = section_id - elem.attrib[ 'version' ] = '' - tool_section = tools.ToolSection( elem ) - trans.app.toolbox.tool_panel[ tool_panel_section_key ] = tool_section - else: - tool_panel_section_key = 'section_%s' % tool_panel_section - tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] + tool_panel_section_key, tool_section = tool_util.handle_tool_panel_section( trans, + tool_panel_section=tool_panel_section, + new_tool_panel_section=new_tool_panel_section ) else: tool_panel_section_key = None tool_section = None diff -r 1380f4546418736a0645267868de615ac6d1b0e1 -r 83213accd759e752538c025275557d3dfc5d1433 lib/tool_shed/util/datatype_util.py --- a/lib/tool_shed/util/datatype_util.py +++ b/lib/tool_shed/util/datatype_util.py @@ -34,7 +34,7 @@ relative_path_to_datatype_file_name = None datatype_files = datatypes_config_root.find( 'datatype_files' ) datatype_class_modules = [] - if datatype_files: + if datatype_files is not None: # The <datatype_files> tag set contains any number of <datatype_file> tags. # <datatype_files> # <datatype_file name="gmap.py"/> @@ -74,14 +74,14 @@ os.write( fd, '<?xml version="1.0"?>\n' ) os.write( fd, '<datatypes>\n' ) os.write( fd, '%s' % xml_util.xml_to_string( registration ) ) - if sniffers: + if sniffers is not None: os.write( fd, '%s' % xml_util.xml_to_string( sniffers ) ) os.write( fd, '</datatypes>\n' ) os.close( fd ) 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 datatype_files: + if datatype_files is not None: try: os.unlink( proprietary_datatypes_config ) except: diff -r 1380f4546418736a0645267868de615ac6d1b0e1 -r 83213accd759e752538c025275557d3dfc5d1433 lib/tool_shed/util/metadata_util.py --- a/lib/tool_shed/util/metadata_util.py +++ b/lib/tool_shed/util/metadata_util.py @@ -435,14 +435,14 @@ root = tree.getroot() repository_datatype_code_files = [] datatype_files = root.find( 'datatype_files' ) - if datatype_files: + if datatype_files is not None: for elem in datatype_files.findall( 'datatype_file' ): name = elem.get( 'name', None ) repository_datatype_code_files.append( name ) metadata_dict[ 'datatype_files' ] = repository_datatype_code_files datatypes = [] registration = root.find( 'registration' ) - if registration: + if registration is not None: for elem in registration.findall( 'datatype' ): converters = [] display_app_containers = [] diff -r 1380f4546418736a0645267868de615ac6d1b0e1 -r 83213accd759e752538c025275557d3dfc5d1433 lib/tool_shed/util/repository_dependency_util.py --- a/lib/tool_shed/util/repository_dependency_util.py +++ b/lib/tool_shed/util/repository_dependency_util.py @@ -203,22 +203,15 @@ else: # We're installing a new tool shed repository that does not yet have a database record. This repository is a repository dependency # of a different repository being installed. - if new_tool_panel_section: - section_id = new_tool_panel_section.lower().replace( ' ', '_' ) - tool_panel_section_key = 'section_%s' % str( section_id ) - elif tool_panel_section: - tool_panel_section_key = 'section_%s' % tool_panel_section - else: - tool_panel_section_key = None + tool_panel_section_key, tool_section = tool_util.handle_tool_panel_section( trans, + tool_panel_section=tool_panel_section, + new_tool_panel_section=new_tool_panel_section ) + else: # We're installing a new tool shed repository that does not yet have a database record. - if new_tool_panel_section: - section_id = new_tool_panel_section.lower().replace( ' ', '_' ) - tool_panel_section_key = 'section_%s' % str( section_id ) - elif tool_panel_section: - tool_panel_section_key = 'section_%s' % tool_panel_section - else: - tool_panel_section_key = None + tool_panel_section_key, tool_section = tool_util.handle_tool_panel_section( trans, + tool_panel_section=tool_panel_section, + new_tool_panel_section=new_tool_panel_section ) tool_shed_repository = suc.create_or_update_tool_shed_repository( app=trans.app, name=name, description=description, @@ -239,7 +232,7 @@ tool_panel_section_keys.append( tool_panel_section_key ) filtered_repo_info_dicts.append( repo_info_dict ) # Build repository dependency relationships even if the user chose to not install repository dependencies. - build_repository_dependency_relationships( trans, all_repo_info_dicts, all_created_or_updated_tool_shed_repositories ) + build_repository_dependency_relationships( trans, all_repo_info_dicts, all_created_or_updated_tool_shed_repositories ) return created_or_updated_tool_shed_repositories, tool_panel_section_keys, all_repo_info_dicts, filtered_repo_info_dicts, message def generate_message_for_invalid_repository_dependencies( metadata_dict ): diff -r 1380f4546418736a0645267868de615ac6d1b0e1 -r 83213accd759e752538c025275557d3dfc5d1433 lib/tool_shed/util/tool_util.py --- a/lib/tool_shed/util/tool_util.py +++ b/lib/tool_shed/util/tool_util.py @@ -458,6 +458,31 @@ fh.close() return sample_files, deleted_sample_files +def get_or_create_tool_section( trans, tool_panel_section_id, new_tool_panel_section=None ): + tool_panel_section_key = 'section_%s' % str( tool_panel_section_id ) + if tool_panel_section_key in trans.app.toolbox.tool_panel: + # Appending a tool to an existing section in trans.app.toolbox.tool_panel + tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] + log.debug( "Appending to tool panel section: %s" % str( tool_section.name ) ) + else: + # Appending a new section to trans.app.toolbox.tool_panel + try: + new_tool_panel_section_name = new_tool_panel_section.name + except: + new_tool_panel_section_name = new_tool_panel_section + if new_tool_panel_section_name: + elem = XmlET.Element( 'section' ) + elem.attrib[ 'name' ] = new_tool_panel_section_name + elem.attrib[ 'id' ] = tool_panel_section_id + elem.attrib[ 'version' ] = '' + tool_section = galaxy.tools.ToolSection( elem ) + trans.app.toolbox.tool_panel[ tool_panel_section_key ] = tool_section + log.debug( "Loading new tool panel section: %s" % str( tool_section.name ) ) + else: + log.debug( "Unable to create new tool pane section using received new_tool_panel_section: %s" % str( new_tool_panel_section )) + return None, None + return tool_panel_section_key, tool_section + def get_tool_path_install_dir( partial_install_dir, shed_tool_conf_dict, tool_dict, config_elems ): for elem in config_elems: if elem.tag == 'tool': @@ -614,8 +639,8 @@ if 'tools' in metadata: # This forces everything to be loaded into the same section (or no section) in the tool panel. if no_changes_checked: - # Make sure the no_changes checkbox overrides the new_tool_panel_section if the user checked the checkbox and - # entered something into the field. + # Make sure the no_changes check box overrides the new_tool_panel_section if the user checked the check box and entered something + # into the field. new_tool_panel_section = None if 'tool_panel_section' in metadata: tool_panel_dict = metadata[ 'tool_panel_section' ] @@ -630,42 +655,29 @@ original_section_id = tool_section_dict[ 'id' ] original_section_name = tool_section_dict[ 'name' ] if original_section_id: - tool_panel_section_key = 'section_%s' % str( original_section_id ) - if tool_panel_section_key in trans.app.toolbox.tool_panel: - tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] - else: - # The section in which the tool was originally loaded used to be in the tool panel, but no longer is. - elem = XmlET.Element( 'section' ) - elem.attrib[ 'name' ] = original_section_name - elem.attrib[ 'id' ] = original_section_id - elem.attrib[ 'version' ] = '' - tool_section = galaxy.tools.ToolSection( elem ) - trans.app.toolbox.tool_panel[ tool_panel_section_key ] = tool_section + tool_panel_section_key, tool_section = get_or_create_tool_section( trans, + tool_panel_section_id=original_section_id, + new_tool_panel_section=new_tool_panel_section ) else: # The user elected to change the tool panel section to contain the tools. - if new_tool_panel_section: - section_id = new_tool_panel_section.lower().replace( ' ', '_' ) - tool_panel_section_key = 'section_%s' % str( section_id ) - if tool_panel_section_key in trans.app.toolbox.tool_panel: - # Appending a tool to an existing section in trans.app.toolbox.tool_panel - log.debug( "Appending to tool panel section: %s" % new_tool_panel_section ) - tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] - else: - # Appending a new section to trans.app.toolbox.tool_panel - log.debug( "Loading new tool panel section: %s" % new_tool_panel_section ) - elem = XmlET.Element( 'section' ) - elem.attrib[ 'name' ] = new_tool_panel_section - elem.attrib[ 'id' ] = section_id - elem.attrib[ 'version' ] = '' - tool_section = galaxy.tools.ToolSection( elem ) - trans.app.toolbox.tool_panel[ tool_panel_section_key ] = tool_section - elif tool_panel_section: - tool_panel_section_key = 'section_%s' % tool_panel_section - tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] - else: - tool_section = None + tool_panel_section_key, tool_section = handle_tool_panel_section( trans, + tool_panel_section=tool_panel_section, + new_tool_panel_section=new_tool_panel_section ) return tool_section, new_tool_panel_section, tool_panel_section_key +def handle_tool_panel_section( trans, tool_panel_section=None, new_tool_panel_section=None ): + if new_tool_panel_section: + section_id = new_tool_panel_section.lower().replace( ' ', '_' ) + tool_panel_section_key, tool_section = get_or_create_tool_section( trans, + tool_panel_section_id=section_id, + new_tool_panel_section=new_tool_panel_section ) + elif tool_panel_section: + tool_panel_section_key = 'section_%s' % str( tool_panel_section ) + tool_section = trans.app.toolbox.tool_panel[ tool_panel_section_key ] + else: + return None, None + return tool_panel_section_key, tool_section + def handle_tool_versions( app, tool_version_dicts, tool_shed_repository ): """ Using the list of tool_version_dicts retrieved from the tool shed (one per changeset revison up to the currently installed changeset revision), 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.
participants (1)
-
commits-noreply@bitbucket.org