Esempio n. 1
0
def check_retropie_menu():
    oTree = ET.parse(ES_SYSTEMS_PRI_FILE)
    oRoot = oTree.getroot()
    try:
        for sys in oRoot.iter('system'):
            if sys.find('name').text == "retropie":
                if sys.find('path').text == RETROPIE_MENU:
                    return True
                break
        return False
    except:
        return False
Esempio n. 2
0
def decompile(apkname):
    apk = apkname + '.apk'
    eachappPath = os.path.join(sourceApkPath, apk)
    deCompileCompletehPath = os.path.join(apkPath, apkname)
    sys = platform.system()
    print('开始反编译')
    if sys.find('Windows') > -1:
        cmd = "apktool d -f -s -o {0} {1} <nul".format(deCompileCompletehPath,
                                                       eachappPath)
    else:
        cmd = "apktool d -f -s -o {0} {1}".format(deCompileCompletehPath,
                                                  eachappPath)
    try:
        os.system(cmd)
        # 检查反编译文件是否存在标识反编译是否真正完成,避免未进入except的反编译失败场景
        if os.path.exists(deCompileCompletehPath):
            set_current_package(apkname)
            sourcecache.backup(apkname)
            print('完成反编译')
            return True
        else:
            cmd = "echo {0}>>{1}".format(eachappPath, "反编译失败")
            os.system(cmd)
            return False

    except Exception as e:
        cmd = "echo {0}>>{1}".format(eachappPath, "反编译失败")
        os.system(cmd)
        return False

    pass
Esempio n. 3
0
def decompile(apk):
    apkname = obtain_apk_name(apk)
    if not apkname:
        print('读取apks文件夹下apk文件出错')
        return False
    eachappPath = os.path.join(sourceApkPath, apk)
    deCompileCompletehPath = os.path.join(apkPath, apkname)
    sys = platform.system()
    print('开始反编译')
    if sys.find('Windows') > -1:
        cmd = "apktool d {0} -f -o {1} <nul".format(eachappPath, deCompileCompletehPath)
    else:
        cmd = "apktool d {0} -f -o {1}".format(eachappPath, deCompileCompletehPath)
    try:
        os.system(cmd)
        # 检查反编译文件是否存在标识反编译是否真正完成,避免未进入except的反编译失败场景
        if os.path.exists(deCompileCompletehPath):
            print('完成反编译')
            return True
        else:
            deCompileExceptionHandle(apk)
            return False

            # data_file = '//var/folders/c6/9591_tjd321fgx_4hs6hqmxm0000gn/T/1.apk'
    # # 如果类型是文件则进行删除
    # if os.path.is_file(data_file):
    #     os.remove(data_file)
    #     print('删除1.apk成功')
    # else:
    #     print(f'Error: {data_file} not a valid filename')

    except:
        deCompileExceptionHandle(apk)
        return False
Esempio n. 4
0
def recompile(appname, appicon, apkname, splash_pic_name):
    apkList = os.listdir(apkPath)
    print('开始重新编译回包')
    for apk in apkList:
        if apk.find('.DS_Store') > -1:
            continue
        if not apkname == apk:
            continue
        eachapkPath = os.path.join(apkPath, apk)
        output_apk_name = create_output_apk_name(
            wrapper.Name_family.Builder().appname(appname).splash_picname(splash_pic_name).app_icon(appicon).build())
        # apkOutPath = recompileApkPath + apkname + os.sep + appname + '-' + splash_pic_name + '-' + appicon + '.apk'
        apkOutPath = recompileApkPath + apkname + os.sep + output_apk_name + '.apk'
        sys = platform.system()
        if sys.find('Windows') > -1:
            cmd = "apktool b {0} -f -o {1} <nul".format(eachapkPath, apkOutPath)
        else:
            cmd = "apktool b {0} -f -o {1}".format(eachapkPath, apkOutPath)
        try:
            os.system(cmd)
            print('完成重新编译回包')
        except:
            print('重新编译回包异常')
            cmd = "echo {0}>>{1}".format(apkOutPath, "重新编译回包异常")
            os.system(cmd)
            continue
    pass
Esempio n. 5
0
def decompile(apk, apkname):
    # TODO applicaiton_id 可为空处理
    # todo 为空标识apks下的apk不需要更改包名,
    # todo 但回编译的apk是放在以application_id命名的文件夹下,处理多个boss不设置application_id文件夹覆盖问题

    eachappPath = os.path.join(sourceApkPath, apk)
    deCompileCompletehPath = os.path.join(apkPath, apkname)
    sys = platform.system()
    print('开始反编译')
    if sys.find('Windows') > -1:
        cmd = "apktool d {0} -f -o {1} <nul".format(eachappPath,
                                                    deCompileCompletehPath)
    else:
        cmd = "apktool d {0} -f -s -o {1}".format(eachappPath,
                                                  deCompileCompletehPath)
    try:
        os.system(cmd)
        # 检查反编译文件是否存在标识反编译是否真正完成,避免未进入except的反编译失败场景
        if os.path.exists(deCompileCompletehPath):
            set_current_package(apkname)
            sourcecache.backup(apkname)
            print('完成反编译')
            return True
        else:
            deCompileExceptionHandle(apk)
            return False

    except:
        deCompileExceptionHandle(apk)
        return False

    pass
Esempio n. 6
0
def hide_retropie_menu(p_bEnable=True):
    p_bCheck = False
    TMP = os.path.join(TMP_LAUNCHER_PATH, "myfile.cfg")
    os.system('cp %s %s > /dev/null 2>&1' % (ES_SYSTEMS_PRI_FILE, TMP))
    if p_bEnable:
        p_sPath = os.path.join(RETROPIE_HOME_PATH, "disabled.retropiemenu")
    else:
        p_sPath = RETROPIE_MENU
    oTree = ET.parse(TMP)
    oRoot = oTree.getroot()
    try:
        for sys in oRoot.iter('system'):
            if sys.find('name').text == "retropie":
                sys.find('path').text = p_sPath
                p_bCheck = True
                break
        if p_bCheck: oTree.write(TMP)
        os.system('sudo cp %s %s > /dev/null 2>&1' %
                  (TMP, ES_SYSTEMS_PRI_FILE))
        os.system("sudo rm %s > /dev/null 2>&1" % TMP)
    except:
        return False
    return p_bCheck
def check_xml_file(p_sFile):
    """
    Analize es_systems.cfg a check if execution string is correct in
    order to have CRT Edition integration. Also checks if any special 
    system is missing (non default system on retropie).
    sCore will be empty if the system don't require any change in 
    execution string. By default sCore will be the system but special
    systems like retropie o CRT menu has a different format of
    launching.
    """
    global oTree
    global oRoot
    global bReboot
    global lSysInfo
    bCheck = False
    oTree = ET.parse(p_sFile)
    oRoot = oTree.getroot()
    for sys in oRoot.iter('system'):
        sSystem = sys.find('name').text
        sCore = sSystem
        sFullName = sys.find('fullname').text
        sCommand = sys.find('command').text
        sTheme = sys.find('theme').text
        for item in SYSTEMS:
            if sSystem == item:
                # set checked
                SYSTEMS[sSystem]["check"] = True
                # set core name, empty if is 1CRT or Retropie
                sCore = SYSTEMS[sSystem]["core"]
                if sTheme != SYSTEMS[sSystem]["theme"]:
                    sys.find('theme').text = SYSTEMS[sSystem]["theme"]
                    lSysInfo.append(("-- CHANGED theme for %s" % \
                             sSystem, "OK"))
                    bCheck = True
        if sCore:
            sExecLine = "python %s " % CRT_LAUNCHER_FILE
            sExecLine += "%%ROM%% %s " % sCore
            sExecLine += "dummy"
            if sExecLine != sCommand and not "force" in sCommand:
                lSysInfo.append(("-- CHANGED exec line for %s" % \
                                 sSystem, "OK"))
                sys.find('command').text = sExecLine
                bCheck = True
    if bCheck:
        oTree.write(p_sFile)
        bReboot = True
Esempio n. 8
0
def recompile2(is_recovery: bool, appname, appicon, apkname, splash_pic_name,
               umeng_channel):
    try:
        apkList = os.listdir(apkPath)
        print('开始重新编译回包')
        for apk in apkList:
            if apk.find('.DS_Store') > -1:
                continue
            if not apkname == apk:
                continue
            eachapkPath = os.path.join(apkPath, apk)
            output_apk_name = wrapper.Name_family.Builder().appname(
                appname).splash_picname(splash_pic_name).app_icon(
                    appicon).umeng_channel(umeng_channel).build().append()
            apkOutPath = recompileApkPath + apkname + os.sep + boss2[
                ELEMENT_TAG_APPLICATION_ID] + os.sep + output_apk_name + '.apk'
            sys = platform.system()
            if sys.find('Windows') > -1:
                cmd = "apktool b -f -o {0} {1} <nul".format(
                    apkOutPath, eachapkPath)
            else:
                cmd = "apktool b -f -o {0} {1}".format(apkOutPath, eachapkPath)

            os.system(cmd)
            if is_recovery:
                set_current_package(apkname)
                sourcecache.recovery(apkname)
            print('完成重新编译回包')
    except Exception as e:
        LogUtil.error('重新编译回包失败')
        logging.exception(e)
        cmd = "echo {0}>>{1}".format(apkOutPath, "重新编译回包失败")
        os.system(cmd)
        raise

    pass
    #for ibin in range(1,default.GetNbinsX()+1):
    #        print default.GetXaxis().GetBinLabel(ibin),default.GetBinContent(ibin)


    colors=[kBlue-9,kBlue,kBlue+2,
            15,12,1,
            2,3,6,7,50,40,30,20,1]

    allHist.append(default)

    counter=0
    for mysys in allSys:
        print "===>", sys
        sys=mysys+"High"
        sys2=sys
        if sys.find("photon")>=0 or  sys.find("GeneratorZ")>=0 or  sys.find("Kappa")>=0 or sys.find("QCD")>=0 or sys.find("TopTuneA14")>=0 or sys.find("TopRadiation")>=0:
            sys2="Nom"

        if sys.find("QCD")>=0:
            sys2="Nom"

        
        histHigh=createGraph(bkg,sys,region,bkg2,sys2,region2)
        histLow=createGraph(bkg,sys.replace("High","Low"),region,bkg2,sys2.replace("High","Low"),region2)
        
        if doSym:
            newHists=Symmetrize(default,histLow,histHigh)
            histLow=newHists[0]
            histHigh=newHists[1]

Esempio n. 10
0
    #for ibin in range(1,default.GetNbinsX()+1):
    #        print default.GetXaxis().GetBinLabel(ibin),default.GetBinContent(ibin)

    colors = [
        kBlue - 9, kBlue, kBlue + 2, 15, 12, 1, 2, 3, 6, 7, 50, 40, 30, 20, 1
    ]

    allHist.append(default)

    counter = 0
    for mysys in allSys:
        print "===>", sys
        sys = mysys + "High"
        sys2 = sys
        if sys.find("photon") >= 0 or sys.find("GeneratorZ") >= 0 or sys.find(
                "Kappa") >= 0 or sys.find("QCD") >= 0 or sys.find(
                    "TopTuneA14") >= 0 or sys.find("TopRadiation") >= 0:
            sys2 = "Nom"

        if sys.find("QCD") >= 0:
            sys2 = "Nom"

        histHigh = createGraph(bkg, sys, region, bkg2, sys2, region2)
        histLow = createGraph(bkg, sys.replace("High", "Low"), region, bkg2,
                              sys2.replace("High", "Low"), region2)

        if doSym:
            newHists = Symmetrize(default, histLow, histHigh)
            histLow = newHists[0]
            histHigh = newHists[1]