Composer can be downloaded gzipped
authorFrederic Massart <fred@moodle.com>
Fri, 3 May 2013 04:56:35 +0000 (12:56 +0800)
committerFrederic Massart <fred@moodle.com>
Fri, 3 May 2013 04:56:35 +0000 (12:56 +0800)
lib/commands/behat.py
lib/commands/phpunit.py

index 9879ac6..00a8f2a 100644 (file)
@@ -26,6 +26,7 @@ import os
 import urllib
 import re
 import logging
+import gzip
 from time import sleep
 from lib.command import Command
 from lib.tools import process, ProcessInThread
@@ -131,7 +132,14 @@ class BehatCommand(Command):
             logging.info('Installing Composer')
             cliFile = 'behat_install_composer.php'
             cliPath = os.path.join(M.get('path'), 'behat_install_composer.php')
-            urllib.urlretrieve('http://getcomposer.org/installer', cliPath)
+            (to, headers) = urllib.urlretrieve('http://getcomposer.org/installer', cliPath)
+            if headers.dict.get('content-encoding') == 'gzip':
+                f = gzip.open(cliPath, 'r')
+                content = f.read()
+                f.close()
+                f = open(cliPath, 'w')
+                f.write(content)
+                f.close()
             M.cli('/' + cliFile, stdout=None, stderr=None)
             os.remove(cliPath)
             M.cli('composer.phar', args='install --dev', stdout=None, stderr=None)
index 32198a5..51cec73 100644 (file)
@@ -24,6 +24,7 @@ http://github.com/FMCorz/mdk
 
 import logging
 import os
+import gzip
 import urllib
 from lib.command import Command
 from lib.tools import process
@@ -75,7 +76,14 @@ class PhpunitCommand(Command):
                 logging.info('Installing Composer')
                 cliFile = 'phpunit_install_composer.php'
                 cliPath = os.path.join(M.get('path'), 'phpunit_install_composer.php')
-                urllib.urlretrieve('http://getcomposer.org/installer', cliPath)
+                (to, headers) = urllib.urlretrieve('http://getcomposer.org/installer', cliPath)
+                if headers.dict.get('content-encoding') == 'gzip':
+                    f = gzip.open(cliPath, 'r')
+                    content = f.read()
+                    f.close()
+                    f = open(cliPath, 'w')
+                    f.write(content)
+                    f.close()
                 M.cli('/' + cliFile, stdout=None, stderr=None)
                 os.remove(cliPath)
                 M.cli('composer.phar', args='install --dev', stdout=None, stderr=None)