1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/2f3e80ded864/ changeset: 2f3e80ded864 user: greg date: 2013-01-22 19:24:23 summary: Handle invalid repository dependency definitions contained in tool shed repositories. affected #: 2 files diff -r 0e064a23864c846483b35f893cf0a769dedf24f1 -r 2f3e80ded864f29b27ad3af71f4887f23293297c lib/galaxy/util/shed_util_common.py --- a/lib/galaxy/util/shed_util_common.py +++ b/lib/galaxy/util/shed_util_common.py @@ -1888,6 +1888,7 @@ handle_next_repository_dependency( trans, key_rd_dicts_to_be_processed, all_repository_dependencies, handled_key_rd_dicts, circular_repository_dependencies ) elif key_rd_dicts_to_be_processed: handle_next_repository_dependency( trans, key_rd_dicts_to_be_processed, all_repository_dependencies, handled_key_rd_dicts, circular_repository_dependencies ) + all_repository_dependencies = prune_invalid_repository_dependencies( all_repository_dependencies ) return all_repository_dependencies def get_repository_dependency_as_key( repository_dependency ): return container_util.generate_repository_dependencies_key_for_repository( repository_dependency[ 0 ], @@ -2181,12 +2182,12 @@ for key_rd_dict in key_rd_dicts: key = key_rd_dict.keys()[ 0 ] repository_dependency = key_rd_dict[ key ] - toolshed, name, owner, changeset_revision = repository_dependency - if tool_shed_is_this_tool_shed( toolshed ): - repository = get_repository_by_name_and_owner( trans, name, owner ) + rd_toolshed, rd_name, rd_owner, rd_changeset_revision = repository_dependency + if tool_shed_is_this_tool_shed( rd_toolshed ): + repository = get_repository_by_name_and_owner( trans, rd_name, rd_owner ) repository_metadata = get_repository_metadata_by_repository_id_changset_revision( trans, trans.security.encode_id( repository.id ), - changeset_revision ) + rd_changeset_revision ) if repository_metadata: # The repository changeset_revision is installable, so no updates are available. new_key_rd_dict = {} @@ -2196,15 +2197,20 @@ # The repository changeset_revision is no longer installable, so see if there's been an update. repo_dir = repository.repo_path( trans.app ) repo = hg.repository( get_configured_ui(), repo_dir ) - changeset_revision = get_next_downloadable_changeset_revision( repository, repo, changeset_revision ) + changeset_revision = get_next_downloadable_changeset_revision( repository, repo, rd_changeset_revision ) repository_metadata = get_repository_metadata_by_repository_id_changset_revision( trans, trans.security.encode_id( repository.id ), changeset_revision ) if repository_metadata: new_key_rd_dict = {} - new_key_rd_dict[ key ] = [ toolshed, name, owner, repository_metadata.changeset_revision ] + new_key_rd_dict[ key ] = [ rd_toolshed, rd_name, rd_owner, repository_metadata.changeset_revision ] # We have the updated changset revision. updated_key_rd_dicts.append( new_key_rd_dict ) + else: + toolshed, repository_name, repository_owner, repository_changeset_revision = container_util.get_components_from_key( key ) + message = "The revision %s defined for repository %s owned by %s is invalid, so repository dependencies defined for repository %s will be ignored." % \ + ( str( rd_changeset_revision ), str( rd_name ), str( rd_owner ), str( repository_name ) ) + log.debug( message ) return updated_key_rd_dicts def get_url_from_repository_tool_shed( app, repository ): """ @@ -2816,6 +2822,25 @@ new_key_rd_dict[ current_repository_key ] = repository_dependency key_rd_dicts_to_be_processed.append( new_key_rd_dict ) return filtered_current_repository_key_rd_dicts, key_rd_dicts_to_be_processed, handled_key_rd_dicts, all_repository_dependencies +def prune_invalid_repository_dependencies( repository_dependencies ): + """ + Eliminate all invalid entries in the received repository_dependencies dictionary. An entry is invalid if if the value_list of the key/value pair is + empty. This occurs when an invalid combination of tool shed, name , owner, changeset_revision is used and a repository_metadata reocrd is not found. + """ + valid_repository_dependencies = {} + description = repository_dependencies.get( 'description', None ) + root_key = repository_dependencies.get( 'root_key', None ) + if root_key is None: + return valid_repository_dependencies + for key, value in repository_dependencies.items(): + if key in [ 'description', 'root_key' ]: + continue + if value: + valid_repository_dependencies[ key ] = value + if valid_repository_dependencies: + valid_repository_dependencies[ 'description' ] = description + valid_repository_dependencies[ 'root_key' ] = root_key + return valid_repository_dependencies def remove_dir( dir ): if os.path.exists( dir ): try: diff -r 0e064a23864c846483b35f893cf0a769dedf24f1 -r 2f3e80ded864f29b27ad3af71f4887f23293297c lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py +++ b/lib/galaxy/webapps/community/controllers/repository.py @@ -1909,6 +1909,7 @@ metadata = repository_metadata.metadata is_malicious = repository_metadata.malicious if repository_metadata: + metadata = repository_metadata.metadata # Get a dictionary of all repositories upon which the contents of the current repository_metadata record depend. repository_dependencies = suc.get_repository_dependencies_for_changeset_revision( trans=trans, repository=repository, @@ -1917,6 +1918,12 @@ key_rd_dicts_to_be_processed=None, all_repository_dependencies=None, handled_key_rd_dicts=None ) + if metadata: + if 'repository_dependencies' in metadata and not repository_dependencies: + message += 'The repository dependency definitions for this repository are invalid and will be ignored. Make sure valid <b>toolshed</b>, ' + message += '<b>name</b>, <b>owner</b> and <b>changeset_revision</b> values are defined in the contained <b>repository_dependencies.xml</b> ' + message += 'file to correct this problem.' + status = 'error' if is_malicious: if trans.app.security_agent.can_push( trans.app, trans.user, repository ): message += malicious_error_can_push @@ -2029,6 +2036,10 @@ key_rd_dicts_to_be_processed=None, all_repository_dependencies=None, handled_key_rd_dicts=None ) + if metadata: + if 'repository_dependencies' in metadata and not repository_dependencies: + message += 'The repository dependency definitions for this repository are invalid and will be ignored.' + status = 'error' else: repository_metadata_id = None metadata = None @@ -2550,6 +2561,10 @@ key_rd_dicts_to_be_processed=None, all_repository_dependencies=None, handled_key_rd_dicts=None ) + if metadata: + if 'repository_dependencies' in metadata and not repository_dependencies: + message += 'The repository dependency definitions for this repository are invalid and will be ignored.' + status = 'error' else: repository_metadata_id = None metadata = None 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.