Example #1
0
 def unpack(source_path, dest_dir):
     with_progress = not app.is_disabled_progressbar()
     try:
         with FileUnpacker(source_path) as fu:
             return fu.unpack(dest_dir, with_progress=with_progress)
     except IOError as e:
         if not with_progress:
             raise e
         with FileUnpacker(source_path) as fu:
             return fu.unpack(dest_dir, with_progress=False)
Example #2
0
    def pack(self, dst=None):
        tmp_dir = tempfile.mkdtemp()
        try:
            src = self.package

            # if zip/tar.gz -> unpack to tmp dir
            if not os.path.isdir(src):
                with FileUnpacker(src) as fu:
                    assert fu.unpack(tmp_dir, silent=True)
                src = tmp_dir

            src = self.find_source_root(src)

            manifest = self.load_manifest(src)
            filename = re.sub(
                r"[^\da-zA-Z\-\._]+",
                "",
                "{name}{system}-{version}.tar.gz".format(
                    name=manifest["name"],
                    system="-" +
                    manifest["system"][0] if "system" in manifest else "",
                    version=manifest["version"],
                ),
            )

            if not dst:
                dst = os.path.join(os.getcwd(), filename)
            elif os.path.isdir(dst):
                dst = os.path.join(dst, filename)

            return self._create_tarball(
                src,
                dst,
                include=manifest.get("export", {}).get("include"),
                exclude=manifest.get("export", {}).get("exclude"),
            )
        finally:
            shutil.rmtree(tmp_dir)
Example #3
0
 def unpack(pkgpath, dest_dir):
     fu = FileUnpacker(pkgpath, dest_dir)
     return fu.start()
Example #4
0
 def unpack(source_path, dest_dir):
     with FileUnpacker(source_path) as fu:
         return fu.unpack(dest_dir)
Example #5
0
 def unpack(pkgpath, dest_dir):
     fu = FileUnpacker(pkgpath, dest_dir)
     return fu.start()
 def unpack(source_path, dest_dir):
     fu = FileUnpacker(source_path, dest_dir)
     return fu.start()
Example #7
0
 def unpack(source_path, dest_dir):
     fu = FileUnpacker(source_path, dest_dir)
     return fu.start()