Пример #1
0
def axml2txt(f):
    ret = 0
    msg = None
    ext = os.path.splitext(f)[1].lower()
    txtFile = None
    if ext == '.apk':
        print('axml2txt .apk')
        zfile = zipfile.ZipFile(f, 'r', compression=zipfile.ZIP_DEFLATED)
        for p in zfile.namelist():
            if p == "AndroidManifest.xml":
                axmlFile = os.path.join(Utils.getparent(f),
                                        'AndroidManifest.xml')
                file(axmlFile, 'wb').write(zfile.read(p))
                txtFile = axmlFile + '.txt'
                star.runcmd2([
                    PathManager.get_axmlprinter_path(), axmlFile, '>', txtFile
                ])
                break
        os.remove(axmlFile)
    else:
        txtFile = f + '.txt'
        ret, msg = star.runcmd2(
            [PathManager.get_axmlprinter_path(), f, '>', txtFile])
        print('axml2txt .xml')
    if os.path.exists(txtFile):
        star.run_cmd_asyn(['notepad', txtFile])

    print('axml2txt ok')
    return ret, msg