Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
bug 729344 - remove extract() until it works properly. r=jhammel
Browse files Browse the repository at this point in the history
  • Loading branch information
escapewindow committed Feb 22, 2012
1 parent 346f627 commit cb0e929
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 171 deletions.
105 changes: 0 additions & 105 deletions examples/test_browser.py

This file was deleted.

66 changes: 0 additions & 66 deletions mozharness/base/script.py
Expand Up @@ -185,72 +185,6 @@ def download_file(self, url, file_name=None, parent_dir=None,
return return
return file_name return file_name


def extract(self, path, extdir=None, delete=False,
error_level=ERROR, exit_code=-1):
"""
Takes in a tar or zip file and extracts it to extdir
- If extdir is not specified, extracts to os.path.dirname(path)
- If delete is set to True, deletes the bundle at path
- Returns the list of top level files that were extracted
TODO: dmg
"""
# determine directory to extract to
if extdir is None:
extdir = os.path.dirname(path)
elif not os.path.isdir(extdir):
if os.path.isfile(extdir):
self.log("%s is a file!" % extdir, level=error_level,
exit_code=exit_code)
self.mkdir_p(extdir)
self.info("Extracting %s to %s" % (os.path.abspath(path),
os.path.abspath(extdir)))
try:
if zipfile.is_zipfile(path):
bundle = zipfile.ZipFile(path)
namelist = bundle.namelist()
if hasattr(bundle, 'extractall'):
bundle.extractall(path=extdir)
# zipfile.extractall doesn't exist in Python 2.5
else:
for name in namelist:
filename = os.path.realpath(os.path.join(extdir, name))
if name.endswith("/"):
os.makedirs(filename)
else:
path = os.path.dirname(filename)
if not os.path.isdir(path):
os.makedirs(path)
dest = open(filename, "wb")
dest.write(bundle.read(name))
elif tarfile.is_tarfile(path):
bundle = tarfile.open(path)
namelist = bundle.getnames()
bundle.extractall(path=extdir)
else:
# unknown filetype
self.warning("Unsupported file type: %s" % path)
bundle.close()
except (zipfile.BadZipfile, zipfile.LargeZipFile,
tarfile.ReadError, tarfile.CompressionError):
cla = sys.exc_info()[0]
self.log("%s, Error extracting: %s" % (cla.__name__,
os.path.abspath(path)),
level=error_level, exit_code=exit_code)
return
if delete:
self.rmtree(path)

# namelist returns paths with forward slashes even in windows
top_level_files = [os.path.join(extdir, name) for name in namelist
if len(name.rstrip('/').split('/')) == 1]
# namelist doesn't include folders, append these to the list
for name in namelist:
root = os.path.join(extdir, name[:name.find('/')])
if root not in top_level_files:
top_level_files.append(root)
return top_level_files

def move(self, src, dest, log_level=INFO, error_level=ERROR, def move(self, src, dest, log_level=INFO, error_level=ERROR,
exit_code=-1): exit_code=-1):
self.log("Moving %s to %s" % (src, dest), level=log_level) self.log("Moving %s to %s" % (src, dest), level=log_level)
Expand Down

0 comments on commit cb0e929

Please sign in to comment.