Example #1
0
    def __init__(self,
                 filename,
                 image_type,
                 simg=None,
                 daddr=None,
                 skip_crc32=False,
                 version=None):
        """Default constructor for the Image class."""
        self.filename = filename
        self.type = image_type
        self.daddr = daddr
        self.skip_crc32 = skip_crc32
        self.version = version

        if (not os.path.exists(filename)):
            raise ValueError("File %s does not exist" % filename)

        if (simg == None):
            contents = open(filename).read()
            self.simg = has_simg(contents)
        else:
            self.simg = simg

        if (not self.verify()):
            raise InvalidImageError("%s is not a valid %s image" %
                                    (filename, image_type))
Example #2
0
    def __init__(self, contents=None):
        """Default constructor for the UbootEnv class."""
        self.variables = {}

        if (contents != None):
            if (has_simg(contents)):
                contents = get_simg_contents(contents)

            contents = contents.rstrip("%c%c" % (chr(0), chr(255)))[4:]
            lines = contents.split(chr(0))
            for line in lines:
                part = line.partition("=")
                self.variables[part[0]] = part[2]
Example #3
0
    def __init__(self, contents=None):
        """Default constructor for the UbootEnv class."""
        self.variables = {}

        if (contents != None):
            if (has_simg(contents)):
                contents = get_simg_contents(contents)

            contents = contents.rstrip("%c%c" % (chr(0), chr(255)))[4:]
            lines = contents.split(chr(0))
            for line in lines:
                part = line.partition("=")
                self.variables[part[0]] = part[2]
Example #4
0
    def __init__(self, filename, image_type, simg=None, daddr=None,
                  skip_crc32=False, version=None):
        """Default constructor for the Image class."""
        self.filename = filename
        self.type = image_type
        self.daddr = daddr
        self.skip_crc32 = skip_crc32
        self.version = version

        if (not os.path.exists(filename)):
            raise ValueError("File %s does not exist" % filename)

        if (simg == None):
            contents = open(filename).read()
            self.simg = has_simg(contents)
        else:
            self.simg = simg

        if (not self.verify()):
            raise InvalidImageError("%s is not a valid %s image" %
                                    (filename, image_type))