def startTask(self, platform):
        packageLs = ConfigParse.shareInstance().getPackageLs()
        # print '<---TASK INFO--->%s' %(packageLs)
        for package in packageLs:
            idChannel = package['idChannel']
            if idChannel in self.__finishChannel:
                #print '<---...CONTINUE WORKING...--->'
                continue
            pkThread = self.getIdleThread()
            if pkThread is None:
                return
            pkThread.setPlatform(platform)
            channel = ConfigParse.shareInstance().findChannel(idChannel)
            if channel is None:
                continue
            pkThread.assignPackTask(channel)
            print '<---packThreadStart--->'
            if not pkThread.isAlive():
                pkThread.start()
            self.__finishChannel.append(idChannel)

        bOver = True
        for thread in self.__taskThreads:
            if thread.getStatus() != 0:
                bOver = False
                break

        if bOver == True:
            for thread in self.__taskThreads:
                thread.stop()
                self.__taskThreads.remove(thread)
예제 #2
0
    def iterFileMapAndCopyFile(self):
        cfgResRootDir = self.sdksRootDir
        luaversion = ConfigParse.shareInstance().getLuaVersion()
        fileMap = ConfigParse.shareInstance().getFileMap()

        rules = fileMap.get(luaversion, None)
        if not rules:
            print("no coresponding luaversion")
            exit(1)

        for k, v in rules.items():
            source = os.path.join(cfgResRootDir, luaversion, k)
            target = os.path.join(self.decompileDir, v['targetDir'])
            # 如果source是文件
            if os.path.isfile(source):
                # 直接复制到目标文件夹, 忽略模式
                target = os.path.join(target, k)
                file_utils.copyFiles(source, target)
            # 是文件夹
            else:
                mode = v['copyMode']
                if mode == '*':
                    file_utils.copyFiles(source, target)
                elif mode == '-':
                    sourceDirFiles = os.listdir(source)
                    targetDirFiles = os.listdir(target)
                    for f in [
                            s for s in sourceDirFiles if s in targetDirFiles
                    ]:
                        source = os.path.join(source, f)
                        target = os.path.join(target, f)
                        file_utils.copyFiles(source, target)
예제 #3
0
 def test_write_test(self):
     a = ConfigParse()
     try:
         a.config_write("127.0.0.1")
     except:
         self.fail("Could not write Config")
     self.assertNotEquals(a.uname, "")
     self.assertNotEquals(a.mac, "")
예제 #4
0
    def test_readconfig(self):
        a = ConfigParse()
        try:
            x, b, c = a.config_read()
        except:
            self.fail("Could not find file or missing head")

        self.assertNotEquals(x, "")
        self.assertNotEquals(b, "")
        self.assertNotEquals(c, "")
예제 #5
0
def startIos():
    reload(sys)
    sys.setdefaultencoding('utf8')
    ConfigParse.shareInstance().readUserConfig(1)
    taskManager.shareInstance().clearRecord()
    packThreadManager.shareInstance().clearRecord()
    packThreadManager.shareInstance().setCurWorkDir(os.getcwd())
    source = ConfigParse.shareInstance().getSource()
    game = ConfigParse.shareInstance().getCurrentGame()
    versionName = ConfigParse.shareInstance().getVersionName()
    packThreadManager.shareInstance().startTask(1)
    thread.start_new_thread(checkTaskThreadForIos, ())
예제 #6
0
def reportCmdError(cmd, stdoutput, erroutput):
    """
    """
    errorLog = stdoutput + '\r\n' + erroutput
    if ConfigParse.shareInstance().get_log_dir() is None:
        reportError(errorLog, int(threading.currentThread().getName()))
    else:
        error = '==================>>>> ERROR <<<<==================\r\n'
        error += '[Time]: ' + time.strftime(
            '%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '\r\n'
        error += '[Error]:\r\n'
        error += errorLog + '\r\n'
        error += '==================================================\r\n'
        log(error, ConfigParse.shareInstance().get_log_dir())
예제 #7
0
def start():
    reload(sys)
    sys.setdefaultencoding('utf8')
    ConfigParse.shareInstance().readUserConfig(0)
    taskManager.shareInstance().clearRecord()
    packThreadManager.shareInstance().clearRecord()
    packThreadManager.shareInstance().setCurWorkDir(os.getcwd())
    # source = ConfigParse.shareInstance().getSource()
    #print '<---source-->'+source
    # game = ConfigParse.shareInstance().getCurrentGame()
    # if os.path.isfile(source):
    # versionName = ConfigParse.shareInstance().getVersionName()
    # print '<---Config VersionName-->'+versionName
    # file_operate.backupApk(source, game, versionName)
    packThreadManager.shareInstance().startTask(0)
    thread.start_new_thread(checkTaskThread, ())
예제 #8
0
def modify_file(workDir, strForReplace, funName):
    #AppController.mm的路径(appctrl_path帝国争霸,超级舰队的。appctrl_path2是战舰传奇的)
    appctrlPath = workDir + '/AppController.mm'
    appctrlPath2 = workDir + '/ios/AppController.mm'

    #如果没有AppController.mm就去找AppDelegate.m的路径
    xcodeProjPath = workDir + '/' + ConfigParse.shareInstance().getProjXcode()
    AppDelegatePath = xcodeProjPath[:-10] + '/AppDelegate.m'

    replaceFlag = '#pragma mark rsdk_' + funName + '_end'  #根据传入的funName拼接 代码标记
    replaceStr = strForReplace + '\n' + replaceFlag  #要添加的代码 + 代码标记
    print 'replaceStr===>' + replaceStr

    #判断AppController.mm或者AppDelegate.m文件路径
    if os.path.exists(appctrlPath):
        content = replace_file(appctrlPath, replaceFlag, replaceStr)
        write_str_to_file(appctrlPath, content)
    elif os.path.exists(appctrlPath2):
        content = replace_file(appctrlPath2, replaceFlag, replaceStr)
        write_str_to_file(appctrlPath2, content)
    elif os.path.exists(AppDelegatePath):
        content = replace_file(AppDelegatePath, replaceFlag, replaceStr)
        write_str_to_file(AppDelegatePath, content)
    else:
        print 'not exist appcontroller.mm or appdelegate.m'
    return
예제 #9
0
    def doPackWithOneChannelSymbol(self, channelId, tempRecompileApk,
                                   tempSignedApkName, outputDir, outputName,
                                   symbol, taskWorkDir):
        '''
        @param channelId 渠道id,用于获取keystore
        @param tempRecompileApk 重打包后的未签名apk path
        @param tempSignedApkName  签名对齐后的包名称
        @param outputDir  输出路径(非完整path)
        @param outputName  输出名称(非完整path)
        @param symbol  自定义渠道标记
        @param taskWorkDir  工作目录
        '''
        log_utils.getLogger().info('doPackWithOneChannelSymbol ... ')
        #添加渠道标识
        log_utils.getLogger().info('adding channel symbol to /assets/ ... ')
        channelSymbolFileName = ConfigParse.shareInstance(
        ).getChannelSymbolFileName()
        zip_utils.addChannelSymbolFile(tempRecompileApk, symbol,
                                       channelSymbolFileName, taskWorkDir)

        #apk签名
        log_utils.getLogger().info('signing apk')
        keystoreInfo = ConfigParse.shareInstance().getKeystoreInfoByChannelId(
            channelId)
        ret = cmd_tools.signApk(tempRecompileApk, keystoreInfo['file'],
                                keystoreInfo['storePassword'],
                                keystoreInfo['keyAlias'],
                                keystoreInfo['aliasPassword'])
        if ret:
            raise PackException(pack_exception.SIGN_APK_FAILED,
                                'sign apk failed')

        #apk优化
        apkName = '%s/%s' % (outputDir, outputName)
        outputDir = os.path.dirname(apkName)

        if not os.path.exists(outputDir):
            os.makedirs(outputDir)

        log_utils.getLogger().debug(outputDir)
        log_utils.getLogger().info('zipaligning and renaming apk apkName == ' +
                                   apkName)
        ret = cmd_tools.alignAPK(tempRecompileApk, tempSignedApkName)
        if ret:
            raise PackException(pack_exception.ALIGN_APK_FAILED,
                                'align apk failed')
        os.rename(tempSignedApkName, apkName)
예제 #10
0
def log(str):
    outputDir = ConfigParse.shareInstance().getOutputDir()
    logDir = outputDir + 'Log/'
    if not os.path.exists(logDir):
        os.makedirs(logDir)
    logFile = codecs.open(logDir + 'error.log', 'a+', 'utf-8')
    content = str + '\r\n'
    logFile.write(unicode(content, 'gbk'))
    logFile.close()
예제 #11
0
def execFormatCmd(cmd):
    cmd = cmd.replace('\\', '/')
    cmd = re.sub('/+', '/', cmd)
    if platform.system() == 'Windows':
        st = subprocess.STARTUPINFO
        st.dwFlags = subprocess.STARTF_USESHOWWINDOW
        st.wShowWindow = subprocess.SW_HIDE
    else:
        cmd = cmd.encode('utf-8').decode('iso-8859-1')

    # findret = cmd.find('jarsigner')
    # if findret > -1:
    #     import shlex
    #     cmds = shlex.split(cmd)
    #     log_utils.getLogger().debug('the execformatCmd cmds:'+str(cmds))
    #     s = subprocess.Popen(cmds)
    # else:
    #     s = subprocess.Popen(cmd, shell=True)

    #===========================================================================
    # import shlex
    # cmds = shlex.split(cmd)
    # #log_utils.getLogger().debug("eeeeeeeeeeeeeeeeeee" + cmd)
    # s = subprocess.Popen(cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    #===========================================================================

    import locale
    cmd = cmd.encode(locale.getdefaultlocale()[1])
    p = subprocess.Popen(cmd,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE,
                         shell=True)

    ConfigParse.shareInstance().setCurrentSubProcess(p)

    while p.poll() == None:
        line = p.stdout.readline()
        if not line:
            break
        # print line
        log_utils.getLogger().info(line)
    p.wait()
    return p.returncode
예제 #12
0
 def kill_subprocess(self):
     p = ConfigParse.shareInstance().getCurrentSubProcess()
     #=======================================================================
     # process = psutil.Process(p.pid)
     # for proc in process.get_children(recursive=True):
     #     proc.kill()
     # process.kill()
     #=======================================================================
     #os.system("taskkill /PID %s /F" % p.pid)
     os.kill(p.pid, signal.CTRL_C_EVENT)
예제 #13
0
def backup_apk(source, game, versionName):
    gameName = game['gameName']
    outputDir = ConfigParse.share_instance().get_output_dir()
    if outputDir == '':
        outputDir = '../output/'
    outputDir += '/' + game['gameName'] + '/' + versionName + '/common'
    outputDir = get_full_path(outputDir)
    backupName = '%s/common.apk' % outputDir
    if os.path.exists(backupName):
        os.remove(backupName)
    copy_file(source, backupName)
예제 #14
0
    def __init__(self):
        self.sdksRootDir = os.path.join(env.SUPPORT_DIR, self._projectShorName)

        self.outputDir = ConfigParse.shareInstance().getOutputDir()
        if self.outputDir is None:
            raise PackException(pack_exception.PHP_PARAMS_ERROR,
                                'outputDir is None')
        self.outputName = ConfigParse.shareInstance().getOutputName()
        self.apkFile = ConfigParse.shareInstance().getApkPath()

        timestamp_str = str(time.time())
        self.taskWorkDir = os.path.join(my_utils.getWorkDir(),
                                        self._projectShorName, timestamp_str,
                                        "temp")

        if not os.path.exists(self.taskWorkDir):
            os.makedirs(self.taskWorkDir)
        log_utils.getLogger().info('taskWorkDir == ' + self.taskWorkDir)
        self.decompileDir = self.taskWorkDir + '/decompile'
        self.tmpApkToolPath = os.path.join(self.taskWorkDir, 'apktooltmp')
예제 #15
0
def doSpecialOperate(channel, decompileDir, packageName, SDKWorkDir):
    """There are special operate in some SDK"""
    for Channel_SDK in channel['sdkLs']:
        idSDK = Channel_SDK['idSDK']
        SDK = ConfigParse.shareInstance().findSDK(idSDK)
        if SDK is None:
            continue
        usrSDKConfig = ConfigParse.shareInstance().findUserSDKConfigBySDK(
            idSDK, channel['idChannel'])
        SDKDir = SDKWorkDir + SDK['SDKName']
        scriptPath = SDKDir + '/' + 'script.pyc'
        if os.path.exists(scriptPath):
            sys.path.append(SDKDir)
            import script
            ret = script.script(SDK, decompileDir, packageName, usrSDKConfig)
            del sys.modules['script']
            sys.path.remove(SDKDir)
            if ret != None and ret == 1:
                return 1

    return 0
예제 #16
0
def log(str):
    outputDir = ConfigParse.shareInstance().getOutputDir()
    logDir = outputDir + '/log/'
    if not os.path.exists(logDir):
        os.makedirs(logDir)
    logFile = codecs.open(logDir + 'error.txt', 'a+', 'utf-8')
    content = str + '\r\n'
    if platform.system() == 'Windows':
        logFile.write(unicode(content, 'gbk'))
    else:
        logFile.write(unicode(content, 'gbk'))
    logFile.close()
예제 #17
0
def log(str, outputDir=None):
    if outputDir is None:
        outputDir = ConfigParse.shareInstance().getOutputLogDir()
    logDir = get_server_dir() + '/Log/' + outputDir + '/'
    print 'log_dir:' + logDir
    if not os.path.exists(logDir):
        os.makedirs(logDir)
    logFile = codecs.open(logDir + 'error.txt', 'a+', 'utf-8')
    print '<---logFile--->' + logDir + 'error.txt'
    content = str + '\r\n'
    if platform.system() == 'Windows':
        logFile.write(unicode(content, 'gbk'))
    else:
        logFile.write(unicode(content, 'gbk'))
    logFile.close()
예제 #18
0
    def doPackWithoutChannelSymbol(self, tempRecompileApk, tempSignedApkName,
                                   outputDir, outputName):
        '''
        @param channelId 渠道id,用于获取keystore
        @param tempRecompileApk 重打包后的未签名apk path
        @param tempSignedApkName  签名对齐后的包名称
        @param outputDir  输出路径(非完整path)
        @param outputName  输出名称(非完整path)
        '''
        log_utils.getLogger().info('doPackWithoutChannelSymbol ... ')
        #apk签名
        log_utils.getLogger().info('signing apk')
        keystoreInfo = ConfigParse.shareInstance().getKeystoreInfo()

        # 签名,没细看
        ret = cmd_tools.signApk(tempRecompileApk, keystoreInfo['file'],
                                keystoreInfo['storePassword'],
                                keystoreInfo['keyAlias'],
                                keystoreInfo['aliasPassword'])
        if ret:
            raise PackException(pack_exception.SIGN_APK_FAILED,
                                'sign apk failed')

        #apk优化
        apkName = '%s/%s' % (outputDir, outputName)
        outputDir = os.path.dirname(apkName)

        if not os.path.exists(outputDir):
            os.makedirs(outputDir)

        log_utils.getLogger().debug(outputDir)
        log_utils.getLogger().info('zipaligning and renaming apk apkName == ' +
                                   apkName)

        # 调用工具里的 zipalign.exe 对temRecompileApk 进行优化,生成tempSignedApkName
        ret = cmd_tools.alignAPK(tempRecompileApk, tempSignedApkName)

        if ret:
            raise PackException(pack_exception.ALIGN_APK_FAILED,
                                'align apk failed')
        import shutil
        shutil.move(tempSignedApkName, apkName)
예제 #19
0
def reportError(errorOuput, idChannel):
    """
    """
    packageName = ''
    channel = ConfigParse.shareInstance().findChannel(idChannel)
    if channel != None and channel.get('packNameSuffix') != None:
        packageName = str(channel['packNameSuffix'])
        channelName = str(channel['name'])
        if platform.system() == 'Windows':
            channelName = str(channel['name']).encode('gbk')
        else:
            channelName = channel['name'].decode('utf8').encode('gbk')
    error = '==================>>>> ERROR <<<<==================\r\n'
    error += '[rsdk_Channel]: ' + threading.currentThread().getName() + '\r\n'
    error += '[rsdk_ChannelName]: ' + channelName + '\r\n'
    error += '[rsdk_Package]: ' + packageName + '\r\n'
    error += '[rsdk_Time]: ' + time.strftime(
        '%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + '\r\n'
    error += '[rsdk_Error]:\r\n'
    error += errorOuput + '\r\n'
    error += '===================================================\r\n'
    log(error)
예제 #20
0
    def doBatchPackWithChannelSymols(self, channelId, unsignedApk,
                                     tempSignedApkName, outputDir, outputName,
                                     symbolList, taskWorkDir):
        '''
        @param channelId 渠道id,用于获取keystore
        @param unsignedApk 重打包后的未签名apk path
        @param tempSignedApkName  签名对齐后的包名称
        @param outputDir  输出路径(非完整path)
        @param outputName  输出名称(非完整path)
        @param symbolList  自定义渠道标记列表
        @param taskWorkDir  工作目录
        '''
        log_utils.getLogger().info('doBatchPackWithChannelSymols ... ')
        batchPackDir = os.path.join(taskWorkDir, 'batch')
        if not os.path.exists(batchPackDir):
            os.makedirs(batchPackDir)

        copiedUnsignedApk = os.path.join(os.path.dirname(unsignedApk),
                                         'batchTmpApk.apk')

        log_utils.getLogger().info('start batch packing ... ')
        for symbol in symbolList:
            if not file_utils.copyFile(unsignedApk, copiedUnsignedApk):
                raise PackException(
                    pack_exception.COPY_FILE_EXCEPTION,
                    'cannot copy apk during doBatchPackWithChannelSymols')

            #添加渠道标识
            log_utils.getLogger().info(
                'adding channel symbol to /assets/ ... ')
            channelSymbolFileName = ConfigParse.shareInstance(
            ).getChannelSymbolFileName()
            zip_utils.addChannelSymbolFile(copiedUnsignedApk, symbol,
                                           channelSymbolFileName, taskWorkDir)

            #apk签名
            log_utils.getLogger().info('signing apk')
            keystoreInfo = ConfigParse.shareInstance(
            ).getKeystoreInfoByChannelId(channelId)
            ret = cmd_tools.signApk(copiedUnsignedApk, keystoreInfo['file'],
                                    keystoreInfo['storePassword'],
                                    keystoreInfo['keyAlias'],
                                    keystoreInfo['aliasPassword'])
            if ret:
                raise PackException(pack_exception.SIGN_APK_FAILED,
                                    'sign apk failed')

            #apk优化
            apkName = '%s/%s' % (batchPackDir, outputName)
            basename = os.path.splitext(os.path.basename(apkName))[0]
            apkOutputDir = os.path.dirname(apkName)
            if not os.path.exists(apkOutputDir):
                os.makedirs(apkOutputDir)

            apkName = os.path.join(apkOutputDir,
                                   basename + '(' + symbol + ').apk')

            log_utils.getLogger().debug(apkOutputDir)
            log_utils.getLogger().info(
                'zipaligning and renaming apk apkName == ' + apkName)
            ret = cmd_tools.alignAPK(copiedUnsignedApk, tempSignedApkName)
            if ret:
                raise PackException(pack_exception.ALIGN_APK_FAILED,
                                    'align apk failed')
            os.rename(tempSignedApkName, apkName)

        log_utils.getLogger().info('batch packing success... ')
        log_utils.getLogger().info('zip apk files ... ')
        zip_utils.zipApks(batchPackDir, '%s/%s' % (outputDir, outputName))
예제 #21
0
def openfilefolder():
        QDesktopServices.openUrl(QUrl(file_operate.getFullPath(ConfigParse.shareInstance().getOutApkDir()), QUrl.TolerantMode))
예제 #22
0
파일: entry.py 프로젝트: YiFeng0755/Repack
def php_entry(arg):
    # 单例
    ConfigParse.shareInstance().initData(arg)

    from pack_managers.newengine_pack_manager import NewEnginePackManager
    NewEnginePackManager().run()
예제 #23
0
def getGameSdkScriptPath():
    return getFullPath(constant.sdkRelatePath +
                       ConfigParse.shareInstance().getChannelName() +
                       "/gameSdkScript")
예제 #24
0
 def test_config_read(self):
     try:
         a = ConfigParse()
     except:
         self.fail("Could not Create Object")
예제 #25
0
def split_apk(db_name, game_id, id_channel, parent_apk_path, sub_apk_path,
              sub_channel_id):
    reload(sys)
    sys.setdefaultencoding('utf8')
    log_dir = '%s/%s/%s' % (db_name, game_id, id_channel)
    ConfigParse.shareInstance().set_log_dir(log_dir)
    if not os.path.exists(parent_apk_path):
        logError('parent apk not exist', log_dir)
        print '{"ret":"fail","msg":"parent apk not exist"}'
        return
    middle_dir = '%s/%s' % (db_name, sub_channel_id)
    split_work_dir = file_operate.get_server_dir(
    ) + '/split_workspace/%s' % middle_dir
    print 'split_work_dir:' + split_work_dir
    if os.path.exists(split_work_dir):
        file_operate.delete_file_folder(split_work_dir)

    os.makedirs(split_work_dir)
    split_decompile_dir = split_work_dir + '/decompile'
    os.mkdir(split_decompile_dir)

    channel_temp_apk_dir = split_work_dir + '/temp'
    os.mkdir(channel_temp_apk_dir)

    channel_temp_apk = channel_temp_apk_dir + '/temp.apk'
    file_operate.copyFile(parent_apk_path, channel_temp_apk)

    ret = apk_operate.decompileApk(channel_temp_apk, split_decompile_dir, None)
    if ret:
        logError('decompileApk parent apk fail', log_dir)
        print '{"ret":"fail","msg":"decompileApk parent apk fail"}'
        return
    ConfigParse.shareInstance().readUserConfig(0)
    sub_channel_config = ConfigParse.shareInstance().get_sub_channel_config()

    sub_channel_icon_url = None
    display_name = None
    sub_app_id = ''
    sub_num = ''

    if len(sub_channel_config) > 0:
        for r in sub_channel_config:
            if int(id_channel) != int(r['p_channel_id']):
                logError('param channel id is not right', log_dir)
                print '{"ret":"fail","msg":"param channel id is not right"}'
                return

            if int(game_id) != int(r['game_id']):
                logError('param game id is not right', log_dir)
                print '{"ret":"fail","msg":"param game id is not right"}'
                return

            if r['r_channel_game_icon'] is None:
                sub_channel_icon_url = ''
            else:
                sub_channel_icon_url = r['r_channel_game_icon']

            if r['display_name'] is None:
                display_name = ''
            else:
                display_name = r['display_name'].encode('utf-8')

            sub_app_id = str(r['sub_app_id'])
            print 'sub_app_id: %s' % sub_app_id
            sub_num = str(r['sub_num'])

    else:
        logError('sub channel config is empty', log_dir)
        print '{"ret":"fail","msg":"sub channel config is empty"}'
        return

    if sub_app_id == 0 or sub_num == 0:
        log_info = 'ret:fail,msg:sub_app_id and sub_num == 0'
        logError(log_info, log_dir)
        return

    if display_name != '' and display_name is not None:
        apk_operate.doModifyAppName(split_decompile_dir, display_name)

    if sub_channel_icon_url != '' and sub_channel_icon_url is not None:
        channel_icon_dir = split_work_dir + '/icon/'
        os.mkdir(channel_icon_dir)
        urllib.urlretrieve(sub_channel_icon_url, channel_icon_dir + 'icon.png')
        ret = apk_operate.pushIconIntoApk(channel_icon_dir,
                                          split_decompile_dir)
        if ret:
            logError('pushIconIntoApk error', log_dir)
            return
    ret = encode_operate.decodeXmlFiles(split_decompile_dir)
    if ret:
        logError('decodeXmlFiles error', log_dir)
        return

    channel = ConfigParse.shareInstance().findChannel(int(id_channel))
    sdk_dir = split_work_dir + '/sdk/'
    for channel_sdk in channel['sdkLs']:
        id_sdk = channel_sdk['idSDK']
        SDK = ConfigParse.shareInstance().findSDK(id_sdk)
        if SDK is None:
            continue
        split_script_src_dir = file_operate.get_server_dir(
        ) + '/config/sdk/' + SDK['SDKName'] + '/specialsplit_script.pyc'
        split_script_src_dir = file_operate.getFullPath(split_script_src_dir)
        if not os.path.exists(split_script_src_dir):
            continue

        split_script_dest_dir = sdk_dir + SDK[
            'SDKName'] + '/specialsplit_script.pyc'

        file_operate.copyFiles(split_script_src_dir, split_script_dest_dir)
        SDKDir = sdk_dir + SDK['SDKName']
        sys.path.append(SDKDir)
        import specialsplit_script
        print 'sub_app_id:' + sub_app_id
        ret = specialsplit_script.script(split_decompile_dir, sub_app_id,
                                         sub_num)
        del sys.modules['specialsplit_script']
        sys.path.remove(SDKDir)
        if ret:
            logError("error do Special Operate", log_dir)
            print "error do Special Operate"
            return

    ret = change_develop_id(split_decompile_dir, sub_app_id, sub_num)
    print 'change_develop_id ret:%s' % ret
    if ret:
        logError('change develop id error', log_dir)
        return

    encode_operate.encodeXmlFiles(split_decompile_dir)

    channel_unsign_apk = channel_temp_apk_dir + '/channel_temp_apk.apk'
    ret = apk_operate.recompileApk(split_decompile_dir, channel_unsign_apk)
    if ret:
        logError("recompileApk fail", log_dir)
        print "recompileApk fail"
        return
    game = ConfigParse.shareInstance().getCurrentGame()
    if game is None:
        print 'game is none'
        logError('game is none', log_dir)
        return
    ret = apk_operate.signApkAuto(channel_unsign_apk, game, channel,
                                  middle_dir)

    if ret:
        print 'signApkAuto fail'
        logError('signApkAuto fail', log_dir)
        return

    out_put_dir = os.path.dirname(sub_apk_path)
    ret = apk_operate.alignAPK(channel_unsign_apk, sub_apk_path, out_put_dir)
    if ret:
        print 'alignAPK fail'
        logError('alignAPK fail', log_dir)
        return
    print '{"ret":"success","msg":"run pack success"}'
    file_operate.delete_file_folder(split_work_dir)
예제 #26
0
    def pack(self):
        try:
            log_utils.getLogger().info('generating new r file ... ')
            #重新生成R文件

            ret = cmd_tools.produceNewRFile(self._packageName,
                                            self.decompileDir)
            if ret:
                raise PackException(pack_exception.PRODUCE_NEW_R_FILE_FAILED,
                                    'produce new r file failed')

            #重新编译成apk
            tempRecompileApkDir = self.taskWorkDir + '/tempRecompileApk'
            tempRecompileApk = '%s/nosig.apk' % (tempRecompileApkDir)
            tempSignedApkName = '%s/_sig.apk' % (tempRecompileApkDir)

            log_utils.getLogger().info(
                'recompiling apk ... tempRecompileApk = ' + tempRecompileApk)
            ret = cmd_tools.recompileApk(self.decompileDir, tempRecompileApk,
                                         self.tmpApkToolPath)
            if ret:
                raise PackException(pack_exception.RECOMPILE_APK_FAILED,
                                    'recompile apk failed')

            # self.outputName是 autotest_xxx.apk
            self.doPackWithoutChannelSymbol(tempRecompileApk,
                                            tempSignedApkName, self.outputDir,
                                            self.outputName)

            #测试桩重打包
            import env
            testbundle_apkFile = os.path.join(
                env.SUPPORT_DIR, self._projectShorName,
                ConfigParse.shareInstance().getLuaVersion(), 'testbundle',
                'TestBundle.apk')
            #testbundle_apkFile = os.path.join(env.GOD_TOOL_DIR, 'TestBundle_base.apk')
            if not os.path.exists(testbundle_apkFile):
                raise PackException(
                    pack_exception.SOURCE_APK_NOT_EXIST,
                    'testbundle_base apk file %s does not exist' %
                    testbundle_apkFile)

            # 拷贝TestBundle.apk 到  工作目录下/testbundle_temp.apk
            tmpTestBundleApk = self.taskWorkDir + '/testbundle_temp.apk'
            my_utils.copyFile(testbundle_apkFile, tmpTestBundleApk)

            testbundle_decompileDir = self.taskWorkDir + '/testbundle_decompile'
            testbundle_tmpApkToolPath = os.path.join(self.taskWorkDir,
                                                     'testbundle_apktooltmp')

            if not os.path.exists(testbundle_tmpApkToolPath):
                os.makedirs(testbundle_tmpApkToolPath)

            log_utils.getLogger().info('decompiling testbundle apk ... ')

            #测试桩反编译 到   工作目录下/testbundle_decompile
            ret = cmd_tools.decompileApk(tmpTestBundleApk,
                                         testbundle_decompileDir,
                                         testbundle_tmpApkToolPath)
            if ret:
                raise PackException(
                    pack_exception.DECOMPLE_APK_FAILED,
                    'decompile testbundle apk %s failed' % tmpTestBundleApk)

            testbundle_packageName = "com.boyaa.application.testbundle"
            # 修改manifest.xml
            self.repackTestBundleForMatch(self.sdksRootDir,
                                          testbundle_decompileDir,
                                          self._packageName)

            log_utils.getLogger().info(
                'generating new r file for testbundle... ')
            #重新生成测试桩的R文件
            ret = cmd_tools.produceNewRFile(testbundle_packageName,
                                            testbundle_decompileDir)
            if ret:
                raise PackException(
                    pack_exception.PRODUCE_NEW_R_FILE_FAILED,
                    'produce new r file for testbundle failed')

            #重新编译测试桩apk
            testbundle_tempRecompileApkDir = self.taskWorkDir + '/testbundle_tempRecompileApk'
            testbundle_tempRecompileApk = '%s/testbundle_nosig.apk' % (
                testbundle_tempRecompileApkDir)
            testbundle_tempSignedApkName = '%s/testbundle_sig.apk' % (
                testbundle_tempRecompileApkDir)

            log_utils.getLogger().info(
                'recompiling apk ... tempRecompileApk = ' +
                testbundle_tempRecompileApk)
            ret = cmd_tools.recompileApk(testbundle_decompileDir,
                                         testbundle_tempRecompileApk,
                                         testbundle_tmpApkToolPath)
            if ret:
                raise PackException(pack_exception.RECOMPILE_APK_FAILED,
                                    'recompile test bundle apk failed')

            self.doPackWithoutChannelSymbol(
                testbundle_tempRecompileApk, testbundle_tempSignedApkName,
                os.path.join(self.outputDir, 'testbundle'), "testbundle.apk")

            #log_utils.getLogger().info('doPack: =============================================success=============================================' + StreamHandler.terminator)

        except PackException as pe:
            log_utils.getLogger().error(pe)
            #log_utils.getLogger().info('doPack: =============================================Failed=============================================' + StreamHandler.terminator)
            return
예제 #27
0
def getUIConfigXmlPath():
    return getFullPath(constant.sdkRelatePath +
                       ConfigParse.shareInstance().getChannelName() +
                       "/uiconfig.xml")
    rlImg = Image.open(gameIconPath)

    if useMark:
        markName = 'right-bottom'
        if markType == 'rb':
            markName = 'right-bottom'
        elif markType == 'rt':
            markName = 'right-top'
        elif markType == 'lt':
            markName = 'left-top'
        elif markType == 'lb':
            markName = 'left-bottom'

        markPath = file_operate.getFullPath(
            constant.sdkRelatePath + ConfigParse.shareInstance(
            ).getChannelName()) + '/icon_marks/' + markName + '.png'
        if not os.path.exists(markPath):
            return 1
        else:
            markIcon = Image.open(markPath)
            rlImg = appendIconMark(rlImg, markIcon, (0, 0))


#             rlImg.show()

    ldpiSize = (36, 36)
    mdpiSize = (48, 48)
    hdpiSize = (72, 72)
    xhdpiSize = (96, 96)
    xxhdpiSize = (144, 144)
    xxxhdpiSize = (512, 512)
예제 #29
0
def getVersionName():
    return ConfigParse.shareInstance().getVersionName()
예제 #30
0
def getForManifestXmlPath():
    return getFullPath(constant.sdkRelatePath +
                       ConfigParse.shareInstance().getChannelName() +
                       "/ForManifest.xml")