From 7d0a35030ae50d9405368d36519db712896841cd Mon Sep 17 00:00:00 2001 From: Chris Alfonso Date: Mon, 21 May 2012 14:50:54 -0400 Subject: [PATCH] Fixing _decompress to handle bundled and compressed The api call to os.path.splitext returns the root and the ext; however, for a .tar.gz the ext would just be the .gz, which meant there was no handler for a file with a .gz extension. --- heat/cfntools/cfn_helper.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/heat/cfntools/cfn_helper.py b/heat/cfntools/cfn_helper.py index 841938cb..0ca2503c 100644 --- a/heat/cfntools/cfn_helper.py +++ b/heat/cfntools/cfn_helper.py @@ -581,15 +581,28 @@ class SourcesHandler(object): def _decompress(self, archive, dest_dir): cmd_str = '' + logger.debug("Decompressing") (r, ext) = os.path.splitext(archive) - if ext == '.tar.gz' or ext == '.tgz': + if ext == '.tgz': cmd_str = 'tar -C %s -xzf %s' % (dest_dir, archive) - elif ext == '.tar.bz2' or ext == '.tbz2': + elif ext == '.tbz2': cmd_str = 'tar -C %s -xjf %s' % (dest_dir, archive) elif ext == '.zip': cmd_str = 'unzip -d %s %s' % (dest_dir, archive) elif ext == '.tar': cmd_str = 'tar -C %s -xf %s' % (dest_dir, archive) + elif ext == '.gz': + (r, ext) = os.path.splitext(r) + if ext: + cmd_str = 'tar -C %s -xzf %s' % (dest_dir, archive) + else: + cmd_str = 'gunzip -c %s > %s' % (archive, dest_dir) + elif ext == 'bz2': + (r, ext) = os.path.splitext(r) + if ext: + cmd_str = 'tar -C %s -xjf %s' % (dest_dir, archive) + else: + cmd_str = 'bunzip2 -c %s > %s' % (archive, dest_dir) else: pass return CommandRunner(cmd_str) -- 2.45.2