def __init__(self, data): if tarfile is None: raise PayloadError("unsupported payload type") super().__init__(data) self.archive = None self.image_file = None
def setup(self, storage): super().setup(storage) try: self.archive = tarfile.open(self.image_file) except (tarfile.ReadError, tarfile.CompressionError) as e: # maybe we only need to catch ReadError and CompressionError here log.error("opening tar archive %s: %s", self.image_file, e) raise PayloadError("invalid payload format")