1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/6865031ea0c4/ Changeset: 6865031ea0c4 User: greg Date: 2013-10-25 17:06:28 Summary: Display an error message rather than raising an exception when a changeset being committed to a tool shed repository includes a dependency definition that has an invalid <repository> tag set. Affected #: 3 files diff -r d57971b60b8d907c33bf4dfc1bba2432baaf96e9 -r 6865031ea0c473984473e57100f60a3739065ca1 lib/galaxy/webapps/tool_shed/controllers/upload.py --- a/lib/galaxy/webapps/tool_shed/controllers/upload.py +++ b/lib/galaxy/webapps/tool_shed/controllers/upload.py @@ -135,8 +135,14 @@ # Move some version of the uploaded file to the load_point within the repository hierarchy. if uploaded_file_filename in [ suc.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME ]: # Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately. - altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name, unpopulate=False ) - if altered: + altered, root_elem, error_message = commit_util.handle_repository_dependencies_definition( trans, + uploaded_file_name, + unpopulate=False ) + if error_message: + ok = False + message = error_message + status = 'error' + elif altered: tmp_filename = xml_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, full_path ) else: @@ -152,26 +158,31 @@ shutil.move( uploaded_file_name, full_path ) else: shutil.move( uploaded_file_name, full_path ) - # See if any admin users have chosen to receive email alerts when a repository is updated. If so, check every uploaded file to ensure - # content is appropriate. - check_contents = commit_util.check_file_contents_for_email_alerts( trans ) - if check_contents and os.path.isfile( full_path ): - content_alert_str = commit_util.check_file_content_for_html_and_images( full_path ) - else: - content_alert_str = '' - commands.add( repo.ui, repo, full_path ) - # Convert from unicode to prevent "TypeError: array item must be char" - full_path = full_path.encode( 'ascii', 'replace' ) - commands.commit( repo.ui, repo, full_path, user=trans.user.username, message=commit_message ) - if full_path.endswith( 'tool_data_table_conf.xml.sample' ): - # Handle the special case where a tool_data_table_conf.xml.sample file is being uploaded by parsing the file and adding new entries - # to the in-memory trans.app.tool_data_tables dictionary. - error, error_message = tool_util.handle_sample_tool_data_table_conf_file( trans.app, full_path ) - if error: - message = '%s<br/>%s' % ( message, error_message ) - # See if the content of the change set was valid. - admin_only = len( repository.downloadable_revisions ) != 1 - suc.handle_email_alerts( trans, repository, content_alert_str=content_alert_str, new_repo_alert=new_repo_alert, admin_only=admin_only ) + if ok: + # See if any admin users have chosen to receive email alerts when a repository is updated. If so, check every uploaded file to ensure + # content is appropriate. + check_contents = commit_util.check_file_contents_for_email_alerts( trans ) + if check_contents and os.path.isfile( full_path ): + content_alert_str = commit_util.check_file_content_for_html_and_images( full_path ) + else: + content_alert_str = '' + commands.add( repo.ui, repo, full_path ) + # Convert from unicode to prevent "TypeError: array item must be char" + full_path = full_path.encode( 'ascii', 'replace' ) + commands.commit( repo.ui, repo, full_path, user=trans.user.username, message=commit_message ) + if full_path.endswith( 'tool_data_table_conf.xml.sample' ): + # Handle the special case where a tool_data_table_conf.xml.sample file is being uploaded by parsing the file and adding new entries + # to the in-memory trans.app.tool_data_tables dictionary. + error, error_message = tool_util.handle_sample_tool_data_table_conf_file( trans.app, full_path ) + if error: + message = '%s<br/>%s' % ( message, error_message ) + # See if the content of the change set was valid. + admin_only = len( repository.downloadable_revisions ) != 1 + suc.handle_email_alerts( trans, + repository, + content_alert_str=content_alert_str, + new_repo_alert=new_repo_alert, + admin_only=admin_only ) if ok: # Update the repository files for browsing. suc.update_repository( repo ) @@ -283,8 +294,12 @@ uploaded_file_name = os.path.abspath( os.path.join( root, uploaded_file ) ) if os.path.split( uploaded_file_name )[ -1 ] == suc.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME: # Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately. - altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name, unpopulate=False ) - if altered: + altered, root_elem, error_message = commit_util.handle_repository_dependencies_definition( trans, + uploaded_file_name, + unpopulate=False ) + if error_message: + return False, error_message, [], '', [], [] + elif altered: tmp_filename = xml_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, uploaded_file_name ) elif os.path.split( uploaded_file_name )[ -1 ] == suc.TOOL_DEPENDENCY_DEFINITION_FILENAME: @@ -344,8 +359,12 @@ uploaded_file_name = os.path.join( full_path, filename ) if os.path.split( uploaded_file_name )[ -1 ] == suc.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME: # Inspect the contents of the file to see if changeset_revision values are missing and if so, set them appropriately. - altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, uploaded_file_name, unpopulate=False ) - if altered: + altered, root_elem, error_message = commit_util.handle_repository_dependencies_definition( trans, + uploaded_file_name, + unpopulate=False ) + if error_message: + return False, error_message, [], '', [], [] + elif altered: tmp_filename = xml_util.create_and_write_tmp_file( root_elem ) shutil.move( tmp_filename, uploaded_file_name ) elif os.path.split( uploaded_file_name )[ -1 ] == suc.TOOL_DEPENDENCY_DEFINITION_FILENAME: diff -r d57971b60b8d907c33bf4dfc1bba2432baaf96e9 -r 6865031ea0c473984473e57100f60a3739065ca1 lib/tool_shed/util/commit_util.py --- a/lib/tool_shed/util/commit_util.py +++ b/lib/tool_shed/util/commit_util.py @@ -257,7 +257,7 @@ # Make sure we're looking at a valid repository_dependencies.xml file. tree, error_message = xml_util.parse_xml( repository_dependencies_config ) if tree is None: - return False, None + return False, None, error_message root = tree.getroot() if root.tag == 'repositories': for index, elem in enumerate( root ): @@ -265,14 +265,14 @@ # <repository name="molecule_datatypes" owner="test" changeset_revision="1a070566e9c6" /> revised, elem, error_message = handle_repository_dependency_elem( trans, elem, unpopulate=unpopulate ) if error_message: - exception_message = 'The repository_dependencies.xml file contains an invalid <repository> tag. %s' % error_message - raise Exception( exception_message ) + error_message = 'The repository_dependencies.xml file contains an invalid <repository> tag. %s' % error_message + return False, None, error_message if revised: root[ index ] = elem if not altered: altered = True - return altered, root - return False, None + return altered, root, error_message + return False, None, error_message def handle_repository_dependency_elem( trans, elem, unpopulate=False ): # <repository name="molecule_datatypes" owner="test" changeset_revision="1a070566e9c6" /> diff -r d57971b60b8d907c33bf4dfc1bba2432baaf96e9 -r 6865031ea0c473984473e57100f60a3739065ca1 lib/tool_shed/util/export_util.py --- a/lib/tool_shed/util/export_util.py +++ b/lib/tool_shed/util/export_util.py @@ -142,7 +142,9 @@ # See if we have a repository dependencies defined. if name == suc.REPOSITORY_DEPENDENCY_DEFINITION_FILENAME: # Eliminate the toolshed, and changeset_revision attributes from all <repository> tags. - altered, root_elem = commit_util.handle_repository_dependencies_definition( trans, full_path, unpopulate=True ) + altered, root_elem, error_message = commit_util.handle_repository_dependencies_definition( trans, full_path, unpopulate=True ) + if error_message: + return None, error_message if altered: tmp_filename = xml_util.create_and_write_tmp_file( root_elem, use_indent=True ) shutil.move( tmp_filename, full_path ) 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.