commit/galaxy-central: greg: Raise an exception with a useful message if a dependency definition file being uploaded to a repository in the tool shed is missing a required name or owner attribute for a repository dependency.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/86efa5ac1fae/ Changeset: 86efa5ac1fae User: greg Date: 2013-07-08 20:31:15 Summary: Raise an exception with a useful message if a dependency definition file being uploaded to a repository in the tool shed is missing a required name or owner attribute for a repository dependency. Affected #: 3 files diff -r 2accb50ef103b083f053c9550518d75c7527f706 -r 86efa5ac1fae6fb46e7af9804e036a7ab44b0e26 lib/tool_shed/util/commit_util.py --- a/lib/tool_shed/util/commit_util.py +++ b/lib/tool_shed/util/commit_util.py @@ -164,6 +164,18 @@ suc.handle_email_alerts( trans, repository, content_alert_str=content_alert_str, new_repo_alert=new_repo_alert, admin_only=admin_only ) return True, '', files_to_remove, content_alert_str, undesirable_dirs_removed, undesirable_files_removed +def handle_missing_repository_attribute( elem ): + # <repository name="molecule_datatypes" owner="test" /> + error_message = '' + name = elem.get( 'name' ) + if not name: + error_message += 'The tag is missing the required name attribute. ' + owner = elem.get( 'owner' ) + if not owner: + error_message += 'The tag is missing the required owner attribute. ' + log.debug( error_message ) + return error_message + def handle_gzip( repository, uploaded_file_name ): fd, uncompressed = tempfile.mkstemp( prefix='repo_%d_upload_gunzip_' % repository.id, dir=os.path.dirname( uploaded_file_name ), text=False ) gzipped_file = gzip.GzipFile( uploaded_file_name, 'rb' ) @@ -192,7 +204,10 @@ if root.tag == 'repositories': for index, elem in enumerate( root ): # <repository name="molecule_datatypes" owner="test" changeset_revision="1a070566e9c6" /> - populated, elem = handle_repository_dependency_elem( trans, elem ) + populated, elem, error_message = handle_repository_dependency_elem( trans, elem ) + if error_message: + exception_message = 'The repository_dependencies.xml file contains an invalid <repository> tag. %s' % error_message + raise Exception( exception_message ) if populated: root[ index ] = elem if not altered: @@ -202,6 +217,12 @@ def handle_repository_dependency_elem( trans, elem ): # <repository name="molecule_datatypes" owner="test" changeset_revision="1a070566e9c6" /> + error_message = '' + name = elem.get( 'name' ) + owner = elem.get( 'owner' ) + if not name or not owner: + error_message = handle_missing_repository_attribute( elem ) + return False, elem, error_message populated = False toolshed = elem.get( 'toolshed' ) if not toolshed: @@ -209,8 +230,6 @@ toolshed = str( url_for( '/', qualified=True ) ).rstrip( '/' ) elem.attrib[ 'toolshed' ] = toolshed populated = True - name = elem.get( 'name' ) - owner = elem.get( 'owner' ) changeset_revision = elem.get( 'changeset_revision' ) if not changeset_revision: # Populate the changeset_revision attribute with the latest installable metadata revision for the defined repository. @@ -224,7 +243,9 @@ if lastest_installable_changeset_revision != suc.INITIAL_CHANGELOG_HASH: elem.attrib[ 'changeset_revision' ] = lastest_installable_changeset_revision populated = True - return populated, elem + else: + error_message = 'Unable to locate repository with name %s and owner %s. ' % ( str( name ), str( owner ) ) + return populated, elem, error_message def handle_tool_dependencies_definition( trans, tool_dependencies_config ): altered = False @@ -241,7 +262,10 @@ for package_index, package_elem in enumerate( root_elem ): if package_elem.tag == 'repository': # <repository name="package_eigen_2_0" owner="test" changeset_revision="09eb05087cd0" prior_installation_required="True" /> - populated, repository_elem = handle_repository_dependency_elem( trans, package_elem ) + populated, repository_elem, error_message = handle_repository_dependency_elem( trans, package_elem ) + if error_message: + exception_message = 'The tool_dependencies.xml file contains an invalid <repository> tag. %s' % error_message + raise Exception( exception_message ) if populated: root_elem[ package_index ] = repository_elem package_altered = True @@ -259,7 +283,10 @@ # </repository> # </action> for repo_index, repo_elem in enumerate( action_elem ): - populated, repository_elem = handle_repository_dependency_elem( trans, repo_elem ) + populated, repository_elem, error_message = handle_repository_dependency_elem( trans, repo_elem ) + if error_message: + exception_message = 'The tool_dependencies.xml file contains an invalid <repository> tag. %s' % error_message + raise Exception( exception_message ) if populated: action_elem[ repo_index ] = repository_elem package_altered = True diff -r 2accb50ef103b083f053c9550518d75c7527f706 -r 86efa5ac1fae6fb46e7af9804e036a7ab44b0e26 lib/tool_shed/util/common_util.py --- a/lib/tool_shed/util/common_util.py +++ b/lib/tool_shed/util/common_util.py @@ -63,7 +63,7 @@ else: exception_msg = '\n\nThe entry for the main Galaxy tool shed at %s is missing from the %s file. ' % ( tool_shed, app.config.tool_sheds_config ) exception_msg += 'The entry for this tool shed must always be available in this file, so re-add it before attempting to start your Galaxy server.\n' - raise Exception( exception_msg ) + raise Exception( exception_msg ) return tool_shed_accessible, missing_tool_configs_dict def check_tool_tag_set( elem, migrated_tool_configs_dict, missing_tool_configs_dict ): diff -r 2accb50ef103b083f053c9550518d75c7527f706 -r 86efa5ac1fae6fb46e7af9804e036a7ab44b0e26 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 @@ -249,7 +249,7 @@ if metadata_dict: invalid_repository_dependencies_dict = metadata_dict.get( 'invalid_repository_dependencies', None ) if invalid_repository_dependencies_dict: - invalid_repository_dependencies = invalid_repository_dependencies_dict[ 'invalid_repository_dependencies' ] + invalid_repository_dependencies = invalid_repository_dependencies_dict.get( 'invalid_repository_dependencies', [] ) for repository_dependency_tup in invalid_repository_dependencies: toolshed, name, owner, changeset_revision, prior_installation_required, error = \ suc.parse_repository_dependency_tuple( repository_dependency_tup, contains_error=True ) 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