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.unpack(bootfile, 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.pack(bootfile, output) result = "Pack " + bootfile + " --> " + output self.__resultText.set(result)
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.unpack(bootfile, 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.pack(bootfile, output) result = "Pack " + bootfile + " --> " + output self.__resultText.set(result)
def unpack(self): if self.mUnpackDir is None: self.mUnpackDir = tempfile.mkdtemp() os.removedirs(self.mUnpackDir) try: bootimg.unpack(self.mImg, self.mUnpackDir) except: self.mStatus = imagetype.STAT_WRONG_IMG return self.mUnpackDir
def assert_type_equals(boot_img, boot_type): bootimg.unpack(boot_img, "OUT/") f = open("OUT/type.config", "r") f_boot_type = f.read() f.close() shutil.rmtree("OUT/") assert boot_type == f_boot_type
- OUTPUT_DIR : the output director after unpack. If not present, BOOT_IMG.img will be used """ __author__ = '*****@*****.**' from internal import bootimg import sys import traceback if __name__ == '__main__': argc = len(sys.argv) if argc <= 1: print __doc__ exit(1) if argc > 1: boot_img = sys.argv[1] output = boot_img + ".out" if argc > 2: output = sys.argv[2] try: bootimg.unpack(boot_img, output) except ValueError as ve: traceback.print_exc() # See help.xml ERR_UNPACK_BOOTIMG_FAILED sys.exit(153)
Usage: pack_bootimg.py BOOT_IMG [OUTPUT_DIR] - BOOT_IMG : the input boot image to be unpacked - OUTPUT_DIR : the output director after unpack. If not present, BOOT_IMG.img will be used """ __author__ = '*****@*****.**' from internal import bootimg import sys import traceback if __name__ == '__main__': argc = len(sys.argv) if argc <= 1: print __doc__ exit(1) if argc > 1: boot_img = sys.argv[1] output = boot_img + ".out" if argc > 2: output = sys.argv[2] try: bootimg.unpack(boot_img, output) except ValueError as ve: traceback.print_exc() # See help.xml ERR_UNPACK_BOOTIMG_FAILED sys.exit(153)