示例#1
0
文件: main.py 项目: dibowei/tools
    def onClick(self, event):
        if event.widget == self.__bootImgSelect:
            filename = tkFileDialog.askopenfilename(
                initialdir=os.path.expanduser("~"))
            if len(filename) > 0:
                self.__bootImgText.set(filename)

        elif event.widget == self.__bootDirSelect:
            directory = tkFileDialog.askdirectory(
                initialdir=os.path.expanduser("~"))
            if len(directory) > 0:
                self.__bootDirText.set(directory)

        elif event.widget == self.__unpackBtn:
            bootfile = self.__bootImgText.get()
            output = self.__bootDirText.get()

            if len(bootfile) > 0:
                Bootimg(bootfile).unpack(output)
                result = "Unpack " + bootfile + " --> " + output
                self.__resultText.set(result)

        elif event.widget == self.__packBtn:
            bootfile = self.__bootDirText.get()
            output = self.__bootImgText.get()

            if len(bootfile) > 0:
                Bootimg(bootfile).pack(output)
                result = "Pack " + bootfile + " --> " + output
                self.__resultText.set(result)
示例#2
0
    def unpack(self):
        if self.mUnpackDir is None:
            self.mUnpackDir = tempfile.mkdtemp()

            try:
                Bootimg(self.mImg).unpack(self.mUnpackDir)
            except:
                self.mStatus = imagetype.STAT_WRONG_IMG

        return self.mUnpackDir
示例#3
0
def assertTypeEquals(bootfile, bootType):

    # Unpack
    Bootimg(bootfile).unpack("OUT/")

    # Load type
    fileHandle = open("OUT/type.config", "r")

    # Assert
    assert bootType == fileHandle.read()

    # Clear
    fileHandle.close()
    shutil.rmtree("OUT/")
示例#4
0
文件: test.py 项目: andykoa/tools
def assertTypeEquals(bootfile, type):

    # Unpack
    Bootimg(bootfile).unpack("OUT/")

    # Load type
    fileHandle = open("OUT/.bootimg_type_file", "r")

    # Assert
    assert pickle.load(fileHandle) == type

    # Clear
    fileHandle.close()
    shutil.rmtree("OUT/")
示例#5
0
def assetPackSucc(bootfile):
    Bootimg(bootfile).pack("out.img")

    assert os.path.exists("out.img")

    os.remove("out.img")
示例#6
0
__author__ = '[email protected] (duanqz)'

from internal import param
from internal.bootimg import Bootimg
import sys
import traceback

### Start
if __name__ == '__main__':
    args = param.ParseOptions(sys.argv[1:])
    argLen = len(args)
    if argLen <= 0:
        print "Usage: pack_bootimg.py BOOT_IMG_DIR [OUTPUT_IMG]"
        print "       - BOOT_IMG_DIR : the directory of boot image files."
        print "       - OUTPUT_IMG   : the output image after pack. If not present, out.img will be used"
        exit(1)
    elif argLen == 1:
        bootfile = args[0]
        output = "out.img"
    elif argLen >= 2:
        bootfile = args[0]
        output = args[1]

    try:
        Bootimg(bootfile).pack(output)
    except ValueError as ve:
        if param.OPTIONS.quiet is False:
            traceback.print_exc()
        # See help.xml ERR_PACK_BOOTIMG_FAILED
        sys.exit(154)