1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/27a3c2f3fc20/ Changeset: 27a3c2f3fc20 User: greg Date: 2013-09-24 23:09:14 Summary: Fix for rendering readme files in a repository that are no longer available on the file system since they are contained in an installable revision that is not the latest one in the changelog. Affected #: 10 files diff -r 22cfae4b6a227c385146d5d71c49a663809244e8 -r 27a3c2f3fc200ef80f07a5b940aa5ac50ad10320 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 @@ -38,7 +38,7 @@ import tool_shed.repository_types.util as rt_util from galaxy import eggs -eggs.require('mercurial') +eggs.require( 'mercurial' ) from mercurial import commands from mercurial import hg @@ -1594,7 +1594,7 @@ if repository_metadata: metadata = repository_metadata.metadata if metadata: - return readme_util.build_readme_files_dict( repository_metadata.metadata ) + return readme_util.build_readme_files_dict( trans, repository, changeset_revision, repository_metadata.metadata ) return {} @web.json @@ -1793,7 +1793,7 @@ break if 'workflows' in metadata: includes_workflows = True - readme_files_dict = readme_util.build_readme_files_dict( metadata ) + readme_files_dict = readme_util.build_readme_files_dict( trans, repository, changeset_revision, metadata ) # See if the repo_info_dict was populated with repository_dependencies or tool_dependencies. has_repository_dependencies = False has_repository_dependencies_only_if_compiling_contained_td = False diff -r 22cfae4b6a227c385146d5d71c49a663809244e8 -r 27a3c2f3fc200ef80f07a5b940aa5ac50ad10320 lib/tool_shed/galaxy_install/repository_util.py --- a/lib/tool_shed/galaxy_install/repository_util.py +++ b/lib/tool_shed/galaxy_install/repository_util.py @@ -22,9 +22,8 @@ from xml.etree import ElementTree as XmlET from galaxy import eggs -import pkg_resources +eggs.require( 'mercurial' ) -pkg_resources.require( 'mercurial' ) from mercurial import commands from mercurial import hg from mercurial import ui diff -r 22cfae4b6a227c385146d5d71c49a663809244e8 -r 27a3c2f3fc200ef80f07a5b940aa5ac50ad10320 lib/tool_shed/util/container_util.py --- a/lib/tool_shed/util/container_util.py +++ b/lib/tool_shed/util/container_util.py @@ -788,7 +788,7 @@ # Readme files container. if metadata: if 'readme_files' not in exclude and 'readme_files' in metadata: - readme_files_dict = readme_util.build_readme_files_dict( metadata ) + readme_files_dict = readme_util.build_readme_files_dict( trans, repository, changeset_revision, metadata ) folder_id, readme_files_root_folder = build_readme_files_folder( trans, folder_id, readme_files_dict ) containers_dict[ 'readme_files' ] = readme_files_root_folder if 'repository_dependencies' not in exclude: diff -r 22cfae4b6a227c385146d5d71c49a663809244e8 -r 27a3c2f3fc200ef80f07a5b940aa5ac50ad10320 lib/tool_shed/util/metadata_util.py --- a/lib/tool_shed/util/metadata_util.py +++ b/lib/tool_shed/util/metadata_util.py @@ -23,9 +23,8 @@ from tool_shed.galaxy_install.tool_dependencies import td_common_util import tool_shed.repository_types.util as rt_util -import pkg_resources +eggs.require( 'mercurial' ) -pkg_resources.require( 'mercurial' ) from mercurial import commands from mercurial import hg from mercurial import ui @@ -1531,7 +1530,7 @@ raw_text = common_util.tool_shed_get( trans.app, tool_shed_url, url ) readme_files_dict = json.from_json_string( raw_text ) else: - readme_files_dict = readme_util.build_readme_files_dict( repository.metadata, tool_path ) + readme_files_dict = readme_util.build_readme_files_dict( trans, repository, repository.changeset_revision, repository.metadata, tool_path ) else: readme_files_dict = None # Handle repository dependencies. diff -r 22cfae4b6a227c385146d5d71c49a663809244e8 -r 27a3c2f3fc200ef80f07a5b940aa5ac50ad10320 lib/tool_shed/util/readme_util.py --- a/lib/tool_shed/util/readme_util.py +++ b/lib/tool_shed/util/readme_util.py @@ -1,30 +1,58 @@ import logging import os +from galaxy import eggs from galaxy.util import json from galaxy.util import unicodify import tool_shed.util.shed_util_common as suc from tool_shed.util import common_util +eggs.require( 'mercurial' ) + +from mercurial import hg + log = logging.getLogger( __name__ ) -def build_readme_files_dict( metadata, tool_path=None ): - """Return a dictionary of valid readme file name <-> readme file content pairs for all readme files contained in the received metadata.""" +def build_readme_files_dict( trans, repository, changeset_revision, metadata, tool_path=None ): + """ + Return a dictionary of valid readme file name <-> readme file content pairs for all readme files defined in the received metadata. Since the + received changeset_revision (which is associated with the received metadata) may not be the latest installable changeset revision, the README + file contents may not be available on disk. This method is used by both Galaxy and the Tool Shed. + """ + if trans.webapp.name == 'galaxy': + can_use_disk_files = True + else: + repo = hg.repository( suc.get_configured_ui(), repository.repo_path( trans.app ) ) + latest_downloadable_changeset_revision = suc.get_latest_downloadable_changeset_revision( trans, repository, repo ) + can_use_disk_files = changeset_revision == latest_downloadable_changeset_revision readme_files_dict = {} if metadata: if 'readme_files' in metadata: for relative_path_to_readme_file in metadata[ 'readme_files' ]: readme_file_name = os.path.split( relative_path_to_readme_file )[ 1 ] - if tool_path: - full_path_to_readme_file = os.path.abspath( os.path.join( tool_path, relative_path_to_readme_file ) ) + if can_use_disk_files: + if tool_path: + full_path_to_readme_file = os.path.abspath( os.path.join( tool_path, relative_path_to_readme_file ) ) + else: + full_path_to_readme_file = os.path.abspath( relative_path_to_readme_file ) + try: + f = open( full_path_to_readme_file, 'r' ) + text = unicodify( f.read() ) + f.close() + readme_files_dict[ readme_file_name ] = suc.size_string( text ) + except Exception, e: + log.exception( "Error reading README file '%s' from disk: %s" % ( str( relative_path_to_readme_file ), str( e ) ) ) else: - full_path_to_readme_file = os.path.abspath( relative_path_to_readme_file ) - try: - f = open( full_path_to_readme_file, 'r' ) - text = unicodify( f.read() ) - f.close() - readme_files_dict[ readme_file_name ] = suc.size_string( text ) - except Exception, e: - log.debug( "Error reading README file '%s' defined in metadata: %s" % ( str( relative_path_to_readme_file ), str( e ) ) ) + # We must be in the tool shed and have an old changeset_revision, so we need to retrieve the file contents from the repository manifest. + ctx = suc.get_changectx_for_changeset( repo, changeset_revision ) + if ctx: + fctx = suc.get_file_context_from_ctx( ctx, readme_file_name ) + if fctx and fctx not in [ 'DELETED' ]: + try: + text = unicodify( fctx.data() ) + readme_files_dict[ readme_file_name ] = suc.size_string( text ) + except Exception, e: + log.exception( "Error reading README file '%s' from repository manifest: %s" % \ + ( str( relative_path_to_readme_file ), str( e ) ) ) return readme_files_dict def get_readme_files_dict_for_display( trans, tool_shed_url, repo_info_dict ): diff -r 22cfae4b6a227c385146d5d71c49a663809244e8 -r 27a3c2f3fc200ef80f07a5b940aa5ac50ad10320 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 @@ -12,9 +12,8 @@ from tool_shed.util import metadata_util from tool_shed.util import tool_util -import pkg_resources +eggs.require( 'mercurial' ) -pkg_resources.require( 'mercurial' ) from mercurial import commands from mercurial import hg from mercurial import ui diff -r 22cfae4b6a227c385146d5d71c49a663809244e8 -r 27a3c2f3fc200ef80f07a5b940aa5ac50ad10320 lib/tool_shed/util/repository_maintenance_util.py --- a/lib/tool_shed/util/repository_maintenance_util.py +++ b/lib/tool_shed/util/repository_maintenance_util.py @@ -5,7 +5,7 @@ from galaxy.web.form_builder import build_select_field from galaxy import eggs -eggs.require('mercurial') +eggs.require( 'mercurial' ) from mercurial import commands from mercurial import hg diff -r 22cfae4b6a227c385146d5d71c49a663809244e8 -r 27a3c2f3fc200ef80f07a5b940aa5ac50ad10320 lib/tool_shed/util/review_util.py --- a/lib/tool_shed/util/review_util.py +++ b/lib/tool_shed/util/review_util.py @@ -5,9 +5,8 @@ from galaxy.util.odict import odict import tool_shed.util.shed_util_common as suc -import pkg_resources +eggs.require( 'mercurial' ) -pkg_resources.require( 'mercurial' ) from mercurial import commands from mercurial import hg from mercurial import ui diff -r 22cfae4b6a227c385146d5d71c49a663809244e8 -r 27a3c2f3fc200ef80f07a5b940aa5ac50ad10320 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 @@ -20,10 +20,10 @@ from tool_shed.util import encoding_util from tool_shed.util import xml_util from xml.etree import ElementTree as XmlET + from galaxy import eggs -import pkg_resources +eggs.require( 'mercurial' ) -pkg_resources.require( 'mercurial' ) from mercurial import cmdutil from mercurial import commands from mercurial import hg diff -r 22cfae4b6a227c385146d5d71c49a663809244e8 -r 27a3c2f3fc200ef80f07a5b940aa5ac50ad10320 lib/tool_shed/util/tool_util.py --- a/lib/tool_shed/util/tool_util.py +++ b/lib/tool_shed/util/tool_util.py @@ -18,9 +18,8 @@ import tool_shed.util.shed_util_common as suc from xml.etree import ElementTree as XmlET -import pkg_resources +eggs.require( 'mercurial' ) -pkg_resources.require( 'mercurial' ) from mercurial import commands from mercurial import hg from mercurial import ui 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.