commit/galaxy-central: greg: A bit of repository dependency function re-factoring for Galaxy installs.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/f5589d243d0f/ Changeset: f5589d243d0f User: greg Date: 2014-06-23 02:31:19 Summary: A bit of repository dependency function re-factoring for Galaxy installs. Affected #: 4 files diff -r 344e84a6554ae94604f32e8f62feebd65a6ac358 -r f5589d243d0f920cdd96c3e980762bb1a7cc061b 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 @@ -1359,9 +1359,8 @@ else: # Entering this else block occurs only if the tool_shed_repository does not include any valid tools. if install_repository_dependencies: - repository_dependencies = \ - repository_dependency_util.get_repository_dependencies_for_installed_tool_shed_repository( trans.app, - tool_shed_repository ) + repository_dependencies = rdm.get_repository_dependencies_for_installed_tool_shed_repository( trans.app, + tool_shed_repository ) else: repository_dependencies = None if metadata: @@ -1579,9 +1578,9 @@ raw_text = common_util.tool_shed_get( trans.app, tool_shed_url, url ) readme_files_dict = json.from_json_string( raw_text ) tool_dependencies = metadata.get( 'tool_dependencies', None ) - repository_dependencies = \ - repository_dependency_util.get_repository_dependencies_for_installed_tool_shed_repository( trans.app, - tool_shed_repository ) + rdm = RepositoryDependencyManager( trans.app ) + repository_dependencies = rdm.get_repository_dependencies_for_installed_tool_shed_repository( trans.app, + tool_shed_repository ) repo_info_dict = \ repository_maintenance_util.create_repo_info_dict( app=trans.app, repository_clone_url=repository_clone_url, diff -r 344e84a6554ae94604f32e8f62feebd65a6ac358 -r f5589d243d0f920cdd96c3e980762bb1a7cc061b lib/tool_shed/galaxy_install/repair_repository_manager.py --- a/lib/tool_shed/galaxy_install/repair_repository_manager.py +++ b/lib/tool_shed/galaxy_install/repair_repository_manager.py @@ -4,6 +4,7 @@ log = logging.getLogger( __name__ ) from tool_shed.galaxy_install import install_manager +from tool_shed.galaxy_install.repository_dependencies.repository_dependency_manager import RepositoryDependencyManager from tool_shed.util import common_util from tool_shed.util import container_util @@ -55,6 +56,7 @@ issues with an installed repository that has installation problems somewhere in its dependency hierarchy. """ + rdm = RepositoryDependencyManager( self.app ) tsr_ids = [] repo_info_dicts = [] tool_panel_section_keys = [] @@ -62,8 +64,8 @@ irm = install_manager.InstallRepositoryManager( self.app ) # Get a dictionary of all repositories upon which the contents of the current repository_metadata #record depend. - repository_dependencies_dict = \ - repository_dependency_util.get_repository_dependencies_for_installed_tool_shed_repository( self.app, repository ) + repository_dependencies_dict = rdm.get_repository_dependencies_for_installed_tool_shed_repository( self.app, + repository ) if repository_dependencies_dict: # Generate the list of installed repositories from the information contained in the # repository_dependencies dictionary. @@ -73,13 +75,15 @@ # repaired in the required order. for installed_repository in installed_repositories: tsr_ids.append( self.app.security.encode_id( installed_repository.id ) ) - repo_info_dict, tool_panel_section_key = self.get_repo_info_dict_for_repair( installed_repository ) + repo_info_dict, tool_panel_section_key = self.get_repo_info_dict_for_repair( rdm, + installed_repository ) tool_panel_section_keys.append( tool_panel_section_key ) repo_info_dicts.append( repo_info_dict ) else: # The received repository has no repository dependencies. tsr_ids.append( self.app.security.encode_id( repository.id ) ) - repo_info_dict, tool_panel_section_key = self.get_repo_info_dict_for_repair( repository ) + repo_info_dict, tool_panel_section_key = self.get_repo_info_dict_for_repair( rdm, + repository ) tool_panel_section_keys.append( tool_panel_section_key ) repo_info_dicts.append( repo_info_dict ) ordered_tsr_ids, ordered_repo_info_dicts, ordered_tool_panel_section_keys = \ @@ -91,11 +95,11 @@ repair_dict[ 'ordered_tool_panel_section_keys' ] = ordered_tool_panel_section_keys return repair_dict - def get_repo_info_dict_for_repair( self, repository ): + def get_repo_info_dict_for_repair( self, rdm, repository ): tool_panel_section_key = None repository_clone_url = common_util.generate_clone_url_for_installed_repository( self.app, repository ) - repository_dependencies = \ - repository_dependency_util.get_repository_dependencies_for_installed_tool_shed_repository( self.app, repository ) + repository_dependencies = rdm.get_repository_dependencies_for_installed_tool_shed_repository( self.app, + repository ) metadata = repository.metadata if metadata: tool_dependencies = metadata.get( 'tool_dependencies', None ) diff -r 344e84a6554ae94604f32e8f62feebd65a6ac358 -r f5589d243d0f920cdd96c3e980762bb1a7cc061b lib/tool_shed/galaxy_install/repository_dependencies/repository_dependency_manager.py --- a/lib/tool_shed/galaxy_install/repository_dependencies/repository_dependency_manager.py +++ b/lib/tool_shed/galaxy_install/repository_dependencies/repository_dependency_manager.py @@ -255,6 +255,29 @@ self.build_repository_dependency_relationships( all_repo_info_dicts, all_created_or_updated_tool_shed_repositories ) return created_or_updated_tool_shed_repositories, tool_panel_section_keys, all_repo_info_dicts, filtered_repo_info_dicts + def get_repository_dependencies_for_installed_tool_shed_repository( self, app, repository ): + """ + Send a request to the appropriate tool shed to retrieve the dictionary of repository dependencies defined + for the received repository which is installed into Galaxy. This method is called only from Galaxy. + """ + tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry( app, str( repository.tool_shed ) ) + params = '?name=%s&owner=%s&changeset_revision=%s' % ( str( repository.name ), + str( repository.owner ), + str( repository.changeset_revision ) ) + url = common_util.url_join( tool_shed_url, + 'repository/get_repository_dependencies%s' % params ) + try: + raw_text = common_util.tool_shed_get( app, tool_shed_url, url ) + except Exception, e: + print "The URL\n%s\nraised the exception:\n%s\n" % ( url, str( e ) ) + return '' + if len( raw_text ) > 2: + encoded_text = json.loads( raw_text ) + text = encoding_util.tool_shed_decode( encoded_text ) + else: + text = '' + return text + def get_repository_dependency_by_repository_id( self, install_model, decoded_repository_id ): return install_model.context.query( install_model.RepositoryDependency ) \ .filter( install_model.RepositoryDependency.table.c.tool_shed_repository_id == decoded_repository_id ) \ diff -r 344e84a6554ae94604f32e8f62feebd65a6ac358 -r f5589d243d0f920cdd96c3e980762bb1a7cc061b 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 @@ -147,29 +147,6 @@ prior_installation_required, only_if_compiling_contained_td ) -def get_repository_dependencies_for_installed_tool_shed_repository( app, repository ): - """ - Send a request to the appropriate tool shed to retrieve the dictionary of repository dependencies defined - for the received repository which is installed into Galaxy. This method is called only from Galaxy. - """ - tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry( app, str( repository.tool_shed ) ) - params = '?name=%s&owner=%s&changeset_revision=%s' % ( str( repository.name ), - str( repository.owner ), - str( repository.changeset_revision ) ) - url = common_util.url_join( tool_shed_url, - 'repository/get_repository_dependencies%s' % params ) - try: - raw_text = common_util.tool_shed_get( app, tool_shed_url, url ) - except Exception, e: - print "The URL\n%s\nraised the exception:\n%s\n" % ( url, str( e ) ) - return '' - if len( raw_text ) > 2: - encoded_text = json.loads( raw_text ) - text = encoding_util.tool_shed_decode( encoded_text ) - else: - text = '' - return text - def get_repository_dependencies_for_changeset_revision( app, repository, repository_metadata, toolshed_base_url, key_rd_dicts_to_be_processed=None, all_repository_dependencies=None, handled_key_rd_dicts=None, circular_repository_dependencies=None ): 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