commit/galaxy-central: greg: Handle exceptions attempting to open a README file contained in a tool shed repository.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/124ac431a5dc/ changeset: 124ac431a5dc user: greg date: 2012-10-24 19:42:01 summary: Handle exceptions attempting to open a README file contained in a tool shed repository. affected #: 2 files diff -r 87e6251af95f57e4fa24d6e0c9eaefec6016025d -r 124ac431a5dc96087fc95fd4e1985033e20ba13f lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py +++ b/lib/galaxy/webapps/community/controllers/repository.py @@ -1333,10 +1333,14 @@ 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' ) - text = f.read() - f.close() - return str( text ) + try: + f = open( metadata[ 'readme' ], 'r' ) + text = f.read() + f.close() + return str( text ) + except Exception, e: + log.debug( "Error attempting to read README file '%s' defined in metadata for repository '%s', revision '%s': %s" % \ + ( str( metadata[ 'readme' ] ), str( repository_name ), str( changeset_revision ), str( e ) ) ) return '' @web.expose def get_tool_dependencies( self, trans, **kwd ): diff -r 87e6251af95f57e4fa24d6e0c9eaefec6016025d -r 124ac431a5dc96087fc95fd4e1985033e20ba13f 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 @@ -1764,10 +1764,15 @@ readme_filename = metadata[ 'readme' ] if tool_path: readme_filename = os.path.join( tool_path, readme_filename ) - f = open( readme_filename, 'r' ) - raw_text = f.read() - f.close() - readme_text = translate_string( raw_text, to_html=True ) + try: + f = open( readme_filename, 'r' ) + raw_text = f.read() + f.close() + readme_text = translate_string( raw_text, to_html=True ) + except Exception, e: + log.debug( "Error attempting to read README file '%s' defined in metadata for repository '%s', revision '%s': %s" % \ + ( str( readme_filename ), str( repository.name ), str( repository.changeset_revision ), str( e ) ) ) + readme_text = '' else: readme_text = '' is_malicious = False 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