def extracted_archive(self, archive, workdir):
     a = Archive(archive)
     d = os.path.join(workdir, 'dir')
     a.extract_archive(d)
     if archive == self.GEM:
         # append top level dir
         d = os.path.join(d, 'archive')
     return d
Beispiel #2
0
    def extract_archive(archive_path, destination):
        """
        Extracts given archive into the destination and handle all exceptions.

        :param archive_path: path to the archive to be extracted
        :param destination: path to a destination, where the archive should be extracted to
        :return:
        """
        archive = Archive(archive_path)

        try:
            archive.extract_archive(destination)
        except IOError as e:
            raise RebaseHelperError("Archive '{}' can not be extracted".format(
                archive_path)) from e
        except (EOFError, SystemError) as e:
            raise RebaseHelperError(
                "Archive '{}' is damaged".format(archive_path)) from e
Beispiel #3
0
    def extract_archive(archive_path, destination):
        """
        Extracts given archive into the destination and handle all exceptions.

        :param archive_path: path to the archive to be extracted
        :param destination: path to a destination, where the archive should be extracted to
        :return:
        """
        try:
            archive = Archive(archive_path)
        except NotImplementedError as ni_e:
            raise RebaseHelperError('%s. Supported archives are %s' % (six.text_type(ni_e),
                                    Archive.get_supported_archives()))

        try:
            archive.extract_archive(destination)
        except IOError:
            raise RebaseHelperError("Archive '%s' can not be extracted" % archive_path)
        except (EOFError, SystemError):
            raise RebaseHelperError("Archive '%s' is damaged" % archive_path)
Beispiel #4
0
 def extracted_archive(self, archive, workdir):
     a = Archive(archive)
     d = os.path.join(workdir, 'dir')
     a.extract_archive(d)
     return d
 def test_invalid_archive(self, archive, workdir):
     a = Archive(archive)
     d = os.path.join(workdir, 'dir')
     with pytest.raises(IOError):
         a.extract_archive(d)
 def _extract_sources(self, archive, dir_name):
     archive = Archive(archive)
     archive.extract_archive(dir_name)