Commit f88c786c authored by Seblu's avatar Seblu
Browse files

better error message when image file is invalid

$ is del description
Error: not a gzip file

$ is del description
Error: Unable to open image description: not a gzip file
parent b1c537bf
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -356,9 +356,12 @@ class PackageImage(Image):
        self.base_path = os.path.dirname(self.path)
        # tarball are named by md5 and not by real name
        self.md5name = md5name
        try:
            if fileobj is None:
                fileobj = istools.uopen(self.path)
                self._tarball = Tarball.open(fileobj=fileobj, mode='r:gz')
        except Exception as e:
            raise Exception("Unable to open image %s: %s" % (path, e))
        self._metadata = self.read_metadata()
        # print info
        arrow("Image %s v%s loaded" % (self.name, self.version))