changeset 19:c54db80d6e7f

fix test
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 27 Feb 2012 12:58:08 -0800
parents 4c4d1e194bf7
children 11bc01a089e7
files paint/package.py
diffstat 1 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/paint/package.py	Fri Feb 24 16:13:13 2012 -0800
+++ b/paint/package.py	Mon Feb 27 12:58:08 2012 -0800
@@ -4,11 +4,18 @@
 
 import os
 import shutil
+import subprocess
+import sys
 import tarfile
 import tempfile
 import urllib2
 import utils
 
+try:
+    from subprocess import check_call as call
+except ImportError:
+    from subporcess import call
+
 __all__ = ['Package']
 
 class Package(object):
@@ -60,7 +67,20 @@
         assert tarfile.is_tarfile(archive), "%s is not an archive" % self.src
         tf = tarfile.TarFile.open(archive)
         self._tmppath = tempfile.mkdtemp()
-        tf.extractall(path=self._tmppath)
+        members = tf.getmembers()
+
+        # cut off the top level directory
+        assert not [i for i in members if not os.path.sep in i.name]
+        tld = set()
+        for member in members:
+            directory, member.name = member.name.split(os.path.sep, 1)
+            tld.add(directory)
+        assert len(tld) == 1
+
+        # extract
+        for member in members:
+            tf.extract(member, path=self._tmppath)
+        tf.close()
 
     def is_archive(self, path):
         """returns if the filesystem path is an archive"""
@@ -90,7 +110,7 @@
             raise AssertionError("%s does not exist" % setup_py)
 
         # setup the egg info
-        call([sys.executable, 'setup.py', 'egg_info'], cwd=directory, stdout=PIPE)
+        call([sys.executable, 'setup.py', 'egg_info'], cwd=directory, stdout=subprocess.PIPE)
 
         # get the .egg-info directory
         egg_info = [i for i in os.listdir(directory)