def setEditByApkPath(self, filePath): if not filePath: return filePath = QtCore.QDir.toNativeSeparators(filePath) self.srcApkEdit.setText(filePath) destPath = FileUtil.getFilePathWithName(filePath) self.destApkEdit.setText(destPath)
def getApkApplicationIconPath(self, apkPath, apkInfo=None): apkPath = unicode(apkPath) applicationIconStr = self.getApkApplicationIconPathInApk( apkPath, apkInfo) if not applicationIconStr: return u'未获取到应用图标' apkZip = zipfile.ZipFile(apkPath) iconData = apkZip.read(applicationIconStr) iconDestPath = FileUtil.getFilePathWithName(apkPath) FileUtil.mkdirNotExist(iconDestPath) saveIconPath = os.path.join(iconDestPath, 'icon_launcher.png') if FileUtil.isFileOrDirExist(saveIconPath): return saveIconPath with open(saveIconPath, 'w+b') as saveIcon: saveIcon.write(iconData) return saveIconPath