From 1155ead7ffb6ae36fc322a05cdfdf81dc0772109 Mon Sep 17 00:00:00 2001 From: Daniel Blankenberg Date: Fri, 6 Feb 2015 11:56:54 -0500 Subject: [PATCH] Fix for SelectToolParameters that utilize dynamic options and that make use of __trans__ failing at get_legal_values(). --- lib/galaxy/tools/parameters/basic.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/galaxy/tools/parameters/basic.py b/lib/galaxy/tools/parameters/basic.py index 7e157199fc3..4a0930338eb 100644 --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -782,13 +782,17 @@ class SelectToolParameter( ToolParameter ): self.legal_values.add( value ) self.is_dynamic = ( ( self.dynamic_options is not None ) or ( self.options is not None ) ) + def _get_dynamic_options_call_other_values( self, trans, other_values ): + call_other_values = { "__trans__": trans } + if other_values: + call_other_values.update( other_values.dict ) + return call_other_values + def get_options( self, trans, other_values ): if self.options: return self.options.get_options( trans, other_values ) elif self.dynamic_options: - call_other_values = {"__trans__": trans} - if other_values: - call_other_values.update( other_values.dict ) + call_other_values = self._get_dynamic_options_call_other_values( trans, other_values ) try: return eval( self.dynamic_options, self.tool.code_namespace, call_other_values ) except Exception: @@ -805,8 +809,10 @@ class SelectToolParameter( ToolParameter ): return map( _get_UnvalidatedValue_value, set( v for _, v, _ in self.options.get_options( trans, other_values ) ) ) elif self.dynamic_options: try: - return set( v for _, v, _ in eval( self.dynamic_options, self.tool.code_namespace, other_values ) ) - except Exception: + call_other_values = self._get_dynamic_options_call_other_values( trans, other_values ) + return set( v for _, v, _ in eval( self.dynamic_options, self.tool.code_namespace, call_other_values ) ) + except Exception, e: + log.debug( 'Determining legal values failed for "%s": %s', self.name, e ) return set() else: return self.legal_values