Hi all!

If you upload a tool with a tool_dependencies.xml file that does not fit
the <requirement> informations in the wrapper the developer will not be
informed about that error. Furthermore, the repository are updated and
the only hint a developer get is an empty or missing dependency field in
the toolshed.
In my opinion the developer should be informed that the specified
informations are wrong or insufficient and the upload should be aborted.

"Talk is cheap. Show me the code." - please see the attached patch.

Regards,
Björn
diff -r cc45bdf57b66 lib/galaxy/util/shed_util.py
--- a/lib/galaxy/util/shed_util.py	Fri Oct 12 17:22:51 2012 -0400
+++ b/lib/galaxy/util/shed_util.py	Sun Oct 14 15:39:41 2012 +0200
@@ -695,7 +695,7 @@
                                 element_tree_root = element_tree.getroot()
                                 is_tool = element_tree_root.tag == 'tool'
                             except Exception, e:
-                                print "Error parsing %s", full_path, ", exception: ", str( e )
+                                log.debug( "Error parsing %s, exception: %s" % ( full_path, str( e ) ))
                                 is_tool = False
                             if is_tool:
                                 tool, valid, error_message = load_tool_from_config( app, full_path )
@@ -793,6 +793,8 @@
             # Handle tool dependency installation via other means here (future).
         if tool_dependencies_dict:
             metadata_dict[ 'tool_dependencies' ] = tool_dependencies_dict
+    else:
+        log.debug( "Name, version and type from the <requirement> tag does not fit the information in the tool_dependencies.xml. Tools dependencies will be ignored." )
     if tool_dependencies_dict:
         if original_tool_dependencies_dict:
             # We're generating metadata on an update pulled to a tool shed repository installed into a Galaxy instance, so handle changes to
diff -r cc45bdf57b66 lib/galaxy/webapps/community/controllers/upload.py
--- a/lib/galaxy/webapps/community/controllers/upload.py	Fri Oct 12 17:22:51 2012 -0400
+++ b/lib/galaxy/webapps/community/controllers/upload.py	Sun Oct 14 15:39:41 2012 +0200
@@ -3,7 +3,7 @@
 from galaxy.model.orm import *
 from galaxy.datatypes.checkers import *
 from common import *
-from galaxy.util.shed_util import get_configured_ui, reset_tool_data_tables, handle_sample_tool_data_table_conf_file, update_repository
+from galaxy.util.shed_util import get_configured_ui, reset_tool_data_tables, handle_sample_tool_data_table_conf_file, update_repository, generate_tool_dependency_metadata
 
 from galaxy import eggs
 eggs.require('mercurial')
@@ -154,6 +154,31 @@
                     # See if the content of the change set was valid.
                     admin_only = len( repository.downloadable_revisions ) != 1
                     handle_email_alerts( trans, repository, content_alert_str=content_alert_str, new_repo_alert=new_repo_alert, admin_only=admin_only )
+
+                """
+                    Check for insufficient tool_dependencies.xml.
+                    If the name, version and type from the <requirement> tag does not fit the information 
+                    in tool_dependencies.xml, we inform the user and abort the current upload.
+                """
+                tool_dependencies_config = get_config_from_disk( 'tool_dependencies.xml', repo_dir )
+
+                if tool_dependencies_config:
+                    encoded_id = trans.security.encode_id( repository.id )
+                    repository_clone_url = generate_clone_url( trans, encoded_id )
+                    metadata_dict, invalid_file_tups = generate_metadata_for_changeset_revision(
+                            app=trans.app,
+                            repository=repository,
+                            repository_clone_url=repository_clone_url,
+                            relative_install_dir=repo_dir,
+                            repository_files_dir=None,
+                            resetting_all_metadata_on_repository=False,
+                            updating_installed_repository=False )
+                    tool_metadata = generate_tool_dependency_metadata( trans.app, repository, tool_dependencies_config, metadata_dict, original_repository_metadata=None )
+                    if 'tool_dependencies' not in tool_metadata:
+                        message += '"Name, version and type from the <requirement> tag does not fit the information in the tool_dependencies.xml."'
+                        ok = False
+                        # Rallback the repository and revert the current upload
+                        repo.rollback()
                 if ok:
                     # Update the repository files for browsing.
                     update_repository( repo )
___________________________________________________________
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:

  http://lists.bx.psu.edu/

Reply via email to