1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/dc9fb7fba975/ Changeset: dc9fb7fba975 User: greg Date: 2014-04-28 13:03:37 Summary: A bit of rework for recently introduced assert action types for tool dependency package install recipes: 1) assert_file_exists - true for both files and symlinks, but false if path is a directory 2) assert_file_executable - true for both files and symlinks but false if path is a directory 3) assert_directory_exists - true for both directories and symlinks, but false if path is a file 4) assert_directory_executable - true for both directories and symlinks, but false if path is a file. Affected #: 3 files diff -r 56dd83576ce67763863b61ad85104f8d14d978e0 -r dc9fb7fba975f6169d9ee8eb257bf477d7d4274c 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 @@ -414,7 +414,8 @@ return tool_dependency, filtered_actions, dir def load_step_handlers( self ): - step_handlers_by_type = dict( assert_directory_exists=step_handler.AssertDirectoryExists(), + 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(), diff -r 56dd83576ce67763863b61ad85104f8d14d978e0 -r dc9fb7fba975f6169d9ee8eb257bf477d7d4274c 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 @@ -36,6 +36,39 @@ raise "Unimplemented Method" +class AssertDirectoryExecutable( RecipeStep ): + + def __init__( self ): + self.type = 'assert_directory_executable' + + def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, + install_environment, work_dir, install_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. + Since this class is not used in the initial download stage, no recipe step filtering is + performed here, and None values are always returned for filtered_actions and dir. + """ + if os.path.isabs( action_dict[ 'full_path' ] ): + full_path = action_dict[ 'full_path' ] + else: + full_path = os.path.join( current_dir, action_dict[ 'full_path' ] ) + if not td_common_util.assert_directory_executable( full_path=full_path ): + status = 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, + 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_dir, is_binary_download ): + # <action type="assert_executable">$INSTALL_DIR/mira/my_file</action> + if action_elem.text: + action_dict[ 'full_path' ] = td_common_util.evaluate_template( action_elem.text, install_dir ) + return action_dict + + class AssertDirectoryExists( RecipeStep ): def __init__( self ): @@ -44,9 +77,9 @@ def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, install_dir, current_dir=None, initial_download=False ): """ - Make sure a directory on disk exists. Since this class is not used in the initial download stage, - no recipe step filtering is performed here, and None values are always returned for filtered_actions - and dir. + Make sure a a symbolic link or directory on disk exists, but is not a file. Since this + class is not used in the initial download stage, no recipe step filtering is performed + here, and None values are always returned for filtered_actions and dir. """ if os.path.isabs( action_dict[ 'full_path' ] ): full_path = action_dict[ 'full_path' ] @@ -54,7 +87,7 @@ full_path = os.path.join( current_dir, action_dict[ 'full_path' ] ) if not td_common_util.assert_directory_exists( full_path=full_path ): status = app.install_model.ToolDependency.installation_status.ERROR - error_message = 'The required directory %s does not exist.' % str( full_path ) + 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, status=status, @@ -77,9 +110,9 @@ def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, install_dir, current_dir=None, initial_download=False ): """ - Make sure a file on disk exists and is executable. Since this class is not used in the initial - download stage, no recipe step filtering is performed here, and None values are always returned - for filtered_actions and dir. + Make sure a symbolic link or file on disk exists and is executable, but is not a directory. + Since this class is not used in the initial download stage, no recipe step filtering is + performed here, and None values are always returned for filtered_actions and dir. """ if os.path.isabs( action_dict[ 'full_path' ] ): full_path = action_dict[ 'full_path' ] @@ -87,7 +120,7 @@ full_path = os.path.join( current_dir, action_dict[ 'full_path' ] ) if not td_common_util.assert_file_executable( full_path=full_path ): status = app.install_model.ToolDependency.installation_status.ERROR - error_message = 'The file %s is not executable by the owner.' % str( full_path ) + 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, status=status, @@ -110,9 +143,9 @@ def execute_step( self, app, tool_dependency, package_name, actions, action_dict, filtered_actions, env_file_builder, install_environment, work_dir, install_dir, current_dir=None, initial_download=False ): """ - Make sure a file on disk exists. Since this class is not used in the initial download stage, - no recipe step filtering is performed here, and None values are always returned for - filtered_actions and dir. + Make sure a symbolic link or file on disk exists, but is not a directory. Since this + class is not used in the initial download stage, no recipe step filtering is performed + here, and None values are always returned for filtered_actions and dir. """ if os.path.isabs( action_dict[ 'full_path' ] ): full_path = action_dict[ 'full_path' ] @@ -120,7 +153,7 @@ full_path = os.path.join( current_dir, action_dict[ 'full_path' ] ) if not td_common_util.assert_file_exists( full_path=full_path ): status = app.install_model.ToolDependency.installation_status.ERROR - error_message = 'The required file %s does not exist.' % str( full_path ) + 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, status=status, diff -r 56dd83576ce67763863b61ad85104f8d14d978e0 -r dc9fb7fba975f6169d9ee8eb257bf477d7d4274c lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py --- a/lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/td_common_util.py @@ -111,31 +111,63 @@ def open_zip( self, filepath, mode ): return zipfile.ZipFile( filepath, mode ) -def assert_directory_exists( full_path ): - """Return True if a directory exists and is not a symbolic link.""" - if os.path.islink( full_path ): +def assert_directory_executable( full_path ): + """ + Return True if a symbolic link or directory exists and is executable, but if + full_path is a file, return False. + """ + if full_path is None: return False - if os.path.is_dir( full_path ): - return True + if os.path.isfile( full_path ): + return False + if os.path.isdir( full_path ): + # Make sure the owner has execute permission on the directory. + # See http://docs.python.org/2/library/stat.html + if stat.S_IXUSR & os.stat( full_path )[ stat.ST_MODE ] == 64: + return True return False -def assert_file_exists( full_path ): - """Return True if a file exists. This will work for both symbolic linke and files.""" - if os.path.exists( full_path ): +def assert_directory_exists( full_path ): + """ + Return True if a symbolic link or directory exists, but if full_path is a file, + return False. """ + if full_path is None: + return False + if os.path.isfile( full_path ): + return False + if os.path.isdir( full_path ): return True return False def assert_file_executable( full_path ): - """Return True if a file exists and is executable.""" - if os.path.islink( full_path ): + """ + Return True if a symbolic link or file exists and is executable, but if full_path + is a directory, return False. + """ + if full_path is None: return False - if os.path.is_file( full_path ): + if os.path.isdir( full_path ): + return False + if os.path.exists( full_path ): # Make sure the owner has execute permission on the file. # See http://docs.python.org/2/library/stat.html if stat.S_IXUSR & os.stat( full_path )[ stat.ST_MODE ] == 64: return True return False +def assert_file_exists( full_path ): + """ + Return True if a symbolic link or file exists, but if full_path is a directory, + return False. + """ + if full_path is None: + return False + if os.path.isdir( full_path ): + return False + if os.path.exists( full_path ): + return True + return False + def create_env_var_dict( elem, tool_dependency_install_dir=None, tool_shed_repository_install_dir=None ): env_var_name = elem.get( 'name', 'PATH' ) env_var_action = elem.get( 'action', 'prepend_to' ) 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.