Ejemplo n.º 1
0
    def _import_sample(self, name, directory):
        sample_file = pjoin(Settings.SAMPLES_PATH,
                            self._args.sample + '.tar.gz')

        archive = Archive()
        archive.decompress(sample_file, self.directory, 'tarball', strip=1)
        return 0
Ejemplo n.º 2
0
    def _import_archive(self, filename, directory):
        if filename.startswith('http://') \
                or filename.startswith('https://') \
                or filename.startswith('ftp://'):
            download_file = self._download(filename)
            filename = download_file

        if filename is None:
            return -1

        try:
            archive = Archive()
            ftype = archive.file_type(filename)
            if ftype is None:
                error('Invalid archive format: ' + filename)
                return -1
            archive.decompress(filename, directory, ftype)
        finally:
            if download_file is not None:
                rmtree(pdirname(download_file))
        return 0