Beispiel #1
0
    def verify(self):
        """Returns true if the image is valid, false otherwise.

        >>> img.verify()
        True

        :returns: Whether or not the image file is valid.
        :rtype: boolean

        """
        if (self.type == "SOC_ELF" and not self.simg):
            try:
                file_process = subprocess.Popen(["file", self.filename],
                                                stdout=subprocess.PIPE)
                file_type = file_process.communicate()[0].split()[1]

                if (file_type != "ELF"):
                    return False
            except OSError:
                # "file" tool wasn't found, just continue without it
                # typically located: /usr/bin/file
                pass

        if (self.type in ["CDB", "BOOT_LOG"]):
            # Look for "CDBH"
            contents = open(self.filename).read()
            if (self.simg):
                contents = get_simg_contents(contents)
            if (contents[:4] != "CDBH"):
                return False
        return True
Beispiel #2
0
    def verify(self):
        """Returns true if the image is valid, false otherwise.

        >>> img.verify()
        True

        :returns: Whether or not the image file is valid.
        :rtype: boolean

        """
        if (self.type == "SOC_ELF" and not self.simg):
            try:
                file_process = subprocess.Popen(["file", self.filename],
                                                stdout=subprocess.PIPE)
                file_type = file_process.communicate()[0].split()[1]

                if (file_type != "ELF"):
                    return False
            except OSError:
                # "file" tool wasn't found, just continue without it
                # typically located: /usr/bin/file
                pass

        if (self.type in ["CDB", "BOOT_LOG"]):
            # Look for "CDBH"
            contents = open(self.filename).read()
            if (self.simg):
                contents = get_simg_contents(contents)
            if (contents[:4] != "CDBH"):
                return False
        return True
Beispiel #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]
Beispiel #4
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]