mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
Slight refactoring of message generation in the tool shed.
This commit is contained in:
@@ -2159,11 +2159,17 @@ class RepositoryController( BaseUIController, ratings_util.ItemRatings ):
|
||||
all_repository_dependencies=None,
|
||||
handled_key_rd_dicts=None )
|
||||
if str( repository.type ) != rt_util.TOOL_DEPENDENCY_DEFINITION:
|
||||
# Handle messaging for orphan tool dependencies.
|
||||
orphan_message = tool_dependency_util.generate_message_for_orphan_tool_dependencies( trans, repository, metadata )
|
||||
if orphan_message:
|
||||
message += orphan_message
|
||||
# Handle messaging for resetting repository type to the optimal value.
|
||||
change_repository_type_message = tool_dependency_util.generate_message_for_repository_type_change( trans, repository )
|
||||
if change_repository_type_message:
|
||||
message += change_repository_type_message
|
||||
status = 'warning'
|
||||
else:
|
||||
# Handle messaging for orphan tool dependency definitions.
|
||||
orphan_message = tool_dependency_util.generate_message_for_orphan_tool_dependencies( trans, repository, metadata )
|
||||
if orphan_message:
|
||||
message += orphan_message
|
||||
status = 'warning'
|
||||
if is_malicious:
|
||||
if trans.app.security_agent.can_push( trans.app, trans.user, repository ):
|
||||
message += malicious_error_can_push
|
||||
|
||||
@@ -207,15 +207,20 @@ class UploadController( BaseUIController ):
|
||||
else:
|
||||
metadata_dict = {}
|
||||
if str( repository.type ) != rt_util.TOOL_DEPENDENCY_DEFINITION:
|
||||
# Provide a warning message if a tool_dependencies.xml file is provided, but tool dependencies weren't loaded due to a requirement tag mismatch
|
||||
# or some other problem. Tool dependency definitions can define orphan tool dependencies (no relationship to any tools contained in the repository),
|
||||
# so warning messages are important because orphans are always valid. The repository owner must be warned in case they did not intend to define an
|
||||
# orphan dependency, but simply provided incorrect information (tool shed, name owner, changeset_revision) for the definition.
|
||||
# Handle messaging for orphan tool dependencies.
|
||||
orphan_message = tool_dependency_util.generate_message_for_orphan_tool_dependencies( trans, repository, metadata_dict )
|
||||
if orphan_message:
|
||||
message += orphan_message
|
||||
change_repository_type_message = tool_dependency_util.generate_message_for_repository_type_change( trans, repository )
|
||||
if change_repository_type_message:
|
||||
message += change_repository_type_message
|
||||
status = 'warning'
|
||||
else:
|
||||
# Provide a warning message if a tool_dependencies.xml file is provided, but tool dependencies weren't loaded due to a requirement tag mismatch
|
||||
# or some other problem. Tool dependency definitions can define orphan tool dependencies (no relationship to any tools contained in the repository),
|
||||
# so warning messages are important because orphans are always valid. The repository owner must be warned in case they did not intend to define an
|
||||
# orphan dependency, but simply provided incorrect information (tool shed, name owner, changeset_revision) for the definition.
|
||||
# Handle messaging for orphan tool dependencies.
|
||||
orphan_message = tool_dependency_util.generate_message_for_orphan_tool_dependencies( trans, repository, metadata_dict )
|
||||
if orphan_message:
|
||||
message += orphan_message
|
||||
status = 'warning'
|
||||
# Handle messaging for invalid tool dependencies.
|
||||
invalid_tool_dependencies_message = tool_dependency_util.generate_message_for_invalid_tool_dependencies( metadata_dict )
|
||||
if invalid_tool_dependencies_message:
|
||||
|
||||
@@ -906,13 +906,13 @@ def generate_tool_dependency_metadata( app, repository, changeset_revision, repo
|
||||
repository_dependency_tups=invalid_repository_dependency_tups,
|
||||
is_valid=False,
|
||||
description=description )
|
||||
# We need to continue to restrict the behavior of orphan tool dependencies, possibly eliminating them altoghether at some point.
|
||||
# We need to continue to restrict the behavior for defining orphan tool dependencies, possibly eliminating them altoghether at some point.
|
||||
check_for_orphan_tool_dependencies = False
|
||||
if app.name == 'tool_shed':
|
||||
if repository.type == rt_util.UNRESTRICTED and 'tools' not in metadata_dict:
|
||||
check_for_orphan_tool_dependencies = True
|
||||
elif 'tools' in metadata_dict:
|
||||
if repository.type != rt_util.TOOL_DEPENDENCY_DEFINITION and not repository.can_change_type_to( app, rt_util.TOOL_DEPENDENCY_DEFINITION ):
|
||||
check_for_orphan_tool_dependencies = True
|
||||
elif 'tools' in metadata_dict:
|
||||
check_for_orphan_tool_dependencies = True
|
||||
if check_for_orphan_tool_dependencies:
|
||||
# Determine and store orphan tool dependencies.
|
||||
orphan_tool_dependencies = get_orphan_tool_dependencies( metadata_dict )
|
||||
|
||||
@@ -150,14 +150,17 @@ def generate_message_for_orphan_tool_dependencies( trans, repository, metadata_d
|
||||
version = requirements_dict[ 'version' ]
|
||||
message += "<b>* name:</b> %s, <b>type:</b> %s, <b>version:</b> %s<br/>" % ( str( name ), str( type ), str( version ) )
|
||||
message += "<br/>"
|
||||
elif repository.can_change_type_to( trans.app, rt_util.TOOL_DEPENDENCY_DEFINITION ):
|
||||
tool_dependency_definition_type_class = trans.app.repository_types_registry.get_class_by_label( rt_util.TOOL_DEPENDENCY_DEFINITION )
|
||||
message += "This repository currently contains a single file named <b>%s</b>. If additional files will " % suc.TOOL_DEPENDENCY_DEFINITION_FILENAME
|
||||
message += "not be added to this repository, then it's type should be set to <b>%s</b>.<br/>" % tool_dependency_definition_type_class.label
|
||||
else:
|
||||
message += "This repository contains no tools, so it's defined tool dependencies are considered orphans within this repository.<br/>"
|
||||
return message
|
||||
|
||||
def generate_message_for_repository_type_change( trans, repository ):
|
||||
message = ''
|
||||
if repository.can_change_type_to( trans.app, rt_util.TOOL_DEPENDENCY_DEFINITION ):
|
||||
tool_dependency_definition_type_class = trans.app.repository_types_registry.get_class_by_label( rt_util.TOOL_DEPENDENCY_DEFINITION )
|
||||
message += "This repository currently contains a single file named <b>%s</b>. If additional files will " % suc.TOOL_DEPENDENCY_DEFINITION_FILENAME
|
||||
message += "not be added to this repository, then it's type should be set to <b>%s</b>.<br/>" % tool_dependency_definition_type_class.label
|
||||
return message
|
||||
|
||||
|
||||
def get_download_url_for_platform( url_templates, platform_info_dict ):
|
||||
'''
|
||||
Compare the dict returned by get_platform_info() with the values specified in the url_template element. Return
|
||||
|
||||
@@ -54,7 +54,7 @@ class TestComplexRepositoryDependencies( ShedTwillTestCase ):
|
||||
strings_displayed=[ 'This repository currently contains a single file named <b>tool_dependencies.xml</b>' ],
|
||||
strings_not_displayed=[] )
|
||||
# Visit the manage repository page for package_bwa_0_5_9_0100.
|
||||
self.display_manage_repository_page( repository, strings_displayed=[ 'Tool dependencies', 'may not be', 'in this repository' ] )
|
||||
self.display_manage_repository_page( repository, strings_displayed=[ 'Tool dependencies', 'will not be', 'to this repository' ] )
|
||||
|
||||
def test_0010_create_bwa_base_repository( self ):
|
||||
'''Create and populate bwa_base_0100.'''
|
||||
|
||||
Reference in New Issue
Block a user