From 20579ebd50c8e11d2f0bac45d3b0f71e1d732466 Mon Sep 17 00:00:00 2001 From: Nicola Soranzo Date: Mon, 19 Oct 2015 12:02:45 +0100 Subject: [PATCH] Add a log.warn() if extracted file does not exist when changing permissions. Should help to debug issue reported in PR #792. --- .../tool_dependencies/recipe/step_handler.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py b/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py index dbcc1e3f3ec..e467b346c7c 100755 --- a/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py +++ b/lib/tool_shed/galaxy_install/tool_dependencies/recipe/step_handler.py @@ -53,7 +53,7 @@ class CompressedFile( object ): def extract( self, path ): '''Determine the path to which the archive should be extracted.''' contents = self.getmembers() - extraction_path = os.path.join( path ) + extraction_path = path common_prefix = '' if len( contents ) == 1: # The archive contains a single file, return the extraction path. @@ -84,8 +84,11 @@ class CompressedFile( object ): external_attributes = self.archive.getinfo( filename ).external_attr # The 2 least significant bytes are irrelevant, the next two contain unix permissions. unix_permissions = external_attributes >> 16 - if unix_permissions != 0 and os.path.exists( absolute_filepath ): - os.chmod( absolute_filepath, unix_permissions ) + if unix_permissions != 0: + if os.path.exists( absolute_filepath ): + os.chmod( absolute_filepath, unix_permissions ) + else: + log.warn("Unable to change permission on extracted file '%s' as it does not exist" % absolute_filepath) return os.path.abspath( os.path.join( extraction_path, common_prefix ) ) def getmembers_tar( self ):