Fixed the interpretation of the file extension.

My initial lack of understanding of "is" and "==".

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
Angus Salkeld 2012-05-03 23:26:25 +10:00
parent 235112febe
commit 18eb501eb0
2 changed files with 18 additions and 4 deletions

View File

@ -575,13 +575,13 @@ class SourcesHandler(object):
def _decompress(self, archive, dest_dir):
cmd_str = ''
(r, ext) = os.path.splitext(archive)
if ext is 'tar.gz' or ext is 'tgz':
if ext == '.tar.gz' or ext == '.tgz':
cmd_str = 'tar -C %s -xzf %s' % (dest_dir, archive)
elif ext is 'tar.bz2' or ext is 'tbz2':
elif ext == '.tar.bz2' or ext == '.tbz2':
cmd_str = 'tar -C %s -xjf %s' % (dest_dir, archive)
elif ext is 'zip':
elif ext == '.zip':
cmd_str = 'unzip -d %s %s' % (dest_dir, archive)
elif ext is 'tar':
elif ext == '.tar':
cmd_str = 'tar -C %s -xf %s' % (dest_dir, archive)
else:
pass

View File

@ -140,6 +140,9 @@ class MetadataTest(unittest.TestCase):
j = ''' {
"AWS::CloudFormation::Init" : {
"config" : {
"sources": {
"/home/ec2-user/sample" : "https://s3.amazonaws.com/cloudformation-examples/CloudFormationRailsSample.zip"
},
"files" : {
"/tmp/_files_test_/epel.repo" : {
"source" : "https://raw.github.com/heat-api/heat/master/README.rst",
@ -175,6 +178,17 @@ class MetadataTest(unittest.TestCase):
self.m.StubOutWithMock(os, 'chown')
self.m.StubOutWithMock(os, 'chmod')
subprocess.Popen(['su', 'root', '-c',
'wget -O /tmp/CloudFormationRailsSample.zip \
https://s3.amazonaws.com/cloudformation-examples/CloudFormationRailsSample.zip'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).AndReturn(PopenMock())
subprocess.Popen(['su', 'root', '-c',
'unzip -d /home/ec2-user/sample /tmp/CloudFormationRailsSample.zip'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).AndReturn(PopenMock())
subprocess.Popen(['su', 'root', '-c',
'wget -O /tmp/_files_test_/epel.repo \
https://raw.github.com/heat-api/heat/master/README.rst'],