1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/fa69b6d3cafd/ Changeset: fa69b6d3cafd User: greg Date: 2014-06-17 17:00:49 Summary: Instantiate the Tool Shed's various tool dependency recipe classes with app so it doesn't have to be passed to functions. Affected #: 7 files diff -r ac9a4a915fdef0fb425e7146637d551066844af7 -r fa69b6d3cafdc18e2531cfd015676223f33cee67 lib/tool_shed/galaxy_install/install_manager.py --- a/lib/tool_shed/galaxy_install/install_manager.py +++ b/lib/tool_shed/galaxy_install/install_manager.py @@ -58,9 +58,10 @@ actions = actions_dict.get( 'actions', None ) filtered_actions = [] env_file_builder = EnvFileBuilder( install_dir ) - install_environment = InstallEnvironment( tool_shed_repository_install_dir=tool_shed_repository_install_dir, + install_environment = InstallEnvironment( app=self.app, + tool_shed_repository_install_dir=tool_shed_repository_install_dir, install_dir=install_dir ) - step_manager = StepManager() + step_manager = StepManager( self.app ) if actions: with install_environment.make_tmp_dir() as work_dir: with lcd( work_dir ): @@ -76,8 +77,7 @@ # tool_dependency status in this stage because it should not have been changed based on a # download. tool_dependency, filtered_actions, dir = \ - step_manager.execute_step( app=self.app, - tool_dependency=tool_dependency, + step_manager.execute_step( tool_dependency=tool_dependency, package_name=package_name, actions=actions, action_type=action_type, @@ -102,8 +102,7 @@ with lcd( current_dir ): action_type, action_dict = action_tup tool_dependency, tmp_filtered_actions, tmp_dir = \ - step_manager.execute_step( app=self.app, - tool_dependency=tool_dependency, + step_manager.execute_step( tool_dependency=tool_dependency, package_name=package_name, actions=actions, action_type=action_type, @@ -154,7 +153,7 @@ """ attr_tups_of_dependencies_for_install = [ ( td.name, td.version, td.type ) for td in tool_dependencies ] installed_packages = [] - tag_manager = TagManager() + tag_manager = TagManager( self.app ) # Parse the tool_dependencies.xml config. tree, error_message = xml_util.parse_xml( tool_dependencies_config ) if tree is None: @@ -192,8 +191,7 @@ # If the tool_dependency.type is 'set_environment', then the call to process_tag_set() will # handle everything - no additional installation is necessary. tool_dependency, proceed_with_install, action_elem_tuples = \ - tag_manager.process_tag_set( self.app, - tool_shed_repository, + tag_manager.process_tag_set( tool_shed_repository, tool_dependency, elem, name, @@ -250,9 +248,9 @@ elems = [ action_elem ] else: elems = [] - step_manager = StepManager() + step_manager = StepManager( self.app ) tool_shed_repository_install_dir = self.get_tool_shed_repository_install_dir( tool_shed_repository ) - install_environment = InstallEnvironment( tool_shed_repository_install_dir, install_dir ) + install_environment = InstallEnvironment( self.app, tool_shed_repository_install_dir, install_dir ) for action_elem in elems: # Make sure to skip all comments, since they are now included in the XML tree. if action_elem.tag != 'action': @@ -260,8 +258,7 @@ action_dict = {} action_type = action_elem.get( 'type', None ) if action_type is not None: - action_dict = step_manager.prepare_step( app=self.app, - tool_dependency=tool_dependency, + action_dict = step_manager.prepare_step( tool_dependency=tool_dependency, action_type=action_type, action_elem=action_elem, action_dict=action_dict, @@ -287,7 +284,7 @@ Install a tool dependency package defined by the XML element elem. The value of tool_dependencies is a partial or full list of ToolDependency records associated with the tool_shed_repository. """ - tag_manager = TagManager() + tag_manager = TagManager( self.app ) # The value of package_name should match the value of the "package" type in the tool config's # <requirements> tag set, but it's not required. package_name = elem.get( 'name', None ) @@ -300,8 +297,7 @@ if tool_dependency is not None: for package_elem in elem: tool_dependency, proceed_with_install, actions_elem_tuples = \ - tag_manager.process_tag_set( self.app, - tool_shed_repository, + tag_manager.process_tag_set( tool_shed_repository, tool_dependency, package_elem, package_name, diff -r ac9a4a915fdef0fb425e7146637d551066844af7 -r fa69b6d3cafdc18e2531cfd015676223f33cee67 lib/tool_shed/galaxy_install/tool_dependencies/recipe/env_file_builder.py --- a/lib/tool_shed/galaxy_install/tool_dependencies/recipe/env_file_builder.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/recipe/env_file_builder.py @@ -17,7 +17,7 @@ return_code = self.file_append( env_entry, env_file, make_executable=make_executable ) self.return_code = self.return_code or return_code return self.return_code - + @staticmethod def create_or_update_env_shell_file( install_dir, env_var_dict ): env_var_action = env_var_dict[ 'action' ] diff -r ac9a4a915fdef0fb425e7146637d551066844af7 -r fa69b6d3cafdc18e2531cfd015676223f33cee67 lib/tool_shed/galaxy_install/tool_dependencies/recipe/install_environment.py --- a/lib/tool_shed/galaxy_install/tool_dependencies/recipe/install_environment.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/recipe/install_environment.py @@ -35,12 +35,13 @@ """Object describing the environment built up as part of the process of building and installing a package.""" - def __init__( self, tool_shed_repository_install_dir, install_dir ): + def __init__( self, app, tool_shed_repository_install_dir, install_dir ): """ The value of the received tool_shed_repository_install_dir is the root installation directory of the repository containing the tool dependency, and the value of the received install_dir is the root installation directory of the tool dependency. """ + self.app = app self.env_shell_file_paths = [] self.install_dir = install_dir self.tool_shed_repository_install_dir = tool_shed_repository_install_dir @@ -122,9 +123,9 @@ log.debug( 'Invalid file %s specified, ignoring template_command action.' % str( env_shell_file_path ) ) return env_vars - def handle_command( self, app, tool_dependency, cmd, return_output=False ): + def handle_command( self, tool_dependency, cmd, return_output=False ): """Handle a command and log the results.""" - context = app.install_model.context + context = self.app.install_model.context command = str( cmd ) output = self.handle_complex_command( command ) self.log_results( cmd, output, os.path.join( self.install_dir, basic_util.INSTALLATION_LOG ) ) @@ -137,7 +138,7 @@ print "Length of stderr > %s, so only a portion will be saved in the database." % str( DATABASE_MAX_STRING_SIZE_PRETTY ) stderr = shrink_string_by_size( stderr, DATABASE_MAX_STRING_SIZE, join_by="\n..\n", left_larger=True, beginning_on_size_error=True ) if output.return_code not in [ 0 ]: - tool_dependency.status = app.install_model.ToolDependency.installation_status.ERROR + tool_dependency.status = self.app.install_model.ToolDependency.installation_status.ERROR if stderr: tool_dependency.error_message = unicodify( stderr ) elif stdout: diff -r ac9a4a915fdef0fb425e7146637d551066844af7 -r fa69b6d3cafdc18e2531cfd015676223f33cee67 lib/tool_shed/galaxy_install/tool_dependencies/recipe/recipe_manager.py --- a/lib/tool_shed/galaxy_install/tool_dependencies/recipe/recipe_manager.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/recipe/recipe_manager.py @@ -9,18 +9,18 @@ class StepManager( object ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.step_handlers_by_type = self.load_step_handlers() def get_step_handler_by_type( self, type ): return self.step_handlers_by_type.get( type, None ) - def execute_step( self, app, tool_dependency, package_name, actions, action_type, action_dict, filtered_actions, + def execute_step( self, tool_dependency, package_name, actions, action_type, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): if actions: step_handler = self.get_step_handler_by_type( action_type ) - tool_dependency, filtered_actions, dir = step_handler.execute_step( app=app, - tool_dependency=tool_dependency, + tool_dependency, filtered_actions, dir = step_handler.execute_step( tool_dependency=tool_dependency, package_name=package_name, actions=actions, action_dict=action_dict, @@ -35,39 +35,38 @@ return tool_dependency, filtered_actions, dir def load_step_handlers( self ): - step_handlers_by_type = dict( assert_directory_executable=step_handler.AssertDirectoryExecutable(), - assert_directory_exists=step_handler.AssertDirectoryExists(), - assert_file_executable=step_handler.AssertFileExecutable(), - assert_file_exists=step_handler.AssertFileExists(), - autoconf=step_handler.Autoconf(), - change_directory=step_handler.ChangeDirectory(), - chmod=step_handler.Chmod(), - download_binary=step_handler.DownloadBinary(), - download_by_url=step_handler.DownloadByUrl(), - download_file=step_handler.DownloadFile(), - make_directory=step_handler.MakeDirectory(), - make_install=step_handler.MakeInstall(), - move_directory_files=step_handler.MoveDirectoryFiles(), - move_file=step_handler.MoveFile(), - set_environment=step_handler.SetEnvironment(), - set_environment_for_install=step_handler.SetEnvironmentForInstall(), - setup_perl_environment=step_handler.SetupPerlEnvironment(), - setup_r_environment=step_handler.SetupREnvironment(), - setup_ruby_environment=step_handler.SetupRubyEnvironment(), - setup_virtualenv=step_handler.SetupVirtualEnv(), - shell_command=step_handler.ShellCommand(), - template_command=step_handler.TemplateCommand() ) + step_handlers_by_type = dict( assert_directory_executable=step_handler.AssertDirectoryExecutable( self.app ), + assert_directory_exists=step_handler.AssertDirectoryExists( self.app ), + assert_file_executable=step_handler.AssertFileExecutable( self.app ), + assert_file_exists=step_handler.AssertFileExists( self.app ), + autoconf=step_handler.Autoconf( self.app ), + change_directory=step_handler.ChangeDirectory( self.app ), + chmod=step_handler.Chmod( self.app ), + download_binary=step_handler.DownloadBinary( self.app ), + download_by_url=step_handler.DownloadByUrl( self.app ), + download_file=step_handler.DownloadFile( self.app ), + make_directory=step_handler.MakeDirectory( self.app ), + make_install=step_handler.MakeInstall( self.app ), + move_directory_files=step_handler.MoveDirectoryFiles( self.app ), + move_file=step_handler.MoveFile( self.app ), + set_environment=step_handler.SetEnvironment( self.app ), + set_environment_for_install=step_handler.SetEnvironmentForInstall( self.app ), + setup_perl_environment=step_handler.SetupPerlEnvironment( self.app ), + setup_r_environment=step_handler.SetupREnvironment( self.app ), + setup_ruby_environment=step_handler.SetupRubyEnvironment( self.app ), + setup_virtualenv=step_handler.SetupVirtualEnv( self.app ), + shell_command=step_handler.ShellCommand( self.app ), + template_command=step_handler.TemplateCommand( self.app ) ) return step_handlers_by_type - def prepare_step( self, app, tool_dependency, action_type, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_type, action_elem, action_dict, install_environment, is_binary_download ): """ Prepare the recipe step for later execution. This generally alters the received action_dict with new information needed during this step's execution. """ if action_elem is not None: step_handler = self.get_step_handler_by_type( action_type ) - action_dict = step_handler.prepare_step( app=app, - tool_dependency=tool_dependency, + action_dict = step_handler.prepare_step( tool_dependency=tool_dependency, action_elem=action_elem, action_dict=action_dict, install_environment=install_environment, @@ -76,18 +75,18 @@ class TagManager( object ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.tag_handlers = self.load_tag_handlers() def get_tag_handler_by_tag( self, tag ): return self.tag_handlers.get( tag, None ) - def process_tag_set( self, app, tool_shed_repository, tool_dependency, package_elem, package_name, package_version, + def process_tag_set( self, tool_shed_repository, tool_dependency, package_elem, package_name, package_version, from_tool_migration_manager=False, tool_dependency_db_records=None ): tag_handler = self.get_tag_handler_by_tag( package_elem.tag ) tool_dependency, proceed_with_install, action_elem_tuples = \ - tag_handler.process_tag_set( app, - tool_shed_repository, + tag_handler.process_tag_set( tool_shed_repository, tool_dependency, package_elem, package_name, @@ -97,10 +96,10 @@ return tool_dependency, proceed_with_install, action_elem_tuples def load_tag_handlers( self ): - tag_handlers = dict( environment_variable=tag_handler.SetEnvironment(), - install=tag_handler.Install(), - package=tag_handler.Package(), - readme=tag_handler.ReadMe(), - repository=tag_handler.Repository(), - set_environment=tag_handler.SetEnvironment() ) + tag_handlers = dict( environment_variable=tag_handler.SetEnvironment( self.app ), + install=tag_handler.Install( self.app ), + package=tag_handler.Package( self.app ), + readme=tag_handler.ReadMe( self.app ), + repository=tag_handler.Repository( self.app ), + set_environment=tag_handler.SetEnvironment( self.app ) ) return tag_handlers diff -r ac9a4a915fdef0fb425e7146637d551066844af7 -r fa69b6d3cafdc18e2531cfd015676223f33cee67 lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py --- a/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py @@ -180,17 +180,18 @@ class RecipeStep( object ): """Abstract class that defines a standard format for handling recipe steps when installing packages.""" - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): raise "Unimplemented Method" - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): raise "Unimplemented Method" class AssertDirectoryExecutable( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'assert_directory_executable' def assert_directory_executable( self, full_path ): @@ -209,7 +210,7 @@ return True return False - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Make sure a symbolic link or directory on disk exists and is executable, but is not a file. @@ -221,16 +222,16 @@ else: full_path = os.path.join( current_dir, action_dict[ 'full_path' ] ) if not self.assert_directory_executable( full_path=full_path ): - status = app.install_model.ToolDependency.installation_status.ERROR + status = self.app.install_model.ToolDependency.installation_status.ERROR error_message = 'The path %s is not a directory or is not executable by the owner.' % str( full_path ) - tool_dependency = tool_dependency_util.set_tool_dependency_attributes( app, + tool_dependency = tool_dependency_util.set_tool_dependency_attributes( self.app, tool_dependency, status=status, error_message=error_message, remove_from_disk=False ) return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # <action type="assert_executable">$INSTALL_DIR/mira/my_file</action> if action_elem.text: action_dict[ 'full_path' ] = basic_util.evaluate_template( action_elem.text, install_environment ) @@ -239,7 +240,8 @@ class AssertDirectoryExists( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'assert_directory_exists' def assert_directory_exists( self, full_path ): @@ -254,7 +256,7 @@ return True return False - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Make sure a a symbolic link or directory on disk exists, but is not a file. Since this @@ -266,16 +268,16 @@ else: full_path = os.path.join( current_dir, action_dict[ 'full_path' ] ) if not self.assert_directory_exists( full_path=full_path ): - status = app.install_model.ToolDependency.installation_status.ERROR + status = self.app.install_model.ToolDependency.installation_status.ERROR error_message = 'The path %s is not a directory or does not exist.' % str( full_path ) - tool_dependency = tool_dependency_util.set_tool_dependency_attributes( app, + tool_dependency = tool_dependency_util.set_tool_dependency_attributes( self.app, tool_dependency, status=status, error_message=error_message, remove_from_disk=False ) return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # <action type="make_directory">$INSTALL_DIR/mira</action> if action_elem.text: action_dict[ 'full_path' ] = basic_util.evaluate_template( action_elem.text, install_environment ) @@ -284,7 +286,8 @@ class AssertFileExecutable( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'assert_file_executable' def assert_file_executable( self, full_path ): @@ -303,7 +306,7 @@ return True return False - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Make sure a symbolic link or file on disk exists and is executable, but is not a directory. @@ -315,16 +318,16 @@ else: full_path = os.path.join( current_dir, action_dict[ 'full_path' ] ) if not self.assert_file_executable( full_path=full_path ): - status = app.install_model.ToolDependency.installation_status.ERROR + status = self.app.install_model.ToolDependency.installation_status.ERROR error_message = 'The path %s is not a file or is not executable by the owner.' % str( full_path ) - tool_dependency = tool_dependency_util.set_tool_dependency_attributes( app, + tool_dependency = tool_dependency_util.set_tool_dependency_attributes( self.app, tool_dependency, status=status, error_message=error_message, remove_from_disk=False ) return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # <action type="assert_executable">$INSTALL_DIR/mira/my_file</action> if action_elem.text: action_dict[ 'full_path' ] = basic_util.evaluate_template( action_elem.text, install_environment ) @@ -333,7 +336,8 @@ class AssertFileExists( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'assert_file_exists' def assert_file_exists( self, full_path ): @@ -349,7 +353,7 @@ return True return False - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Make sure a symbolic link or file on disk exists, but is not a directory. Since this @@ -361,16 +365,16 @@ else: full_path = os.path.join( current_dir, action_dict[ 'full_path' ] ) if not self.assert_file_exists( full_path=full_path ): - status = app.install_model.ToolDependency.installation_status.ERROR + status = self.app.install_model.ToolDependency.installation_status.ERROR error_message = 'The path %s is not a file or does not exist.' % str( full_path ) - tool_dependency = tool_dependency_util.set_tool_dependency_attributes( app, + tool_dependency = tool_dependency_util.set_tool_dependency_attributes( self.app, tool_dependency, status=status, error_message=error_message, remove_from_disk=False ) return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # <action type="assert_on_path">$INSTALL_DIR/mira/my_file</action> if action_elem.text: action_dict[ 'full_path' ] = basic_util.evaluate_template( action_elem.text, install_environment ) @@ -379,10 +383,11 @@ class Autoconf( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'autoconf' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Handle configure, make and make install in a shell, allowing for configuration options. Since this @@ -396,15 +401,14 @@ else: pre_cmd = './configure --prefix=$INSTALL_DIR %s && make && make install' % configure_opts cmd = install_environment.build_command( basic_util.evaluate_template( pre_cmd, install_environment ) ) - return_code = install_environment.handle_command( app=app, - tool_dependency=tool_dependency, + return_code = install_environment.handle_command( tool_dependency=tool_dependency, cmd=cmd, return_output=False ) # The caller should check the status of the returned tool_dependency since this function # does nothing with the return_code. return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # Handle configure, make and make install allow providing configuration options if action_elem.text: configure_opts = basic_util.evaluate_template( action_elem.text, install_environment ) @@ -414,10 +418,11 @@ class ChangeDirectory( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'change_directory' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Change the working directory in a shell. Since this class is not used in the initial download stage, @@ -436,7 +441,7 @@ dir = current_dir return tool_dependency, None, dir - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # <action type="change_directory">PHYLIP-3.6b</action> if action_elem.text: action_dict[ 'directory' ] = action_elem.text @@ -445,10 +450,11 @@ class Chmod( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'chmod' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Change the mode setting for certain files in the installation environment. Since this class is not @@ -462,7 +468,7 @@ log.debug( 'Invalid file %s specified, ignoring %s action.', target_file, action_type ) return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # Change the read, write, and execute bits on a file. # <action type="chmod"> # <file mode="750">$INSTALL_DIR/bin/faToTwoBit</file> @@ -492,7 +498,8 @@ class DownloadBinary( Download, RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'download_binary' def download_binary( self, url, work_dir ): @@ -510,7 +517,7 @@ filtered_actions.append( action ) return filtered_actions - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Download a binary file. If the value of initial_download is True, the recipe steps will be @@ -561,7 +568,7 @@ return tool_dependency, filtered_actions, dir return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): platform_info_dict = tool_dependency_util.get_platform_info_dict() platform_info_dict[ 'name' ] = str( tool_dependency.name ) platform_info_dict[ 'version' ] = str( tool_dependency.version ) @@ -584,10 +591,11 @@ class DownloadByUrl( Download, RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'download_by_url' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Download a file via HTTP. If the value of initial_download is True, the recipe steps will be @@ -622,7 +630,7 @@ return tool_dependency, filtered_actions, dir return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # <action type="download_by_url"> # http://sourceforge.net/projects/samtools/files/samtools/0.1.18/samtools-0.1.... # </action> @@ -638,10 +646,11 @@ class DownloadFile( Download, RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'download_file' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Download a file. If the value of initial_download is True, the recipe steps will be @@ -667,7 +676,7 @@ return tool_dependency, filtered_actions, dir return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # <action type="download_file">http://effectors.org/download/version/TTSS_GUI-1.0.1.jar</action> if action_elem.text: action_dict[ 'url' ] = action_elem.text @@ -680,10 +689,11 @@ class MakeDirectory( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'make_directory' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Make a directory on disk. Since this class is not used in the initial download stage, no recipe step @@ -700,7 +710,7 @@ if not os.path.exists( full_path ): os.makedirs( full_path ) - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # <action type="make_directory">$INSTALL_DIR/lib/python</action> if action_elem.text: action_dict[ 'full_path' ] = basic_util.evaluate_template( action_elem.text, install_environment ) @@ -709,10 +719,11 @@ class MakeInstall( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'make_install' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Execute a make_install command in a shell. Since this class is not used in the initial download stage, @@ -722,15 +733,14 @@ with settings( warn_only=True ): make_opts = action_dict.get( 'make_opts', '' ) cmd = install_environment.build_command( 'make %s && make install' % make_opts ) - return_code = install_environment.handle_command( app=app, - tool_dependency=tool_dependency, + return_code = install_environment.handle_command( tool_dependency=tool_dependency, cmd=cmd, return_output=False ) # The caller should check the status of the returned tool_dependency since this function # does nothing with the return_code. return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # make; make install; allow providing make options if action_elem.text: make_opts = basic_util.evaluate_template( action_elem.text, install_environment ) @@ -740,10 +750,11 @@ class MoveDirectoryFiles( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'move_directory_files' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Move a directory of files. Since this class is not used in the initial download stage, no recipe step @@ -774,7 +785,7 @@ for source_file, destination_file in regular_files: shutil.move( source_file, destination_file ) - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # <action type="move_directory_files"> # <source_directory>bin</source_directory> # <destination_directory>$INSTALL_DIR/bin</destination_directory> @@ -788,10 +799,11 @@ class MoveFile( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'move_file' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Move a file on disk. Since this class is not used in the initial download stage, no recipe step @@ -803,7 +815,7 @@ rename_to=action_dict[ 'rename_to' ] ) return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # <action type="move_file" rename_to="new_file_name"> # <source>misc/some_file</source> # <destination>$INSTALL_DIR/bin</destination> @@ -816,10 +828,11 @@ class SetEnvironment( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'set_environment' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Configure an install environment. Since this class is not used in the initial download stage, @@ -831,8 +844,7 @@ env_var_dicts = action_dict.get( 'environment_variable', [] ) for env_var_dict in env_var_dicts: # Check for the presence of the $ENV[] key string and populate it if possible. - env_var_dict = self.handle_environment_variables( app=app, - install_environment=install_environment, + env_var_dict = self.handle_environment_variables( install_environment=install_environment, tool_dependency=tool_dependency, env_var_dict=env_var_dict, set_prior_environment_commands=cmds ) @@ -842,7 +854,7 @@ return_code = env_file_builder.return_code return tool_dependency, None, None - def handle_environment_variables( self, app, install_environment, tool_dependency, env_var_dict, + def handle_environment_variables( self, install_environment, tool_dependency, env_var_dict, set_prior_environment_commands ): """ This method works with with a combination of three tool dependency definition tag sets, which are defined @@ -925,8 +937,7 @@ set_prior_environment_commands.append( 'echo %s: $%s' % ( inherited_env_var_name, inherited_env_var_name ) ) command = ' ; '.join( set_prior_environment_commands ) # Run the command and capture the output. - command_return = install_environment.handle_command( app=app, - tool_dependency=tool_dependency, + command_return = install_environment.handle_command( tool_dependency=tool_dependency, cmd=command, return_output=True ) # And extract anything labeled with the name of the environment variable we're populating here. @@ -944,7 +955,7 @@ env_var_dict[ 'value' ] = env_var_value return env_var_dict - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # This function is only called for set environment actions as defined above, not within a <set_environment> tool # dependency type. Here is an example of the tag set this function does handle: # <action type="set_environment"> @@ -955,7 +966,7 @@ # <action type="set_environment"> # <environment_variable name="PATH" action="prepend_to">$INSTALL_DIR</environment_variable> # </action> - env_manager = EnvManager( app ) + env_manager = EnvManager( self.app ) env_var_dicts = [] for env_elem in action_elem: if env_elem.tag == 'environment_variable': @@ -971,10 +982,11 @@ class SetEnvironmentForInstall( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'set_environment_for_install' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Configure an environment for compiling a package. Since this class is not used in the initial @@ -989,7 +1001,7 @@ install_environment.add_env_shell_file_paths( env_shell_file_paths ) return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # <action type="set_environment_for_install"> # <repository toolshed="http://localhost:9009/" name="package_numpy_1_7" owner="test" changeset_revision="c84c6a8be056"> # <package name="numpy" version="1.7.1" /> @@ -1002,7 +1014,7 @@ # the current tool dependency package. See the package_matplotlib_1_2 repository in the test tool # shed for a real-world example. all_env_shell_file_paths = [] - env_manager = EnvManager( app ) + env_manager = EnvManager( self.app ) for env_elem in action_elem: if env_elem.tag == 'repository': env_shell_file_paths = env_manager.get_env_shell_file_paths( env_elem ) @@ -1014,10 +1026,11 @@ class SetupPerlEnvironment( Download, RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'setup_purl_environment' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Initialize the environment for installing Perl packages. The class is called during the initial @@ -1076,8 +1089,7 @@ return tool_dependency, None, None with lcd( tmp_work_dir ): cmd = install_environment.build_command( basic_util.evaluate_template( cmd, install_environment ) ) - return_code = install_environment.handle_command( app=app, - tool_dependency=tool_dependency, + return_code = install_environment.handle_command( tool_dependency=tool_dependency, cmd=cmd, return_output=False ) if return_code: @@ -1089,8 +1101,7 @@ # cpanm should be installed with the parent perl distribution, otherwise this will not work. cmd += '''cpanm --local-lib=$INSTALL_DIR %s''' % ( perl_package ) cmd = install_environment.build_command( basic_util.evaluate_template( cmd, install_environment ) ) - return_code = install_environment.handle_command( app=app, - tool_dependency=tool_dependency, + return_code = install_environment.handle_command( tool_dependency=tool_dependency, cmd=cmd, return_output=False ) if return_code: @@ -1115,7 +1126,7 @@ return tool_dependency, filtered_actions, dir return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # setup a Perl environment. # <action type="setup_perl_environment"> # <repository name="package_perl_5_18" owner="bgruening"> @@ -1129,7 +1140,7 @@ # with each repository. This will potentially update the value of the 'env_shell_file_paths' entry # in action_dict. all_env_shell_file_paths = [] - env_manager = EnvManager( app ) + env_manager = EnvManager( self.app ) action_dict = env_manager.get_env_shell_file_paths_from_setup_environment_elem( all_env_shell_file_paths, action_elem, action_dict ) @@ -1149,10 +1160,11 @@ class SetupREnvironment( Download, RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'setup_r_environment' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Initialize the environment for installing R packages. The class is called during the initial @@ -1198,8 +1210,7 @@ Rscript -e "install.packages(c('%s'),lib='$INSTALL_DIR', repos=NULL, dependencies=FALSE)"''' % \ ( str( tarball_name ) ) cmd = install_environment.build_command( basic_util.evaluate_template( cmd, install_environment ) ) - return_code = install_environment.handle_command( app=app, - tool_dependency=tool_dependency, + return_code = install_environment.handle_command( tool_dependency=tool_dependency, cmd=cmd, return_output=False ) if return_code: @@ -1219,7 +1230,7 @@ return tool_dependency, filtered_actions, dir return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # setup an R environment. # <action type="setup_r_environment"> # <repository name="package_r_3_0_1" owner="bgruening"> @@ -1232,7 +1243,7 @@ # associated with each repository. This will potentially update the value of the # 'env_shell_file_paths' entry in action_dict. all_env_shell_file_paths = [] - env_manager = EnvManager( app ) + env_manager = EnvManager( self.app ) action_dict = env_manager.get_env_shell_file_paths_from_setup_environment_elem( all_env_shell_file_paths, action_elem, action_dict ) @@ -1247,10 +1258,11 @@ class SetupRubyEnvironment( Download, RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'setup_ruby_environment' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Initialize the environment for installing Ruby packages. The class is called during the initial @@ -1313,8 +1325,7 @@ cmd = '''PATH=$PATH:$RUBY_HOME/bin; export PATH; GEM_HOME=$INSTALL_DIR; export GEM_HOME; gem install %s''' % ( gem ) cmd = install_environment.build_command( basic_util.evaluate_template( cmd, install_environment ) ) - return_code = install_environment.handle_command( app=app, - tool_dependency=tool_dependency, + return_code = install_environment.handle_command( tool_dependency=tool_dependency, cmd=cmd, return_output=False ) if return_code: @@ -1338,7 +1349,7 @@ return tool_dependency, filtered_actions, dir return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # setup a Ruby environment. # <action type="setup_ruby_environment"> # <repository name="package_ruby_2_0" owner="bgruening"> @@ -1353,7 +1364,7 @@ # associated with each repository. This will potentially update the value of the # 'env_shell_file_paths' entry in action_dict. all_env_shell_file_paths = [] - env_manager = EnvManager( app ) + env_manager = EnvManager( self.app ) action_dict = env_manager.get_env_shell_file_paths_from_setup_environment_elem( all_env_shell_file_paths, action_elem, action_dict ) @@ -1381,10 +1392,11 @@ class SetupVirtualEnv( Download, RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'setup_virtualenv' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Initialize a virtual environment for installing packages. If initial_download is True, the recipe @@ -1395,8 +1407,8 @@ # This class is not currently used during stage 1 of the installation process, so filter_actions # are not affected, and dir is not set. Enhancements can easily be made to this function if this # class is needed in stage 1. - venv_src_directory = os.path.abspath( os.path.join( app.config.tool_dependency_dir, '__virtualenv_src' ) ) - if not self.install_virtualenv( app, install_environment, venv_src_directory ): + venv_src_directory = os.path.abspath( os.path.join( self.app.config.tool_dependency_dir, '__virtualenv_src' ) ) + if not self.install_virtualenv( install_environment, venv_src_directory ): log.debug( 'Unable to install virtualenv' ) return tool_dependency, None, None requirements = action_dict[ 'requirements' ] @@ -1438,8 +1450,7 @@ else: install_command = "%s && %s" % ( install_command, line_install_command ) full_setup_command = "%s; %s; %s" % ( setup_command, activate_command, install_command ) - return_code = install_environment.handle_command( app=app, - tool_dependency=tool_dependency, + return_code = install_environment.handle_command( tool_dependency=tool_dependency, cmd=full_setup_command, return_output=False ) if return_code: @@ -1448,7 +1459,7 @@ return tool_dependency, None, None site_packages_directory, site_packages_directory_list = \ self.__get_site_packages_directory( install_environment, - app, + self.app, tool_dependency, python_cmd, venv_directory ) @@ -1462,7 +1473,7 @@ return_code = env_file_builder.return_code return tool_dependency, None, None - def install_virtualenv( self, app, install_environment, venv_dir ): + def install_virtualenv( self, install_environment, venv_dir ): if not os.path.exists( venv_dir ): with install_environment.make_tmp_dir() as work_dir: downloaded_filename = VIRTUALENV_URL.rsplit('/', 1)[-1] @@ -1476,7 +1487,7 @@ shutil.move( full_path_to_dir, venv_dir ) return True - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # <action type="setup_virtualenv" /> ## Install requirements from file requirements.txt of downloaded bundle - or - # <action type="setup_virtualenv">tools/requirements.txt</action> @@ -1511,8 +1522,7 @@ os.path.join( venv_directory, "bin", "python" ), r"""%s -c 'import os, sys; print os.path.join( sys.prefix, "lib", "python" + sys.version[:3], "site-packages" )'""" % \ os.path.join( venv_directory, "bin", "python" ) ]: - output = install_environment.handle_command( app=app, - tool_dependency=tool_dependency, + output = install_environment.handle_command( tool_dependency=tool_dependency, cmd=site_packages_command, return_output=True ) site_packages_directory_list.append( output.stdout ) @@ -1522,10 +1532,11 @@ class ShellCommand( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'shell_command' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Execute a command in a shell. If the value of initial_download is True, the recipe steps will @@ -1546,15 +1557,14 @@ with settings( warn_only=True ): # The caller should check the status of the returned tool_dependency since this function # does nothing with return_code. - return_code = install_environment.handle_command( app=app, - tool_dependency=tool_dependency, + return_code = install_environment.handle_command( tool_dependency=tool_dependency, cmd=cmd, return_output=False ) if initial_download: return tool_dependency, filtered_actions, dir return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # <action type="shell_command">make</action> action_elem_text = basic_util.evaluate_template( action_elem.text, install_environment ) if action_elem_text: @@ -1564,10 +1574,11 @@ class TemplateCommand( RecipeStep ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.type = 'template_command' - def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + def execute_step( self, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, current_dir=None, initial_download=False ): """ Execute a template command in a shell. If the value of initial_download is True, the recipe steps @@ -1586,13 +1597,12 @@ cmd = fill_template( '#from fabric.api import env\n%s' % action_dict[ 'command' ], context=env_vars ) # The caller should check the status of the returned tool_dependency since this function # does nothing with return_code. - return_code = install_environment.handle_command( app=app, - tool_dependency=tool_dependency, + return_code = install_environment.handle_command( tool_dependency=tool_dependency, cmd=cmd, return_output=False ) return tool_dependency, None, None - def prepare_step( self, app, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): + def prepare_step( self, tool_dependency, action_elem, action_dict, install_environment, is_binary_download ): # Default to Cheetah as it's the first template language supported. language = action_elem.get( 'language', 'cheetah' ).lower() if language == 'cheetah': diff -r ac9a4a915fdef0fb425e7146637d551066844af7 -r fa69b6d3cafdc18e2531cfd015676223f33cee67 lib/tool_shed/galaxy_install/tool_dependencies/recipe/tag_handler.py --- a/lib/tool_shed/galaxy_install/tool_dependencies/recipe/tag_handler.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/recipe/tag_handler.py @@ -20,24 +20,25 @@ class RecipeTag( object ): """Abstract class that defines a standard format for handling recipe tags when installing packages.""" - def process_tag_set( app, tool_shed_repository, tool_dependency, package_elem, package_name, package_version, + def process_tag_set( tool_shed_repository, tool_dependency, package_elem, package_name, package_version, from_tool_migration_manager=False, tool_dependency_db_records=None ): raise "Unimplemented Method" class Install( RecipeTag ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.tag = 'install' - def process_tag_set( self, app, tool_shed_repository, tool_dependency, package_elem, package_name, package_version, + def process_tag_set( self, tool_shed_repository, tool_dependency, package_elem, package_name, package_version, from_tool_migration_manager=False, tool_dependency_db_records=None ): # <install version="1.0"> # Get the installation directory for tool dependencies that will be installed for the received tool_shed_repository. actions_elem_tuples = [] proceed_with_install = False install_dir = \ - tool_dependency_util.get_tool_dependency_install_dir( app=app, + tool_dependency_util.get_tool_dependency_install_dir( app=self.app, repository_name=tool_shed_repository.name, repository_owner=tool_shed_repository.owner, repository_changeset_revision=tool_shed_repository.installed_changeset_revision, @@ -57,7 +58,7 @@ else: # Notice that we'll throw away the following tool_dependency if it can be installed. tool_dependency, proceed_with_install = \ - tool_dependency_util.sync_database_with_file_system( app, + tool_dependency_util.sync_database_with_file_system( self.app, tool_shed_repository, package_name, package_version, @@ -71,9 +72,9 @@ proceed_with_install = True if proceed_with_install: package_install_version = package_elem.get( 'version', '1.0' ) - status = app.install_model.ToolDependency.installation_status.INSTALLING + status = self.app.install_model.ToolDependency.installation_status.INSTALLING tool_dependency = \ - tool_dependency_util.create_or_update_tool_dependency( app=app, + tool_dependency_util.create_or_update_tool_dependency( app=self.app, tool_shed_repository=tool_shed_repository, name=package_name, version=package_version, @@ -95,7 +96,7 @@ error_message += 'tag set.' # Since there was an installation error, update the tool dependency status to Error. # The remove_installation_path option must be left False here. - tool_dependency = tool_dependency_util.handle_tool_dependency_installation_error( app, + tool_dependency = tool_dependency_util.handle_tool_dependency_installation_error( self.app, tool_dependency, error_message, remove_installation_path=False ) @@ -106,29 +107,30 @@ class Package( RecipeTag ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.tag = 'package' - def process_tag_set( self, app, tool_shed_repository, tool_dependency, package_elem, package_name, package_version, + def process_tag_set( self, tool_shed_repository, tool_dependency, package_elem, package_name, package_version, from_tool_migration_manager=False, tool_dependency_db_records=None ): action_elem_tuples = [] proceed_with_install = False # Only install the tool_dependency if it is not already installed and it is associated with a database # record in the received tool_dependencies. if package_name and package_version: - dependencies_ignored = not app.toolbox.dependency_manager.uses_tool_shed_dependencies() + dependencies_ignored = not self.app.toolbox.dependency_manager.uses_tool_shed_dependencies() if dependencies_ignored: attr_tups_of_dependencies_for_install = [] log.debug( "Skipping installation of tool dependency package %s because tool shed dependency resolver not enabled." % \ str( package_name ) ) # Tool dependency resolves have been configured and they do not include the tool shed. Do not install package. - if app.toolbox.dependency_manager.find_dep( package_name, package_version, type='package') != INDETERMINATE_DEPENDENCY: + if self.app.toolbox.dependency_manager.find_dep( package_name, package_version, type='package') != INDETERMINATE_DEPENDENCY: ## TODO: Do something here such as marking it installed or configured externally. pass tool_dependency = \ - tool_dependency_util.set_tool_dependency_attributes( app, + tool_dependency_util.set_tool_dependency_attributes( self.app, tool_dependency=tool_dependency, - status=app.install_model.ToolDependency.installation_status.ERROR, + status=self.app.install_model.ToolDependency.installation_status.ERROR, error_message=None, remove_from_disk=False ) else: @@ -142,10 +144,11 @@ class ReadMe( RecipeTag ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.tag = 'readme' - def process_tag_set( self, app, tool_shed_repository, tool_dependency, package_elem, package_name, package_version, + def process_tag_set( self, tool_shed_repository, tool_dependency, package_elem, package_name, package_version, from_tool_migration_manager=False, tool_dependency_db_records=None ): # Nothing to be done. action_elem_tuples = [] @@ -155,12 +158,13 @@ class Repository( RecipeTag ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.tag = 'repository' - def create_temporary_tool_dependencies_config( self, app, tool_shed_url, name, owner, changeset_revision ): + def create_temporary_tool_dependencies_config( self, tool_shed_url, name, owner, changeset_revision ): """Make a call to the tool shed to get the required repository's tool_dependencies.xml file.""" - tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry( app, tool_shed_url ) + tool_shed_url = common_util.get_tool_shed_url_from_tool_shed_registry( self.app, tool_shed_url ) if tool_shed_url is None or name is None or owner is None or changeset_revision is None: message = "Unable to retrieve required tool_dependencies.xml file from the Tool Shed because one or more of the " message += "following required parameters is None: tool_shed_url: %s, name: %s, owner: %s, changeset_revision: %s " % \ @@ -169,7 +173,7 @@ params = '?name=%s&owner=%s&changeset_revision=%s' % ( name, owner, changeset_revision ) url = common_util.url_join( tool_shed_url, 'repository/get_tool_dependencies_config_contents%s' % params ) - text = common_util.tool_shed_get( app, tool_shed_url, url ) + text = common_util.tool_shed_get( self.app, tool_shed_url, url ) if text: # Write the contents to a temporary file on disk so it can be reloaded and parsed. fh = tempfile.NamedTemporaryFile( 'wb', prefix="tmp-toolshed-cttdc" ) @@ -185,7 +189,7 @@ raise Exception( message ) return None - def create_tool_dependency_with_initialized_env_sh_file( self, app, dependent_install_dir, tool_shed_repository, + def create_tool_dependency_with_initialized_env_sh_file( self, dependent_install_dir, tool_shed_repository, required_repository, package_name, package_version, tool_dependencies_config ): """ Create or get a tool_dependency record that is defined by the received package_name and package_version. @@ -215,7 +219,7 @@ # Check the database to see if we have a record for the required tool dependency (we may not which is ok). If we # find a record, we need to see if it is in an error state and if so handle it appropriately. required_tool_dependency = \ - tool_dependency_util.get_tool_dependency_by_name_version_type_repository( app, + tool_dependency_util.get_tool_dependency_by_name_version_type_repository( self.app, required_repository, required_td_package_name, required_td_package_version, @@ -223,29 +227,29 @@ if required_td_package_name == package_name and required_td_package_version == package_version: # Get or create a database tool_dependency record with which the installed package on disk will be associated. tool_dependency = \ - tool_dependency_util.create_or_update_tool_dependency( app=app, + tool_dependency_util.create_or_update_tool_dependency( app=self.app, tool_shed_repository=tool_shed_repository, name=package_name, version=package_version, type='package', - status=app.install_model.ToolDependency.installation_status.NEVER_INSTALLED, + status=self.app.install_model.ToolDependency.installation_status.NEVER_INSTALLED, set_status=True ) # Create an env.sh file for the tool_dependency whose first line will source the env.sh file located in # the path defined by required_tool_dependency_env_file_path. It doesn't matter if the required env.sh # file currently exists.. required_tool_dependency_env_file_path = \ - tool_dependency_util.get_required_repository_package_env_sh_path( app, + tool_dependency_util.get_required_repository_package_env_sh_path( self.app, package_name, package_version, required_repository ) - env_file_builder = EnvFileBuilder( tool_dependency.installation_directory( app ) ) + env_file_builder = EnvFileBuilder( tool_dependency.installation_directory( self.app ) ) env_file_builder.append_line( action="source", value=required_tool_dependency_env_file_path ) return_code = env_file_builder.return_code if return_code: error_message = 'Error defining env.sh file for package %s, return_code: %s' % \ ( str( package_name ), str( return_code ) ) tool_dependency = \ - tool_dependency_util.handle_tool_dependency_installation_error( app, + tool_dependency_util.handle_tool_dependency_installation_error( self.app, tool_dependency, error_message, remove_installation_path=False ) @@ -253,47 +257,47 @@ error_message = "This tool dependency's required tool dependency %s version %s has status %s." % \ ( str( required_tool_dependency.name ), str( required_tool_dependency.version ), str( required_tool_dependency.status ) ) tool_dependency = \ - tool_dependency_util.handle_tool_dependency_installation_error( app, + tool_dependency_util.handle_tool_dependency_installation_error( self.app, tool_dependency, error_message, remove_installation_path=False ) else: tool_dependency = \ - tool_dependency_util.set_tool_dependency_attributes( app, + tool_dependency_util.set_tool_dependency_attributes( self.app, tool_dependency=tool_dependency, - status=app.install_model.ToolDependency.installation_status.INSTALLED ) + status=self.app.install_model.ToolDependency.installation_status.INSTALLED ) tool_dependencies.append( tool_dependency ) return tool_dependencies - def get_tool_shed_repository_by_tool_shed_name_owner_changeset_revision( self, app, tool_shed_url, name, owner, changeset_revision ): - sa_session = app.install_model.context + def get_tool_shed_repository_by_tool_shed_name_owner_changeset_revision( self, tool_shed_url, name, owner, changeset_revision ): + sa_session = self.app.install_model.context # The protocol is not stored, but the port is if it exists. tool_shed = common_util.remove_protocol_from_tool_shed_url( tool_shed_url ) - tool_shed_repository = sa_session.query( app.install_model.ToolShedRepository ) \ - .filter( and_( app.install_model.ToolShedRepository.table.c.tool_shed == tool_shed, - app.install_model.ToolShedRepository.table.c.name == name, - app.install_model.ToolShedRepository.table.c.owner == owner, - app.install_model.ToolShedRepository.table.c.changeset_revision == changeset_revision ) ) \ + tool_shed_repository = sa_session.query( self.app.install_model.ToolShedRepository ) \ + .filter( and_( self.app.install_model.ToolShedRepository.table.c.tool_shed == tool_shed, + self.app.install_model.ToolShedRepository.table.c.name == name, + self.app.install_model.ToolShedRepository.table.c.owner == owner, + self.app.install_model.ToolShedRepository.table.c.changeset_revision == changeset_revision ) ) \ .first() if tool_shed_repository: return tool_shed_repository # The tool_shed_repository must have been updated to a newer changeset revision than the one defined in the repository_dependencies.xml file, # so call the tool shed to get all appropriate newer changeset revisions. - text = suc.get_updated_changeset_revisions_from_tool_shed( app, tool_shed_url, name, owner, changeset_revision ) + text = suc.get_updated_changeset_revisions_from_tool_shed( self.app, tool_shed_url, name, owner, changeset_revision ) if text: changeset_revisions = listify( text ) for changeset_revision in changeset_revisions: - tool_shed_repository = sa_session.query( app.install_model.ToolShedRepository ) \ - .filter( and_( app.install_model.ToolShedRepository.table.c.tool_shed == tool_shed, - app.install_model.ToolShedRepository.table.c.name == name, - app.install_model.ToolShedRepository.table.c.owner == owner, - app.install_model.ToolShedRepository.table.c.changeset_revision == changeset_revision ) ) \ + tool_shed_repository = sa_session.query( self.app.install_model.ToolShedRepository ) \ + .filter( and_( self.app.install_model.ToolShedRepository.table.c.tool_shed == tool_shed, + self.app.install_model.ToolShedRepository.table.c.name == name, + self.app.install_model.ToolShedRepository.table.c.owner == owner, + self.app.install_model.ToolShedRepository.table.c.changeset_revision == changeset_revision ) ) \ .first() if tool_shed_repository: return tool_shed_repository return None - def handle_complex_repository_dependency_for_package( self, app, elem, package_name, package_version, tool_shed_repository, + def handle_complex_repository_dependency_for_package( self, elem, package_name, package_version, tool_shed_repository, from_tool_migration_manager=False ): """ Inspect the repository defined by a complex repository dependency definition and take certain steps to @@ -310,8 +314,7 @@ required_repository_owner = elem.attrib[ 'owner' ] default_required_repository_changeset_revision = elem.attrib[ 'changeset_revision' ] required_repository = \ - self.get_tool_shed_repository_by_tool_shed_name_owner_changeset_revision( app, - tool_shed, + self.get_tool_shed_repository_by_tool_shed_name_owner_changeset_revision( tool_shed, required_repository_name, required_repository_owner, default_required_repository_changeset_revision ) @@ -320,7 +323,7 @@ required_repository_changeset_revision = required_repository.installed_changeset_revision # Define the installation directory for the required tool dependency package in the required repository. required_repository_package_install_dir = \ - tool_dependency_util.get_tool_dependency_install_dir( app=app, + tool_dependency_util.get_tool_dependency_install_dir( app=self.app, repository_name=required_repository_name, repository_owner=required_repository_owner, repository_changeset_revision=required_repository_changeset_revision, @@ -330,7 +333,7 @@ # Define this dependent repository's tool dependency installation directory that will contain # the env.sh file with a path to the required repository's installed tool dependency package. dependent_install_dir = \ - tool_dependency_util.get_tool_dependency_install_dir( app=app, + tool_dependency_util.get_tool_dependency_install_dir( app=self.app, repository_name=tool_shed_repository.name, repository_owner=tool_shed_repository.owner, repository_changeset_revision=tool_shed_repository.installed_changeset_revision, @@ -350,7 +353,7 @@ else: # Notice that we'll throw away the following tool_dependency if it can be installed. tool_dependency, can_install_tool_dependency = \ - tool_dependency_util.sync_database_with_file_system( app, + tool_dependency_util.sync_database_with_file_system( self.app, tool_shed_repository, package_name, package_version, @@ -370,7 +373,7 @@ if required_repository.is_deactivated_or_installed: if not os.path.exists( required_repository_package_install_dir ): print 'Missing required tool dependency directory %s' % str( required_repository_package_install_dir ) - repo_files_dir = required_repository.repo_files_directory( app ) + repo_files_dir = required_repository.repo_files_directory( self.app ) tool_dependencies_config = suc.get_absolute_path_to_file_in_repository( repo_files_dir, 'tool_dependencies.xml' ) if tool_dependencies_config: config_to_use = tool_dependencies_config @@ -381,7 +384,7 @@ else: # Make a call to the tool shed to get the changeset revision to which the current value of required_repository_changeset_revision # should be updated if it's not current. - text = suc.get_updated_changeset_revisions_from_tool_shed( app=app, + text = suc.get_updated_changeset_revisions_from_tool_shed( app=self.app, tool_shed_url=tool_shed, name=required_repository_name, owner=required_repository_owner, @@ -391,15 +394,13 @@ # The list of changeset revisions is in reverse order, so the newest will be first. required_repository_changeset_revision = updated_changeset_revisions[ 0 ] # Make a call to the tool shed to get the required repository's tool_dependencies.xml file. - tmp_filename = self.create_temporary_tool_dependencies_config( app, - tool_shed, + tmp_filename = self.create_temporary_tool_dependencies_config( tool_shed, required_repository_name, required_repository_owner, required_repository_changeset_revision ) config_to_use = tmp_filename handled_tool_dependencies = \ - self.create_tool_dependency_with_initialized_env_sh_file( app=app, - dependent_install_dir=dependent_install_dir, + self.create_tool_dependency_with_initialized_env_sh_file( dependent_install_dir=dependent_install_dir, tool_shed_repository=tool_shed_repository, required_repository=required_repository, package_name=package_name, @@ -412,19 +413,18 @@ raise Exception( message ) return handled_tool_dependencies - def process_tag_set( self, app, tool_shed_repository, tool_dependency, package_elem, package_name, package_version, + def process_tag_set( self, tool_shed_repository, tool_dependency, package_elem, package_name, package_version, from_tool_migration_manager=False, tool_dependency_db_records=None ): # We have a complex repository dependency definition. action_elem_tuples = [] proceed_with_install = False - rd_tool_dependencies = self.handle_complex_repository_dependency_for_package( app, - package_elem, + rd_tool_dependencies = self.handle_complex_repository_dependency_for_package( package_elem, package_name, package_version, tool_shed_repository, from_tool_migration_manager=from_tool_migration_manager ) for rd_tool_dependency in rd_tool_dependencies: - if rd_tool_dependency.status == app.install_model.ToolDependency.installation_status.ERROR: + if rd_tool_dependency.status == self.app.install_model.ToolDependency.installation_status.ERROR: # We'll log the error here, but continue installing packages since some may not require this dependency. print "Error installing tool dependency for required repository: %s" % str( rd_tool_dependency.error_message ) return tool_dependency, proceed_with_install, action_elem_tuples @@ -441,10 +441,11 @@ class SetEnvironment( RecipeTag ): - def __init__( self ): + def __init__( self, app ): + self.app = app self.tag = 'set_environment' - def process_tag_set( self, app, tool_shed_repository, tool_dependency, package_elem, package_name, package_version, + def process_tag_set( self, tool_shed_repository, tool_dependency, package_elem, package_name, package_version, from_tool_migration_manager=False, tool_dependency_db_records=None ): # We need to handle two tag sets for package_elem here, this: # <set_environment version="1.0"> @@ -459,21 +460,21 @@ else: attr_tups_of_dependencies_for_install = [ ( td.name, td.version, td.type ) for td in tool_dependency_db_records ] try: - tool_dependencies = self.set_environment( app, package_elem, tool_shed_repository, attr_tups_of_dependencies_for_install ) + tool_dependencies = self.set_environment( package_elem, tool_shed_repository, attr_tups_of_dependencies_for_install ) except Exception, e: error_message = "Error setting environment for tool dependency: %s" % str( e ) log.debug( error_message ) for tool_dependency in tool_dependencies: - if tool_dependency and tool_dependency.status == app.install_model.ToolDependency.installation_status.ERROR: + if tool_dependency and tool_dependency.status == self.app.install_model.ToolDependency.installation_status.ERROR: # Since there was an installation error, update the tool dependency status to Error. The # remove_installation_path option must be left False here. - tool_dependency = tool_dependency_util.handle_tool_dependency_installation_error( app, + tool_dependency = tool_dependency_util.handle_tool_dependency_installation_error( self.app, tool_dependency, error_message, remove_installation_path=False ) return tool_dependency, proceed_with_install, action_elem_tuples - def set_environment( self, app, elem, tool_shed_repository, attr_tups_of_dependencies_for_install ): + def set_environment( self, elem, tool_shed_repository, attr_tups_of_dependencies_for_install ): """ Create a ToolDependency to set an environment variable. This is different from the process used to set an environment variable that is associated with a package. An example entry in a tool_dependencies.xml @@ -497,10 +498,10 @@ # <set_environment version="1.0"> # <repository toolshed="<tool shed>" name="<repository name>" owner="<repository owner>" changeset_revision="<changeset revision>" /> # </set_environment> - env_manager = EnvManager( app ) + env_manager = EnvManager( self.app ) tool_dependencies = [] env_var_version = elem.get( 'version', '1.0' ) - tool_shed_repository_install_dir = os.path.abspath( tool_shed_repository.repo_files_directory( app ) ) + tool_shed_repository_install_dir = os.path.abspath( tool_shed_repository.repo_files_directory( self.app ) ) if elem.tag == 'environment_variable': # <environment_variable name="R_SCRIPT_PATH" action="set_to">$REPOSITORY_INSTALL_DIR</environment_variable> elems = [ elem ] @@ -520,23 +521,24 @@ attr_tup = ( env_var_name, None, 'set_environment' ) if attr_tup in attr_tups_of_dependencies_for_install: install_dir = \ - tool_dependency_util.get_tool_dependency_install_dir( app=app, + tool_dependency_util.get_tool_dependency_install_dir( app=self.app, repository_name=tool_shed_repository.name, repository_owner=tool_shed_repository.owner, repository_changeset_revision=tool_shed_repository.installed_changeset_revision, tool_dependency_type='set_environment', tool_dependency_name=env_var_name, tool_dependency_version=None ) - install_environment = InstallEnvironment( tool_shed_repository_install_dir=tool_shed_repository_install_dir, + install_environment = InstallEnvironment( app=self.app, + tool_shed_repository_install_dir=tool_shed_repository_install_dir, install_dir=install_dir ) env_var_dict = env_manager.create_env_var_dict( elem=env_var_elem, install_environment=install_environment ) if env_var_dict: if not os.path.exists( install_dir ): os.makedirs( install_dir ) - status = app.install_model.ToolDependency.installation_status.INSTALLING + status = self.app.install_model.ToolDependency.installation_status.INSTALLING tool_dependency = \ - tool_dependency_util.create_or_update_tool_dependency( app=app, + tool_dependency_util.create_or_update_tool_dependency( app=self.app, tool_shed_repository=tool_shed_repository, name=env_var_name, version=None, @@ -551,19 +553,19 @@ error_message = 'Error creating env.sh file for tool dependency %s, return_code: %s' % \ ( str( tool_dependency.name ), str( return_code ) ) log.debug( error_message ) - status = app.install_model.ToolDependency.installation_status.ERROR + status = self.app.install_model.ToolDependency.installation_status.ERROR tool_dependency = \ - tool_dependency_util.set_tool_dependency_attributes( app, + tool_dependency_util.set_tool_dependency_attributes( self.app, tool_dependency=tool_dependency, status=status, error_message=error_message, remove_from_disk=False ) else: - if tool_dependency.status not in [ app.install_model.ToolDependency.installation_status.ERROR, - app.install_model.ToolDependency.installation_status.INSTALLED ]: - status = app.install_model.ToolDependency.installation_status.INSTALLED + if tool_dependency.status not in [ self.app.install_model.ToolDependency.installation_status.ERROR, + self.app.install_model.ToolDependency.installation_status.INSTALLED ]: + status = self.app.install_model.ToolDependency.installation_status.INSTALLED tool_dependency = \ - tool_dependency_util.set_tool_dependency_attributes( app, + tool_dependency_util.set_tool_dependency_attributes( self.app, tool_dependency=tool_dependency, status=status, error_message=None, @@ -572,9 +574,9 @@ ( str( env_var_name ), str( install_dir ), str( tool_dependency.name ) ) ) else: error_message = 'Only set_environment version 1.0 is currently supported (i.e., change your tag to be <set_environment version="1.0">).' - status = app.install_model.ToolDependency.installation_status.ERROR + status = self.app.install_model.ToolDependency.installation_status.ERROR tool_dependency = \ - tool_dependency_util.set_tool_dependency_attributes( app, + tool_dependency_util.set_tool_dependency_attributes( self.app, tool_dependency=tool_dependency, status=status, error_message=error_message, diff -r ac9a4a915fdef0fb425e7146637d551066844af7 -r fa69b6d3cafdc18e2531cfd015676223f33cee67 lib/tool_shed/util/common_install_util.py --- a/lib/tool_shed/util/common_install_util.py +++ b/lib/tool_shed/util/common_install_util.py @@ -17,8 +17,6 @@ from tool_shed.util import tool_util from tool_shed.util import xml_util -from tool_shed.galaxy_install.tool_dependencies.recipe.recipe_manager import TagManager - log = logging.getLogger( __name__ ) def activate_repository( app, repository ): 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.