commit/galaxy-central: greg: Fix for viewing a tool shed repository README in a changeset revision older than the tip.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/00681c35d987/ changeset: 00681c35d987 user: greg date: 2012-10-02 17:36:20 summary: Fix for viewing a tool shed repository README in a changeset revision older than the tip. affected #: 3 files diff -r fb35591b0273945610917c178255674bba0f9a21 -r 00681c35d987cde2200ff94c7f5510c594c904fd lib/galaxy/util/shed_util.py --- a/lib/galaxy/util/shed_util.py +++ b/lib/galaxy/util/shed_util.py @@ -1043,15 +1043,6 @@ if name == config_file: return os.path.abspath( os.path.join( root, name ) ) return None -def get_config_from_repository( app, config_file, repository, changeset_revision, dir, install_dir=None ): - """Return config_filename if it exists in some changeset of the repository using only the repository and changeset_revision.""" - if install_dir is None: - install_dir = repository.repo_path( app ) - repo_files_dir = os.path.join( install_dir, repository.name ) - repo = hg.repository( get_configured_ui(), repo_files_dir ) - ctx = get_changectx_for_changeset( repo, changeset_revision ) - config = get_config( config_file, repo, ctx, dir ) - return config def get_configured_ui(): # Configure any desired ui settings. _ui = ui.ui() @@ -1140,6 +1131,13 @@ if deleted: return 'DELETED' return None +def get_file_from_changeset_revision( app, repository, repo_files_dir, changeset_revision, file_name, dir ): + """Return file_name from the received changeset_revision of the repository manifest.""" + stripped_file_name = strip_path( file_name ) + repo = hg.repository( get_configured_ui(), repo_files_dir ) + ctx = get_changectx_for_changeset( repo, changeset_revision ) + named_tmp_file = get_named_tmpfile_from_ctx( ctx, file_name, dir ) + return named_tmp_file def get_list_of_copied_sample_files( repo, ctx, dir ): """ Find all sample files (files in the repository with the special .sample extension) in the reversed repository manifest up to ctx. Copy diff -r fb35591b0273945610917c178255674bba0f9a21 -r 00681c35d987cde2200ff94c7f5510c594c904fd lib/galaxy/webapps/community/controllers/common.py --- a/lib/galaxy/webapps/community/controllers/common.py +++ b/lib/galaxy/webapps/community/controllers/common.py @@ -624,10 +624,7 @@ status = 'error' else: tool, message, sample_files = handle_sample_files_and_load_tool_from_tmp_config( trans, repo, changeset_revision, tool_config_filename, work_dir ) - try: - shutil.rmtree( work_dir ) - except: - pass + remove_dir( work_dir ) trans.app.config.tool_data_path = original_tool_data_path # Reset the tool_data_tables by loading the empty tool_data_table_conf.xml file. reset_tool_data_tables( trans.app ) @@ -685,6 +682,12 @@ return True # The received metadata_dict includes no metadata for workflows, so a new repository_metadata table record is not needed. return False +def remove_dir( dir ): + if os.path.exists( dir ): + try: + shutil.rmtree( dir ) + except: + pass def reset_all_metadata_on_repository( trans, id, **kwd ): def reset_all_tool_versions( trans, id, repo ): changeset_revisions = [] @@ -799,11 +802,7 @@ changeset_revisions.append( metadata_changeset_revision ) ancestor_changeset_revision = None ancestor_metadata_dict = None - if os.path.exists( work_dir ): - try: - shutil.rmtree( work_dir ) - except: - pass + remove_dir( work_dir ) # Delete all repository_metadata records for this repository that do not have a changeset_revision value in changeset_revisions. clean_repository_metadata( trans, id, changeset_revisions ) # Set tool version information for all downloadable changeset revisions. Get the list of changeset revisions from the changelog. diff -r fb35591b0273945610917c178255674bba0f9a21 -r 00681c35d987cde2200ff94c7f5510c594c904fd lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py +++ b/lib/galaxy/webapps/community/controllers/repository.py @@ -9,8 +9,8 @@ from galaxy.web.framework.helpers import time_ago, iff, grids from galaxy.util.json import from_json_string, to_json_string from galaxy.model.orm import * -from galaxy.util.shed_util import create_repo_info_dict, get_changectx_for_changeset, get_configured_ui, get_repository_file_contents -from galaxy.util.shed_util import get_repository_metadata_by_changeset_revision, handle_sample_files_and_load_tool_from_disk +from galaxy.util.shed_util import create_repo_info_dict, get_changectx_for_changeset, get_configured_ui, get_file_from_changeset_revision +from galaxy.util.shed_util import get_repository_file_contents, get_repository_metadata_by_changeset_revision, handle_sample_files_and_load_tool_from_disk from galaxy.util.shed_util import handle_sample_files_and_load_tool_from_tmp_config, INITIAL_CHANGELOG_HASH, load_tool_from_config, NOT_TOOL_CONFIGS from galaxy.util.shed_util import open_repository_files_folder, reversed_lower_upper_bounded_changelog, reversed_upper_bounded_changelog, strip_path from galaxy.util.shed_util import to_html_escaped, translate_string, update_repository, url_join @@ -2184,9 +2184,32 @@ repository_metadata = get_repository_metadata_by_changeset_revision( trans, trans.security.encode_id( repository.id ), changeset_revision ) metadata = repository_metadata.metadata if metadata and 'readme' in metadata: - f = open( metadata[ 'readme' ], 'r' ) - raw_text = f.read() - f.close() + readme_file = str( metadata[ 'readme' ] ) + repo_files_dir = repository.repo_path + try: + f = open( readme_file, 'r' ) + raw_text = f.read() + f.close() + except IOError: + work_dir = tempfile.mkdtemp() + try: + manifest_readme_file = get_file_from_changeset_revision( trans.app, + repository, + repo_files_dir, + changeset_revision, + readme_file, + work_dir ) + f = open( manifest_readme_file, 'r' ) + raw_text = f.read() + f.close() + remove_dir( work_dir ) + except Exception, e: + raw_text = "Error locating and reading this repository's README file '%s': %s" % ( readme_file, str( e ) ) + log.debug( raw_text ) + remove_dir( work_dir ) + except Exception, e: + raw_text = "Error locating and reading this repository's README file '%s': %s" % ( readme_file, str( e ) ) + log.debug( raw_text ) readme_text = translate_string( raw_text, to_html=True ) else: readme_text = '' 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)
-
Bitbucket