commit/galaxy-central: greg: Some code cleanup for setting metadata on tool shed repositories.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/0eaf1edd08e3/ Changeset: 0eaf1edd08e3 User: greg Date: 2014-07-21 19:38:43 Summary: Some code cleanup for setting metadata on tool shed repositories. Affected #: 11 files diff -r f8bf7a37c69469d3b4350e0d6b1965cc87dc7a49 -r 0eaf1edd08e3b79ebbbe68921baef2f94bb4804d lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py --- a/lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py +++ b/lib/galaxy/webapps/galaxy/api/tool_shed_repositories.py @@ -413,12 +413,12 @@ # Make sure the current user's API key proves he is an admin user in this Galaxy instance. if not trans.user_is_admin(): raise HTTPForbidden( detail='You are not authorized to reset metadata on repositories installed into this Galaxy instance.' ) - query = suc.get_query_for_setting_metadata_on_repositories( trans, my_writable=False, order=False ) + irmm = InstalledRepositoryMetadataManager( trans.app ) + query = irmm.get_query_for_setting_metadata_on_repositories( order=False ) # Now reset metadata on all remaining repositories. for repository in query: repository_id = trans.security.encode_id( repository.id ) try: - irmm = InstalledRepositoryMetadataManager( trans.app ) invalid_file_tups, metadata_dict = irmm.reset_all_metadata_on_installed_repository( repository_id ) if invalid_file_tups: message = tool_util.generate_message_for_invalid_tools( trans.app, diff -r f8bf7a37c69469d3b4350e0d6b1965cc87dc7a49 -r 0eaf1edd08e3b79ebbbe68921baef2f94bb4804d lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py --- a/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py +++ b/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py @@ -1708,13 +1708,13 @@ @web.expose @web.require_admin def reset_metadata_on_selected_installed_repositories( self, trans, **kwd ): + irmm = InstalledRepositoryMetadataManager( trans.app ) if 'reset_metadata_on_selected_repositories_button' in kwd: - irmm = InstalledRepositoryMetadataManager( trans.app ) message, status = irmm.reset_metadata_on_selected_repositories( trans.user, **kwd ) else: message = kwd.get( 'message', '' ) status = kwd.get( 'status', 'done' ) - repositories_select_field = suc.build_repository_ids_select_field( trans ) + repositories_select_field = irmm.build_repository_ids_select_field( trans ) return trans.fill_template( '/admin/tool_shed_repository/reset_metadata_on_selected_repositories.mako', repositories_select_field=repositories_select_field, message=message, diff -r f8bf7a37c69469d3b4350e0d6b1965cc87dc7a49 -r 0eaf1edd08e3b79ebbbe68921baef2f94bb4804d lib/galaxy/webapps/tool_shed/api/repositories.py --- a/lib/galaxy/webapps/tool_shed/api/repositories.py +++ b/lib/galaxy/webapps/tool_shed/api/repositories.py @@ -392,7 +392,8 @@ my_writable = True handled_repository_ids = [] repository_ids = [] - query = suc.get_query_for_setting_metadata_on_repositories( trans, my_writable=my_writable, order=False ) + rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app, trans.user ) + query = rmm.get_query_for_setting_metadata_on_repositories( my_writable=my_writable, order=False ) # Make sure repositories of type tool_dependency_definition are first in the list. for repository in query: if repository.type == rt_util.TOOL_DEPENDENCY_DEFINITION and repository.id not in handled_repository_ids: @@ -426,13 +427,12 @@ This param can be used as an alternative to the above encoded_ids_to_skip. """ - def handle_repository( trans, repository, results ): + def handle_repository( trans, rmm, repository, results ): log.debug( "Resetting metadata on repository %s" % str( repository.name ) ) repository_id = trans.security.encode_id( repository.id ) try: - rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app ) invalid_file_tups, metadata_dict = \ - rmm.reset_all_metadata_on_repository_in_tool_shed( trans.user, repository_id ) + rmm.reset_all_metadata_on_repository_in_tool_shed( repository_id ) if invalid_file_tups: message = tool_util.generate_message_for_invalid_tools( trans.app, invalid_file_tups, @@ -451,7 +451,7 @@ status = '%s : %s' % ( str( repository.name ), message ) results[ 'repository_status' ].append( status ) return results - + rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app, trans.user ) start_time = strftime( "%Y-%m-%d %H:%M:%S" ) results = dict( start_time=start_time, repository_status=[], @@ -473,7 +473,7 @@ my_writable = util.asbool( payload.get( 'my_writable', False ) ) else: my_writable = True - query = suc.get_query_for_setting_metadata_on_repositories( trans, my_writable=my_writable, order=False ) + query = rmm.get_query_for_setting_metadata_on_repositories( my_writable=my_writable, order=False ) # First reset metadata on all repositories of type repository_dependency_definition. for repository in query: encoded_id = trans.security.encode_id( repository.id ) @@ -481,7 +481,7 @@ log.debug( "Skipping repository with id %s because it is in encoded_ids_to_skip %s" % \ ( str( repository.id ), str( encoded_ids_to_skip ) ) ) elif repository.type == rt_util.TOOL_DEPENDENCY_DEFINITION and repository.id not in handled_repository_ids: - results = handle_repository( trans, repository, results ) + results = handle_repository( trans, rmm, repository, results ) # Now reset metadata on all remaining repositories. for repository in query: encoded_id = trans.security.encode_id( repository.id ) @@ -489,7 +489,7 @@ log.debug( "Skipping repository with id %s because it is in encoded_ids_to_skip %s" % \ ( str( repository.id ), str( encoded_ids_to_skip ) ) ) elif repository.type != rt_util.TOOL_DEPENDENCY_DEFINITION and repository.id not in handled_repository_ids: - results = handle_repository( trans, repository, results ) + results = handle_repository( trans, rmm, repository, results ) stop_time = strftime( "%Y-%m-%d %H:%M:%S" ) results[ 'stop_time' ] = stop_time return json.dumps( results, sort_keys=True, indent=4 ) @@ -511,10 +511,9 @@ results = dict( start_time=start_time, repository_status=[] ) try: - rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app ) + rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app, trans.user ) invalid_file_tups, metadata_dict = \ - rmm.reset_all_metadata_on_repository_in_tool_shed( trans.user, - trans.security.encode_id( repository.id ) ) + rmm.reset_all_metadata_on_repository_in_tool_shed( trans.security.encode_id( repository.id ) ) if invalid_file_tups: message = tool_util.generate_message_for_invalid_tools( trans.app, invalid_file_tups, diff -r f8bf7a37c69469d3b4350e0d6b1965cc87dc7a49 -r 0eaf1edd08e3b79ebbbe68921baef2f94bb4804d lib/galaxy/webapps/tool_shed/controllers/admin.py --- a/lib/galaxy/webapps/tool_shed/controllers/admin.py +++ b/lib/galaxy/webapps/tool_shed/controllers/admin.py @@ -348,13 +348,16 @@ @web.expose @web.require_admin def reset_metadata_on_selected_repositories_in_tool_shed( self, trans, **kwd ): + rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app, trans.user ) if 'reset_metadata_on_selected_repositories_button' in kwd: - rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app ) - message, status = rmm.reset_metadata_on_selected_repositories( trans.user, **kwd ) + message, status = rmm.reset_metadata_on_selected_repositories( **kwd ) else: message = util.restore_text( kwd.get( 'message', '' ) ) status = kwd.get( 'status', 'done' ) - repositories_select_field = suc.build_repository_ids_select_field( trans ) + repositories_select_field = rmm.build_repository_ids_select_field( name='repository_ids', + multiple=True, + display='checkboxes', + my_writable=False ) return trans.fill_template( '/webapps/tool_shed/common/reset_metadata_on_selected_repositories.mako', repositories_select_field=repositories_select_field, message=message, diff -r f8bf7a37c69469d3b4350e0d6b1965cc87dc7a49 -r 0eaf1edd08e3b79ebbbe68921baef2f94bb4804d lib/galaxy/webapps/tool_shed/controllers/hg.py --- a/lib/galaxy/webapps/tool_shed/controllers/hg.py +++ b/lib/galaxy/webapps/tool_shed/controllers/hg.py @@ -48,8 +48,8 @@ repo = hg.repository( ui.ui(), repository.repo_path( trans.app ) ) update_repository( repo, ctx_rev=None ) # Set metadata using the repository files on disk. - rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app ) - error_message, status = rmm.set_repository_metadata( trans.request.host, trans.user, repository ) + rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app, trans.user ) + error_message, status = rmm.set_repository_metadata( trans.request.host, repository ) if status == 'ok' and error_message: log.debug( "Successfully reset metadata on repository %s owned by %s, but encountered problem: %s" % \ ( str( repository.name ), str( repository.user.username ), error_message ) ) diff -r f8bf7a37c69469d3b4350e0d6b1965cc87dc7a49 -r 0eaf1edd08e3b79ebbbe68921baef2f94bb4804d lib/galaxy/webapps/tool_shed/controllers/repository.py --- a/lib/galaxy/webapps/tool_shed/controllers/repository.py +++ b/lib/galaxy/webapps/tool_shed/controllers/repository.py @@ -2753,9 +2753,9 @@ def reset_all_metadata( self, trans, id, **kwd ): """Reset all metadata on the complete changelog for a single repository in the tool shed.""" # This method is called only from the ~/templates/webapps/tool_shed/repository/manage_repository.mako template. - rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app ) + rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app, trans.user ) invalid_file_tups, metadata_dict = \ - rmm.reset_all_metadata_on_repository_in_tool_shed( trans.user, id, **kwd ) + rmm.reset_all_metadata_on_repository_in_tool_shed( id, **kwd ) if invalid_file_tups: repository = suc.get_repository_in_tool_shed( trans.app, id ) message = tool_util.generate_message_for_invalid_tools( trans.app, @@ -2774,13 +2774,16 @@ @web.expose def reset_metadata_on_my_writable_repositories_in_tool_shed( self, trans, **kwd ): + rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app, trans.user ) if 'reset_metadata_on_selected_repositories_button' in kwd: - rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app ) - message, status = rmm.reset_metadata_on_selected_repositories( trans.user, **kwd ) + message, status = rmm.reset_metadata_on_selected_repositories( **kwd ) else: message = kwd.get( 'message', '' ) status = kwd.get( 'status', 'done' ) - repositories_select_field = suc.build_repository_ids_select_field( trans, my_writable=True ) + repositories_select_field = rmm.build_repository_ids_select_field( name='repository_ids', + multiple=True, + display='checkboxes', + my_writable=True ) return trans.fill_template( '/webapps/tool_shed/common/reset_metadata_on_selected_repositories.mako', repositories_select_field=repositories_select_field, message=message, @@ -2840,9 +2843,8 @@ if tip == repository.tip( trans.app ): message += 'No changes to repository. ' else: - rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app ) + rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app, trans.user ) status, error_message = rmm.set_repository_metadata_due_to_new_tip( trans.request.host, - trans.user, repository, **kwd ) if error_message: diff -r f8bf7a37c69469d3b4350e0d6b1965cc87dc7a49 -r 0eaf1edd08e3b79ebbbe68921baef2f94bb4804d 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 @@ -262,10 +262,9 @@ ( len( files_to_remove ), upload_point ) else: message += " %d files were removed from the repository root. " % len( files_to_remove ) - rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app ) + rmm = repository_metadata_manager.RepositoryMetadataManager( trans.app, trans.user ) status, error_message = \ rmm.set_repository_metadata_due_to_new_tip( trans.request.host, - trans.user, repository, content_alert_str=content_alert_str, **kwd ) diff -r f8bf7a37c69469d3b4350e0d6b1965cc87dc7a49 -r 0eaf1edd08e3b79ebbbe68921baef2f94bb4804d lib/tool_shed/capsule/capsule_manager.py --- a/lib/tool_shed/capsule/capsule_manager.py +++ b/lib/tool_shed/capsule/capsule_manager.py @@ -727,9 +727,8 @@ results_dict[ 'ok' ] = False results_dict[ 'error_message' ] += error_message try: - rmm = repository_metadata_manager.RepositoryMetadataManager( self.app ) + rmm = repository_metadata_manager.RepositoryMetadataManager( self.app, self.user ) status, error_message = rmm.set_repository_metadata_due_to_new_tip( self.host, - self.user, repository, content_alert_str=content_alert_str ) if error_message: diff -r f8bf7a37c69469d3b4350e0d6b1965cc87dc7a49 -r 0eaf1edd08e3b79ebbbe68921baef2f94bb4804d lib/tool_shed/galaxy_install/metadata/installed_repository_metadata_manager.py --- a/lib/tool_shed/galaxy_install/metadata/installed_repository_metadata_manager.py +++ b/lib/tool_shed/galaxy_install/metadata/installed_repository_metadata_manager.py @@ -3,6 +3,7 @@ from galaxy import util from galaxy.util import inflector +from galaxy.web.form_builder import SelectField from tool_shed.metadata import metadata_generator @@ -19,6 +20,32 @@ super( InstalledRepositoryMetadataManager, self ).__init__( app ) self.app = app + def build_repository_ids_select_field( self, name='repository_ids', multiple=True, display='checkboxes' ): + """Generate the current list of repositories for resetting metadata.""" + repositories_select_field = SelectField( name=name, multiple=multiple, display=display ) + query = self.get_query_for_setting_metadata_on_repositories( order=True ) + for repository in query: + owner = str( repository.owner ) + option_label = '%s (%s)' % ( str( repository.name ), owner ) + option_value = '%s' % self.app.security.encode_id( repository.id ) + repositories_select_field.add_option( option_label, option_value ) + return repositories_select_field + + def get_query_for_setting_metadata_on_repositories( self, order=True ): + """ + Return a query containing repositories for resetting metadata. The order parameter + is used for displaying the list of repositories ordered alphabetically for display on + a page. When called from the Galaxy API, order is False. + """ + if order: + return self.app.install_model.context.query( self.app.install_model.ToolShedRepository ) \ + .filter( self.app.install_model.ToolShedRepository.table.c.uninstalled == False ) \ + .order_by( self.app.install_model.ToolShedRepository.table.c.name, + self.app.install_model.ToolShedRepository.table.c.owner ) + else: + return self.app.install_model.context.query( self.app.install_model.ToolShedRepository ) \ + .filter( self.app.install_model.ToolShedRepository.table.c.uninstalled == False ) + def reset_all_metadata_on_installed_repository( self, id ): """Reset all metadata on a single tool shed repository installed into a Galaxy instance.""" invalid_file_tups = [] diff -r f8bf7a37c69469d3b4350e0d6b1965cc87dc7a49 -r 0eaf1edd08e3b79ebbbe68921baef2f94bb4804d lib/tool_shed/metadata/repository_metadata_manager.py --- a/lib/tool_shed/metadata/repository_metadata_manager.py +++ b/lib/tool_shed/metadata/repository_metadata_manager.py @@ -2,11 +2,13 @@ import os import tempfile +from galaxy import util from galaxy.util import inflector -from galaxy import util +from galaxy.web.form_builder import SelectField from tool_shed.metadata import metadata_generator from tool_shed.repository_types.metadata import TipOnly +from tool_shed.repository_types import util as rt_util from tool_shed.util import basic_util from tool_shed.util import common_util @@ -20,9 +22,10 @@ class RepositoryMetadataManager( metadata_generator.MetadataGenerator ): - def __init__( self, app ): + def __init__( self, app, user ): super( RepositoryMetadataManager, self ).__init__( app ) self.app = app + self.user = user # Repository metadata comparisons for changeset revisions. self.EQUAL = 'equal' self.NO_METADATA = 'no metadata' @@ -47,6 +50,18 @@ self.sa_session.add( repository_metadata ) self.sa_session.flush() + def build_repository_ids_select_field( self, name='repository_ids', multiple=True, display='checkboxes', + my_writable=False ): + """Generate the current list of repositories for resetting metadata.""" + repositories_select_field = SelectField( name=name, multiple=multiple, display=display ) + query = self.get_query_for_setting_metadata_on_repositories( my_writable=my_writable, order=True ) + for repository in query: + owner = str( repository.user.username ) + option_label = '%s (%s)' % ( str( repository.name ), owner ) + option_value = '%s' % self.app.security.encode_id( repository.id ) + repositories_select_field.add_option( option_label, option_value ) + return repositories_select_field + def clean_repository_metadata( self, id, changeset_revisions ): # Delete all repository_metadata records associated with the repository that have # a changeset_revision that is not in changeset_revisions. We sometimes see multiple @@ -458,6 +473,54 @@ # The tool did not change through all of the changeset revisions. return old_id + def get_query_for_setting_metadata_on_repositories( self, my_writable=False, order=True ): + """ + Return a query containing repositories for resetting metadata. The order parameter + is used for displaying the list of repositories ordered alphabetically for display on + a page. When called from the Tool Shed API, order is False. + """ + # When called from the Tool Shed API, the metadata is reset on all repositories of types + # repository_suite_definition and tool_dependency_definition in addition to other selected + # repositories. + if my_writable: + username = self.user.username + clause_list = [] + for repository in self.sa_session.query( self.app.model.Repository ) \ + .filter( self.app.model.Repository.table.c.deleted == False ): + # Always reset metadata on all repositories of types repository_suite_definition and + # tool_dependency_definition. + if repository.type in [ rt_util.REPOSITORY_SUITE_DEFINITION, rt_util.TOOL_DEPENDENCY_DEFINITION ]: + clause_list.append( self.app.model.Repository.table.c.id == repository.id ) + else: + allow_push = repository.allow_push( self.app ) + if allow_push: + # Include all repositories that are writable by the current user. + allow_push_usernames = allow_push.split( ',' ) + if username in allow_push_usernames: + clause_list.append( self.app.model.Repository.table.c.id == repository.id ) + if clause_list: + if order: + return self.sa_session.query( self.app.model.Repository ) \ + .filter( or_( *clause_list ) ) \ + .order_by( self.app.model.Repository.table.c.name, + self.app.model.Repository.table.c.user_id ) + else: + return self.sa_session.query( self.app.model.Repository ) \ + .filter( or_( *clause_list ) ) + else: + # Return an empty query. + return self.sa_session.query( self.app.model.Repository ) \ + .filter( self.app.model.Repository.table.c.id == -1 ) + else: + if order: + return self.sa_session.query( self.app.model.Repository ) \ + .filter( self.app.model.Repository.table.c.deleted == False ) \ + .order_by( self.app.model.Repository.table.c.name, + self.app.model.Repository.table.c.user_id ) + else: + return self.sa_session.query( self.app.model.Repository ) \ + .filter( self.app.model.Repository.table.c.deleted == False ) + def new_datatypes_metadata_required( self, repository_metadata, metadata_dict ): """ Compare the last saved metadata for each datatype in the repository with the new metadata @@ -732,13 +795,13 @@ # repository_metadata table record is not needed. return False - def reset_all_metadata_on_repository_in_tool_shed( self, user, id ): + def reset_all_metadata_on_repository_in_tool_shed( self, id ): """Reset all metadata on a single repository in a tool shed.""" repository = suc.get_repository_in_tool_shed( self.app, id ) log.debug( "Resetting all metadata on repository: %s" % repository.name ) repo_dir = repository.repo_path( self.app ) repo = hg_util.get_repo_for_repository( self.app, repository=None, repo_path=repo_dir, create=False ) - repository_clone_url = common_util.generate_clone_url_for_repository_in_tool_shed( user, repository ) + repository_clone_url = common_util.generate_clone_url_for_repository_in_tool_shed( self.user, repository ) # The list of changeset_revisions refers to repository_metadata records that have been created # or updated. When the following loop completes, we'll delete all repository_metadata records # for this repository that do not have a changeset_revision value in this list. @@ -875,7 +938,7 @@ self.sa_session.add( repository_metadata ) self.sa_session.flush() - def reset_metadata_on_selected_repositories( self, user, **kwd ): + def reset_metadata_on_selected_repositories( self, **kwd ): """ Inspect the repository changelog to reset metadata for all appropriate changeset revisions. This method is called from both Galaxy and the Tool Shed. @@ -892,7 +955,7 @@ repository = suc.get_repository_in_tool_shed( self.app, repository_id ) owner = str( repository.user.username ) invalid_file_tups, metadata_dict = \ - self.reset_all_metadata_on_repository_in_tool_shed( user, repository_id ) + self.reset_all_metadata_on_repository_in_tool_shed( self.user, repository_id ) if invalid_file_tups: message = tool_util.generate_message_for_invalid_tools( self.app, invalid_file_tups, @@ -918,7 +981,7 @@ status = 'error' return message, status - def set_repository_metadata( self, host, user, repository, content_alert_str='', **kwd ): + def set_repository_metadata( self, host, repository, content_alert_str='', **kwd ): """ Set metadata using the repository's current disk files, returning specific error messages (if any) to alert the repository owner that the changeset has problems. @@ -926,7 +989,7 @@ message = '' status = 'done' encoded_id = self.app.security.encode_id( repository.id ) - repository_clone_url = common_util.generate_clone_url_for_repository_in_tool_shed( user, repository ) + repository_clone_url = common_util.generate_clone_url_for_repository_in_tool_shed( self.user, repository ) repo_dir = repository.repo_path( self.app ) repo = hg_util.get_repo_for_repository( self.app, repository=None, repo_path=repo_dir, create=False ) metadata_dict, invalid_file_tups = \ @@ -1027,10 +1090,9 @@ tool_util.reset_tool_data_tables( self.app ) return message, status - def set_repository_metadata_due_to_new_tip( self, host, user, repository, content_alert_str=None, **kwd ): + def set_repository_metadata_due_to_new_tip( self, host, repository, content_alert_str=None, **kwd ): """Set metadata on the repository tip in the tool shed.""" error_message, status = self.set_repository_metadata( host, - user, repository, content_alert_str=content_alert_str, **kwd ) diff -r f8bf7a37c69469d3b4350e0d6b1965cc87dc7a49 -r 0eaf1edd08e3b79ebbbe68921baef2f94bb4804d lib/tool_shed/util/shed_util_common.py --- a/lib/tool_shed/util/shed_util_common.py +++ b/lib/tool_shed/util/shed_util_common.py @@ -84,20 +84,6 @@ '${host}' """ -def build_repository_ids_select_field( trans, name='repository_ids', multiple=True, display='checkboxes', my_writable=False ): - """Method called from both Galaxy and the Tool Shed to generate the current list of repositories for resetting metadata.""" - repositories_select_field = SelectField( name=name, multiple=multiple, display=display ) - query = get_query_for_setting_metadata_on_repositories( trans, my_writable=my_writable, order=True ) - for repository in query: - if trans.webapp.name == 'tool_shed': - owner = str( repository.user.username ) - else: - owner = str( repository.owner ) - option_label = '%s (%s)' % ( str( repository.name ), owner ) - option_value = '%s' % trans.security.encode_id( repository.id ) - repositories_select_field.add_option( option_label, option_value ) - return repositories_select_field - def build_tool_dependencies_select_field( app, tool_shed_repository, name, multiple=True, display='checkboxes', uninstalled_only=False ): """Method called from Galaxy to generate the current list of tool dependency ids for an installed tool shed repository.""" tool_dependencies_select_field = SelectField( name=name, multiple=multiple, display=display ) @@ -645,66 +631,6 @@ prior_import_or_install_required_dict[ encoded_repository_id ] = prior_import_or_install_ids return prior_import_or_install_required_dict -def get_query_for_setting_metadata_on_repositories( trans, my_writable=False, order=True ): - """ - Return a query containing repositories for resetting metadata. This method is called from both the - Tool Shed and Galaxy. The my_writable parameter is ignored unless called from the Tool Shed, and the - order parameter is used for displaying the list of repositories ordered alphabetically for display on - a page. When called from either the Tool Shed or Galaxy API, order is False. - """ - if trans.webapp.name == 'tool_shed': - # When called from the Tool Shed API, the metadata is reset on all repositories of types - # repository_suite_definition and tool_dependency_definition in addition to other selected - # repositories. - if my_writable: - username = trans.user.username - clause_list = [] - for repository in trans.sa_session.query( trans.model.Repository ) \ - .filter( trans.model.Repository.table.c.deleted == False ): - # Always reset metadata on all repositories of types repository_suite_definition and - # tool_dependency_definition. - if repository.type in [ rt_util.REPOSITORY_SUITE_DEFINITION, rt_util.TOOL_DEPENDENCY_DEFINITION ]: - clause_list.append( trans.model.Repository.table.c.id == repository.id ) - else: - allow_push = repository.allow_push( trans.app ) - if allow_push: - # Include all repositories that are writable by the current user. - allow_push_usernames = allow_push.split( ',' ) - if username in allow_push_usernames: - clause_list.append( trans.model.Repository.table.c.id == repository.id ) - if clause_list: - if order: - return trans.sa_session.query( trans.model.Repository ) \ - .filter( or_( *clause_list ) ) \ - .order_by( trans.model.Repository.table.c.name, - trans.model.Repository.table.c.user_id ) - else: - return trans.sa_session.query( trans.model.Repository ) \ - .filter( or_( *clause_list ) ) - else: - # Return an empty query. - return trans.sa_session.query( trans.model.Repository ) \ - .filter( trans.model.Repository.table.c.id == -1 ) - else: - if order: - return trans.sa_session.query( trans.model.Repository ) \ - .filter( trans.model.Repository.table.c.deleted == False ) \ - .order_by( trans.model.Repository.table.c.name, - trans.model.Repository.table.c.user_id ) - else: - return trans.sa_session.query( trans.model.Repository ) \ - .filter( trans.model.Repository.table.c.deleted == False ) - else: - # We're in Galaxy. - if order: - return trans.install_model.context.query( trans.install_model.ToolShedRepository ) \ - .filter( trans.install_model.ToolShedRepository.table.c.uninstalled == False ) \ - .order_by( trans.install_model.ToolShedRepository.table.c.name, - trans.install_model.ToolShedRepository.table.c.owner ) - else: - return trans.install_model.context.query( trans.install_model.ToolShedRepository ) \ - .filter( trans.install_model.ToolShedRepository.table.c.uninstalled == False ) - def get_repo_info_tuple_contents( repo_info_tuple ): """Take care in handling the repo_info_tuple as it evolves over time as new tool shed features are introduced.""" if len( repo_info_tuple ) == 6: 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