def list_ramdisks(): deviceramdiskdir = os.path.join(OS.ramdiskdir, config.get_device()) ramdisks = [] for root, dirs, files in os.walk(deviceramdiskdir): relative_path = os.path.relpath(root, OS.ramdiskdir) for f in files: if suffix.search(f): ramdisks.append(os.path.join(relative_path, f)) return ramdisks
def setdefaultvalues(self): # Auto patch by default self.rbautopatch.setChecked(True) self.patchtypetoggled() # Don't remove device checks self.cbdevicecheck.setChecked(False) # Boot image exists self.cbhasbootimg.setChecked(True) self.hasbootimagetoggled() # No loki self.cbloki.setChecked(False) # No patched init self.cbpatchedinit.setChecked(False) self.patchedinittoggled() # 'boot.img' self.lebootimg.setText("boot.img") self.enablebootimgcombobox(True) if not self.addonce: self.addonce = True self.presets = fileinfo.get_infos(config.get_device()) self.cmbpreset.addItem("Custom") for i in self.presets: self.cmbpreset.addItem(i[0][:-3]) for i in fileinfo.get_inits(): self.cmbinitfile.addItem(i) for i in ramdisk.list_ramdisks(): self.cmbramdisk.addItem(i[:-4]) self.autopatchers = autopatcher.get_auto_patchers() for i in self.autopatchers: self.cmbautopatchsel.addItem(i.name)
def selectfile(self): if not self.automode: supported = [ "Zip files and boot images (*.zip *.img *.lok)", "Zip files (*.zip)", "Boot images (*.img)", "Loki boot images (*.lok)", ] self.filename = QtWidgets.QFileDialog.getOpenFileName(self, filter=";;".join(supported))[0] if not self.filename: return self.hidewidgets() file_info = fileinfo.FileInfo() file_info.set_filename(self.filename) file_info.set_device(config.get_device()) if self.automode and not file_info.is_filetype_supported(): ext = os.path.splitext(self.filename)[1] msgbox.setText("The '%s' file extension is not supported." % ext) msgbox.setIcon(QtWidgets.QMessageBox.Warning) msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok) msgbox.exec() self.close() return if not file_info.find_and_merge_patchinfo(): msgbox = UnsupportedFileDialog(self, file_info=file_info) ret = msgbox.exec() if ret == QtWidgets.QDialog.Accepted: self.startpatching(file_info) else: self.showwidgets() else: self.startpatching(file_info)
else: filename = i # List ramdisks if that was the action if action == 'list': for i in ramdisk.list_ramdisks(): print(i) sys.exit(1) if not filename: print("No file specified") sys.exit(1) file_info = fileinfo.FileInfo() file_info.set_filename(filename) file_info.set_device(config.get_device()) if not file_info.is_filetype_supported(): print('Unsupported file type') sys.exit(1) supported = file_info.find_and_merge_patchinfo() if not supported: print("File not supported! Will attempt auto-patching ...") print("") if askramdisk or not file_info: try: ramdisks, choice = common.ask_ramdisk() except Exception as e:
partition_config = None for i in partition_configs: if i.id == config_name: partition_config = i if not partition_config: ui.info("Multiboot config %s does not exist!" % config_name) exit.exit(1) if not os.path.exists(filename): ui.info("%s does not exist!" % filename) exit.exit(1) filename = os.path.abspath(filename) filetype = detect_file_type(filename) file_info = fileinfo.get_info(filename, config.get_device()) if file_info and \ (('all' not in file_info.configs and partition_config not in file_info.configs) or '!' + partition_config.id in file_info.configs): file_info = None ui.info("The %s partition configuration is not supported for this file" % partition_config.id) loki_msg = ("The boot image was unloki'd in order to be patched. " "*** Remember to flash loki-doki " "if you have a locked bootloader ***") if filetype == "UNKNOWN": ui.failed("Unsupported file")