1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/commits/b97103653cb6/ Changeset: b97103653cb6 User: inithello Date: 2013-03-29 13:58:14 Summary: Merged in next-stable. Affected #: 9 files
diff -r 906ab184b6dd40e8e575e1e0823729c6978a737a -r b97103653cb622defbc20ae222f04bf145083791 lib/galaxy/tools/__init__.py --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -446,6 +446,7 @@ def load_tool_tag_set( self, elem, panel_dict, integrated_panel_dict, tool_path, load_panel_dict, guid=None, index=None ): try: path = elem.get( "file" ) + repository_id = None if guid is None: tool_shed_repository = None can_load_into_panel_dict = True @@ -464,11 +465,12 @@ if tool_shed_repository: # Only load tools if the repository is not deactivated or uninstalled. can_load_into_panel_dict = not tool_shed_repository.deleted + repository_id = self.app.security.encode_id( tool_shed_repository.id ) else: # If there is not yet a tool_shed_repository record, we're in the process of installing # a new repository, so any included tools can be loaded into the tool panel. can_load_into_panel_dict = True - tool = self.load_tool( os.path.join( tool_path, path ), guid=guid ) + tool = self.load_tool( os.path.join( tool_path, path ), guid=guid, repository_id=repository_id ) key = 'tool_%s' % str( tool.id ) if can_load_into_panel_dict: if guid is not None: @@ -574,7 +576,7 @@ self.integrated_tool_panel[ key ] = integrated_section else: self.integrated_tool_panel.insert( index, key, integrated_section ) - def load_tool( self, config_file, guid=None, **kwds ): + def load_tool( self, config_file, guid=None, repository_id=None, **kwds ): """Load a single tool from the file named by `config_file` and return an instance of `Tool`.""" # Parse XML configuration file and get the root element tree = self._load_and_preprocess_tool_xml( config_file ) @@ -590,7 +592,7 @@ ToolClass = tool_types.get( root.get( 'tool_type' ) ) else: ToolClass = Tool - return ToolClass( config_file, root, self.app, guid=guid, **kwds ) + return ToolClass( config_file, root, self.app, guid=guid, repository_id=repository_id, **kwds ) def reload_tool_by_id( self, tool_id ): """ Attempt to reload the tool identified by 'tool_id', if successful @@ -1004,12 +1006,13 @@ tool_type = 'default' default_tool_action = DefaultToolAction
- def __init__( self, config_file, root, app, guid=None ): + def __init__( self, config_file, root, app, guid=None, repository_id=None ): """Load a tool from the config named by `config_file`""" # Determine the full path of the directory where the tool config is self.config_file = config_file self.tool_dir = os.path.dirname( config_file ) self.app = app + self.repository_id = repository_id #setup initial attribute values self.inputs = odict() self.stdio_exit_codes = list() @@ -1354,6 +1357,19 @@ """ # TODO: Allow raw HTML or an external link. self.help = root.find("help") + # Handle tool shelp image display for tools that are contained in repositories that are in the lool shed or installed into Galaxy. + # When tool config files use the speical string $PATH_TO_IMAGES, the folloing code will replace that string with the path on disk. + if self.repository_id and self.help.text.find( '$PATH_TO_IMAGES' ) >= 0: + if self.app.name == 'galaxy': + repository = self.sa_session.query( self.app.model.ToolShedRepository ).get( self.app.security.decode_id( self.repository_id ) ) + if repository: + path_to_images = '/tool_runner/static/images/%s' % self.repository_id + self.help.text = self.help.text.replace( '$PATH_TO_IMAGES', path_to_images ) + elif self.app.name == 'tool_shed': + repository = self.sa_session.query( self.app.model.Repository ).get( self.app.security.decode_id( self.repository_id ) ) + if repository: + path_to_images = '/repository/static/images/%s' % self.repository_id + self.help.text = self.help.text.replace( '$PATH_TO_IMAGES', path_to_images ) self.help_by_page = list() help_header = "" help_footer = ""
diff -r 906ab184b6dd40e8e575e1e0823729c6978a737a -r b97103653cb622defbc20ae222f04bf145083791 lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -44,6 +44,8 @@ atexit.register( app.shutdown ) # Create the universe WSGI application webapp = GalaxyWebApplication( app, session_cookie='galaxysession', name='galaxy' ) + # The following route will handle displaying tool shelp images for tools contained in repositories installed from the tool shed. + webapp.add_route( '/tool_runner/static/images/:repository_id/:image_file', controller='tool_runner', action='display_tool_help_image_in_repository', repository_id=None, image_file=None ) webapp.add_ui_controllers( 'galaxy.webapps.galaxy.controllers', app ) # Force /history to go to /root/history -- needed since the tests assume this webapp.add_route( '/history', controller='root', action='history' )
diff -r 906ab184b6dd40e8e575e1e0823729c6978a737a -r b97103653cb622defbc20ae222f04bf145083791 lib/galaxy/webapps/galaxy/controllers/tool_runner.py --- a/lib/galaxy/webapps/galaxy/controllers/tool_runner.py +++ b/lib/galaxy/webapps/galaxy/controllers/tool_runner.py @@ -1,19 +1,22 @@ """ Upload class """ - +import os import logging import galaxy.util - from galaxy import web from galaxy.tools import DefaultToolState from galaxy.tools.actions import upload_common -from galaxy.tools.parameters import params_to_incoming, visit_input_values -from galaxy.tools.parameters.basic import DataToolParameter, UnvalidatedValue +from galaxy.tools.parameters import params_to_incoming +from galaxy.tools.parameters import visit_input_values +from galaxy.tools.parameters.basic import DataToolParameter +from galaxy.tools.parameters.basic import UnvalidatedValue from galaxy.util.bunch import Bunch from galaxy.util.hash_util import is_hashable -from galaxy.web import error, url_for +from galaxy.web import error +from galaxy.web import url_for from galaxy.web.base.controller import BaseUIController +import tool_shed.util.shed_util_common as suc
log = logging.getLogger( __name__ )
@@ -92,7 +95,17 @@ util=galaxy.util, add_frame=add_frame, **vars ) - + + @web.expose + def display_tool_help_image_in_repository( self, trans, **kwd ): + repository_id = kwd.get( 'repository_id', None ) + image_file = kwd.get( 'image_file', None ) + if repository_id and image_file: + repository = suc.get_tool_shed_repository_by_id( trans, repository_id ) + repo_files_dir = os.path.join( repository.repo_path( trans.app ), repository.name, repository.name ) + return open( os.path.join( repo_files_dir, 'static', 'images', image_file ), 'r' ) + return None + @web.expose def rerun( self, trans, id=None, from_noframe=None, **kwd ): """
diff -r 906ab184b6dd40e8e575e1e0823729c6978a737a -r b97103653cb622defbc20ae222f04bf145083791 lib/galaxy/webapps/tool_shed/buildapp.py --- a/lib/galaxy/webapps/tool_shed/buildapp.py +++ b/lib/galaxy/webapps/tool_shed/buildapp.py @@ -69,6 +69,8 @@ webapp.add_route( '/view/{owner}', controller='repository', action='sharable_owner' ) webapp.add_route( '/view/{owner}/{name}', controller='repository', action='sharable_repository' ) webapp.add_route( '/view/{owner}/{name}/{changeset_revision}', controller='repository', action='sharable_repository_revision' ) + # The following route will handle displaying tool shelp images for tools contained in repositories. + webapp.add_route( '/repository/static/images/:repository_id/:image_file', controller='repository', action='display_tool_help_image_in_repository', repository_id=None, image_file=None ) webapp.add_route( '/:controller/:action', action='index' ) webapp.add_route( '/:action', controller='repository', action='index' ) webapp.add_route( '/repos/*path_info', controller='hg', action='handle_request', path_info='/' )
diff -r 906ab184b6dd40e8e575e1e0823729c6978a737a -r b97103653cb622defbc20ae222f04bf145083791 lib/galaxy/webapps/tool_shed/config.py --- a/lib/galaxy/webapps/tool_shed/config.py +++ b/lib/galaxy/webapps/tool_shed/config.py @@ -36,7 +36,7 @@ self.database_engine_options = get_database_engine_options( kwargs ) self.database_create_tables = string_as_bool( kwargs.get( "database_create_tables", "True" ) ) # Where dataset files are stored - self.file_path = resolve_path( kwargs.get( "file_path", "database/files" ), self.root ) + self.file_path = resolve_path( kwargs.get( "file_path", "database/community_files" ), self.root ) self.new_file_path = resolve_path( kwargs.get( "new_file_path", "database/tmp" ), self.root ) self.cookie_path = kwargs.get( "cookie_path", "/" ) self.enable_quotas = string_as_bool( kwargs.get( 'enable_quotas', False ) )
diff -r 906ab184b6dd40e8e575e1e0823729c6978a737a -r b97103653cb622defbc20ae222f04bf145083791 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 @@ -367,7 +367,6 @@ return trans.response.send_redirect( web.url_for( controller='repository', action='browse_valid_repositories', **kwd ) ) - log.debug("CCC In browse_valid_categories, just before returning valid_category_grid, kwd: %s" % str( kwd )) return self.valid_category_grid( trans, **kwd )
@web.expose @@ -746,6 +745,16 @@ status='error' ) )
@web.expose + def display_tool_help_image_in_repository( self, trans, **kwd ): + repository_id = kwd.get( 'repository_id', None ) + image_file = kwd.get( 'image_file', None ) + if repository_id and image_file: + repository = suc.get_repository_in_tool_shed( trans, repository_id ) + repo_files_dir = os.path.join( repository.repo_path( trans.app ), repository.name ) + return open( os.path.join( repo_files_dir, 'static', 'images', image_file ), 'r' ) + return None + + @web.expose def download( self, trans, repository_id, changeset_revision, file_type, **kwd ): # Download an archive of the repository files compressed as zip, gz or bz2. params = util.Params( kwd ) @@ -2568,14 +2577,16 @@ if can_use_disk_file: trans.app.config.tool_data_path = work_dir tool, valid, message, sample_files = tool_util.handle_sample_files_and_load_tool_from_disk( trans, - repo_files_dir, - full_path_to_tool_config, - work_dir ) + repo_files_dir, + repository_id, + full_path_to_tool_config, + work_dir ) if message: status = 'error' else: tool, message, sample_files = tool_util.handle_sample_files_and_load_tool_from_tmp_config( trans, repo, + repository_id, changeset_revision, tool_config_filename, work_dir )
diff -r 906ab184b6dd40e8e575e1e0823729c6978a737a -r b97103653cb622defbc20ae222f04bf145083791 lib/tool_shed/util/metadata_util.py --- a/lib/tool_shed/util/metadata_util.py +++ b/lib/tool_shed/util/metadata_util.py @@ -377,7 +377,7 @@ log.debug( 'Loaded Data Manager tool_files: %s' % ( tool_file ) ) return metadata_dict
-def generate_datatypes_metadata( app, repository_clone_url, repository_files_dir, datatypes_config, metadata_dict ): +def generate_datatypes_metadata( app, repository, repository_clone_url, repository_files_dir, datatypes_config, metadata_dict ): """Update the received metadata_dict with information from the parsed datatypes_config.""" try: tree = ElementTree.parse( datatypes_config ) @@ -428,7 +428,7 @@ # Parse the tool_config to get the guid. tool_config_path = suc.get_config_from_disk( tool_config, repository_files_dir ) full_path = os.path.abspath( tool_config_path ) - tool, valid, error_message = tool_util.load_tool_from_config( app, full_path ) + tool, valid, error_message = tool_util.load_tool_from_config( app, app.security.encode_id( repository.id ), full_path ) if tool is None: guid = None else: @@ -534,7 +534,7 @@ # Handle proprietary datatypes, if any. datatypes_config = suc.get_config_from_disk( 'datatypes_conf.xml', files_dir ) if datatypes_config: - metadata_dict = generate_datatypes_metadata( app, repository_clone_url, files_dir, datatypes_config, metadata_dict ) + metadata_dict = generate_datatypes_metadata( app, repository, repository_clone_url, files_dir, datatypes_config, metadata_dict ) # Get the relative path to all sample files included in the repository for storage in the repository's metadata. sample_file_metadata_paths, sample_file_copy_paths = get_sample_files_from_disk( repository_files_dir=files_dir, tool_path=shed_config_dict.get( 'tool_path' ), @@ -589,7 +589,7 @@ log.debug( "Error parsing %s, exception: %s" % ( full_path, str( e ) ) ) is_tool = False if is_tool: - tool, valid, error_message = tool_util.load_tool_from_config( app, full_path ) + tool, valid, error_message = tool_util.load_tool_from_config( app, app.security.encode_id( repository.id ), full_path ) if tool is None: if not valid: invalid_tool_configs.append( name )
diff -r 906ab184b6dd40e8e575e1e0823729c6978a737a -r b97103653cb622defbc20ae222f04bf145083791 lib/tool_shed/util/tool_util.py --- a/lib/tool_shed/util/tool_util.py +++ b/lib/tool_shed/util/tool_util.py @@ -555,7 +555,7 @@ repository_tools_tups[ index ] = ( tup_path, guid, repository_tool ) return repository_tools_tups, sample_files_copied
-def handle_sample_files_and_load_tool_from_disk( trans, repo_files_dir, tool_config_filepath, work_dir ): +def handle_sample_files_and_load_tool_from_disk( trans, repo_files_dir, repository_id, tool_config_filepath, work_dir ): # Copy all sample files from disk to a temporary directory since the sample files may be in multiple directories. message = '' sample_files = copy_disk_sample_files_to_dir( trans, repo_files_dir, work_dir ) @@ -564,11 +564,11 @@ # Load entries into the tool_data_tables if the tool requires them. tool_data_table_config = os.path.join( work_dir, 'tool_data_table_conf.xml' ) error, message = handle_sample_tool_data_table_conf_file( trans.app, tool_data_table_config ) - tool, valid, message2 = load_tool_from_config( trans.app, tool_config_filepath ) + tool, valid, message2 = load_tool_from_config( trans.app, repository_id, tool_config_filepath ) message = concat_messages( message, message2 ) return tool, valid, message, sample_files
-def handle_sample_files_and_load_tool_from_tmp_config( trans, repo, changeset_revision, tool_config_filename, work_dir ): +def handle_sample_files_and_load_tool_from_tmp_config( trans, repo, repository_id, changeset_revision, tool_config_filename, work_dir ): tool = None message = '' ctx = suc.get_changectx_for_changeset( repo, changeset_revision ) @@ -586,7 +586,7 @@ log.debug( message ) manifest_ctx, ctx_file = suc.get_ctx_file_path_from_manifest( tool_config_filename, repo, changeset_revision ) if manifest_ctx and ctx_file: - tool, message2 = load_tool_from_tmp_config( trans, repo, manifest_ctx, ctx_file, work_dir ) + tool, message2 = load_tool_from_tmp_config( trans, repo, repository_id, manifest_ctx, ctx_file, work_dir ) message = concat_messages( message, message2 ) return tool, message, sample_files
@@ -755,7 +755,7 @@ can_use_disk_file = can_use_tool_config_disk_file( trans, repository, repo, tool_config_filepath, changeset_revision ) if can_use_disk_file: trans.app.config.tool_data_path = work_dir - tool, valid, message, sample_files = handle_sample_files_and_load_tool_from_disk( trans, repo_files_dir, tool_config_filepath, work_dir ) + tool, valid, message, sample_files = handle_sample_files_and_load_tool_from_disk( trans, repo_files_dir, repository_id, tool_config_filepath, work_dir ) if tool is not None: invalid_files_and_errors_tups = check_tool_input_params( trans.app, repo_files_dir, @@ -771,16 +771,16 @@ displaying_invalid_tool=True ) message = concat_messages( message, message2 ) else: - tool, message, sample_files = handle_sample_files_and_load_tool_from_tmp_config( trans, repo, changeset_revision, tool_config_filename, work_dir ) + tool, message, sample_files = handle_sample_files_and_load_tool_from_tmp_config( trans, repo, repository_id, changeset_revision, tool_config_filename, work_dir ) suc.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 ) return repository, tool, message
-def load_tool_from_config( app, full_path ): +def load_tool_from_config( app, repository_id, full_path ): try: - tool = app.toolbox.load_tool( full_path ) + tool = app.toolbox.load_tool( full_path, repository_id=repository_id ) valid = True error_message = None except KeyError, e: @@ -795,7 +795,7 @@ error_message = str( e ) return tool, valid, error_message
-def load_tool_from_tmp_config( trans, repo, ctx, ctx_file, work_dir ): +def load_tool_from_tmp_config( trans, repo, repository_id, ctx, ctx_file, work_dir ): tool = None message = '' tmp_tool_config = suc.get_named_tmpfile_from_ctx( ctx, ctx_file, work_dir ) @@ -809,7 +809,7 @@ tmp_code_file_name = suc.copy_file_from_manifest( repo, ctx, code_file_name, work_dir ) if tmp_code_file_name: tmp_code_files.append( tmp_code_file_name ) - tool, valid, message = load_tool_from_config( trans.app, tmp_tool_config ) + tool, valid, message = load_tool_from_config( trans.app, repository_id, tmp_tool_config ) for tmp_code_file in tmp_code_files: try: os.unlink( tmp_code_file )
diff -r 906ab184b6dd40e8e575e1e0823729c6978a737a -r b97103653cb622defbc20ae222f04bf145083791 tool_shed_wsgi.ini.sample --- a/tool_shed_wsgi.ini.sample +++ b/tool_shed_wsgi.ini.sample @@ -29,7 +29,7 @@ # Where the hgweb.config file is stored. The default is the Galaxy installation directory. #hgweb_config_dir = None
-# Where dataset files are saved +# Where tool shed repositories are stored. file_path = database/community_files # Temporary storage for additional datasets, this should be shared through the cluster new_file_path = database/tmp
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.