From 3d9da261d1dcbad2414d1edc2f25fbdab0cb1bc3 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Mon, 23 Jun 2014 16:32:24 -0500 Subject: [PATCH] Allow tool conf 'tool_path' resolution relative to conf file. Relative 'tool_path' directories are resolved relative to GALAXY_ROOT (or really working directory). This is probably the expected behavior - but I think it is advantageous to be able to find tools relative to the tool_conf file also. This can now be done using string.Template resolution of ${tool_conf_dir}. --- lib/galaxy/tools/__init__.py | 15 +++++++++++++-- test/functional/tools/samples_tool_conf.xml | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index 131294e6a63..10a9b2b217d 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -11,6 +11,7 @@ import pipes import re import shutil import sys +import string import tempfile import threading import traceback @@ -214,8 +215,7 @@ class ToolBox( object, Dictifiable ): config_elems = [] else: parsing_shed_tool_conf = False - # Default to backward compatible config setting. - tool_path = self.tool_root_dir + tool_path = self.__resolve_tool_path(tool_path, config_filename) # Only load the panel_dict under certain conditions. load_panel_dict = not self.integrated_tool_panel_config_has_contents for _, elem in enumerate( root ): @@ -243,6 +243,17 @@ class ToolBox( object, Dictifiable ): return shed_config_dict return default + def __resolve_tool_path(self, tool_path, config_filename): + if not tool_path: + # Default to backward compatible config setting. + tool_path = self.tool_root_dir + else: + # Allow use of __tool_conf_dir__ in toolbox config files. + tool_conf_dir = os.path.dirname(config_filename) + tool_path_vars = {"tool_conf_dir": tool_conf_dir} + tool_path = string.Template(tool_path).safe_substitute(tool_path_vars) + return tool_path + def __add_tool_to_tool_panel( self, tool, panel_component, section=False ): # See if a version of this tool is already loaded into the tool panel. The value of panel_component # will be a ToolSection (if the value of section=True) or self.tool_panel (if section=False). diff --git a/test/functional/tools/samples_tool_conf.xml b/test/functional/tools/samples_tool_conf.xml index 52f3e54bbba..918e7c5a5e9 100644 --- a/test/functional/tools/samples_tool_conf.xml +++ b/test/functional/tools/samples_tool_conf.xml @@ -1,5 +1,5 @@ - +