def main():
    
    file_utils.printF("-------------------------encrypt config start------------------------")
    channels = config_utils.getAllChannels()
   
   # 循环获取每个channel,将每个channel的属性经过AzDG加密,输出为以channel_name为名的xml文件,并复制该xml文件到path属性下
    for channel in channels:    
        chnXml = config_utils.genChannelParamsXml(channel)
        sdkDemoPath = chnXml.getAttribute("path")
        chnXml.removeAttribute("path") ##不传递给sdk代码
        
        azdg = AzDG.AzDG()
        jsonStr = config_utils.xmltojson(chnXml.toprettyxml().encode())
        m = azdg.encode(jsonStr)  # 存储加密后的json文本
        
        fileDir = os.path.dirname(file_utils.curDir) + "\\" + sdkDemoPath
        if os.path.exists( fileDir ):
            path = fileDir + "\\assets\\" + "fssdk_config"
            file_utils.setFileContent(m, path)
            file_utils.printF("* save encrypt config : %s", sdkDemoPath + "\\assets\\")

            path = fileDir + "\\additional\\assets\\" + "fssdk_config"
            file_utils.setFileContent(m, path)
            file_utils.printF("* save encrypt config : %s", sdkDemoPath + "\\additional\\assets\\")
                
                # 解密
                # content = azdg.decode(m)
                # file_utils.setFileContent(content, file_utils.curDir + "\\" + param.getAttribute("value") + ".txt")

    file_utils.printF("-------------------------encrypt config over------------------------\r\n\r\n")
Beispiel #2
0
def main(game, isPublic, target):
    appName = game['appName']
    channels = config_utils.getAllChannels(appName, isPublic)
    if channels is None or len(channels) == 0:
        print("没有任何可以打包的渠道")
        return 3

    selected = []

    if target == '*':
        selected = channels
    else:
        for t in target.split(','):
            t = t.strip()
            matchChannels = [c for c in channels if c['name'].lower() == t.lower()]
            if len(matchChannels) > 0:
                selected.append(matchChannels[0])

    clen = len(selected)
    log_utils.info("now hava %s channels to package...", clen)
    baseApkPath = file_utils.getFullPath('games/'+game['appName']+'/u8.apk')
    log_utils.info("the base apk file is : %s", baseApkPath)

    if not os.path.exists(baseApkPath):
        log_utils.error('the base apk file is not exists, must named with u8.apk')
        return 2

    sucNum = 0
    failNum = 0
    
    for channel in selected:
        ret = core.pack(game, channel, baseApkPath, isPublic)
        if ret:
            exit(1)
            failNum = failNum + 1
        else:
            sucNum = sucNum + 1

    log_utils.info("<< success num:%s; failed num:%s >>", sucNum, failNum)
    if failNum > 0:
        log_utils.error("<< all done with error >>")
    else:
        log_utils.info("<< all nice done >>")
    return 0
Beispiel #3
0
def packAllChannels(game, isPublic, threadNum):

    basePath = file_utils.getCurrDir()
    log_utils.info("Curr Work Dir::%s", basePath)

    appName = game['appName']
    channels = config_utils.getAllChannels(appName, isPublic)

    if channels != None and len(channels) > 0:

        clen = len(channels)
        log_utils.info("Now Have %s channels to package ", clen)
        packagePath = file_utils.getFullPath('games/'+game['appName']+'/yxme.apk')
        log_utils.info("The base apk file is : %s", packagePath)

        if not os.path.exists(packagePath):
            log_utils.error("The apk file name must be 'yxme.apk'")
            return

        que = queue.Queue()
        for channel in channels:
            que.put(channel, True, None)

        # start threads to pack

        if threadNum <= 0:
            threadNum = 1

        log_utils.info("Now start %s threads to pack", threadNum)

        for i in range(threadNum):
            thread = PackerThread(que, packagePath, isPublic, game, i+1)
            thread.start()

        que.join()

        log_utils.info("<< all nice done >>")
    else:
        log_utils.info("<< no channels to pack >>")
def packAllChannels(game, isPublic, threadNum):

    basePath = file_utils.getCurrDir()
    log_utils.info("Curr Work Dir::%s", basePath)

    appName = game['appName']
    channels = config_utils.getAllChannels(appName, isPublic)

    if channels != None and len(channels) > 0:

        clen = len(channels)
        log_utils.info("Now Have %s channels to package ", clen)
        packagePath = file_utils.getFullPath("u8.apk")
        log_utils.info("The base apk file is : %s", packagePath)

        if not os.path.exists(packagePath):
            log_utils.error("The apk file name must be 'u8.apk'")
            return

        que = queue.Queue()
        for channel in channels:
            que.put(channel, True, None)

        # start threads to pack

        if threadNum <= 0:
            threadNum = 1

        log_utils.info("Now start %s threads to pack", threadNum)

        for i in range(threadNum):
            thread = PackerThread(que, packagePath, isPublic, game, i+1)
            thread.start()

        que.join()

        log_utils.info("<< all nice done >>")
    else:
        log_utils.info("<< no channels to pack >>")
Beispiel #5
0
def main():

    file_utils.printF(
        "-------------------------encrypt config start------------------------"
    )
    channels = config_utils.getAllChannels()

    # 循环获取每个channel,将每个channel的属性经过AzDG加密,输出为以channel_name为名的xml文件,并复制该xml文件到path属性下
    for channel in channels:
        chnXml = config_utils.genChannelParamsXml(channel)
        sdkDemoPath = chnXml.getAttribute("path")
        chnXml.removeAttribute("path")  ##不传递给sdk代码

        azdg = AzDG.AzDG()
        jsonStr = config_utils.xmltojson(chnXml.toprettyxml().encode())
        m = azdg.encode(jsonStr)  # 存储加密后的json文本

        fileDir = os.path.dirname(file_utils.curDir) + "\\" + sdkDemoPath
        if os.path.exists(fileDir):
            path = fileDir + "\\assets\\" + "fssdk_config"
            file_utils.setFileContent(m, path)
            file_utils.printF("* save encrypt config : %s",
                              sdkDemoPath + "\\assets\\")

            path = fileDir + "\\additional\\assets\\" + "fssdk_config"
            file_utils.setFileContent(m, path)
            file_utils.printF("* save encrypt config : %s",
                              sdkDemoPath + "\\additional\\assets\\")

            # 解密
            # content = azdg.decode(m)
            # file_utils.setFileContent(content, file_utils.curDir + "\\" + param.getAttribute("value") + ".txt")

    file_utils.printF(
        "-------------------------encrypt config over------------------------\r\n\r\n"
    )
Beispiel #6
0
def main(game, isPublic, isFullRes = False):

    print(u"**********当前配置的渠道号**********")
    print(u"\t渠道名 \t\t 渠道号 \t\t 渠道 \n")

    appName = game['appName']

    channels = config_utils.getAllChannels(appName, isPublic)

    if channels is None or len(channels) == 0:
        print("没有任何可以打包的渠道")
        return

    for ch in channels:
        name = ch['name']
        if len(name) <= 6:
            chStr = u"\t%s \t\t\t %s \t\t %s " % (ch['name'], ch['id'], ch['desc'])
        elif len(name) > 6 and len(name) <= 13:
            chStr = u"\t%s \t\t %s \t\t %s " % (ch['name'], ch['id'], ch['desc'])
        else:
            chStr = u"\t%s \t %s \t\t %s " % (ch['name'], ch['id'], ch['desc'])
        
        print(chStr)


    selected = []

    while(True):
        sys.stdout.write(u"请选择需要打包的渠道(渠道名),全部输入*,多个用逗号分割:")
        sys.stdout.flush()

        target = raw_input()

        if target == '*':
            selected = channels
        else:
            for t in target.split(','):
                t = t.strip()
                matchChannels = [c for c in channels if c['name'].lower() == t.lower()]
                if len(matchChannels) > 0:
                    selected.append(matchChannels[0])

        if len(selected) == 0:
            print(u"\n无效的渠道名,请重新输入!!\n")
        else:
            break

    clen = len(selected)
    log_utils.info("now hava %s channels to package...", clen)
    baseApkPath = file_utils.getFullPath('games/'+game['appName']+'/u8.apk')
    log_utils.info("the base apk file is : %s", baseApkPath)

    if not os.path.exists(baseApkPath):
        log_utils.error('the base apk file is not exists, must named with u8.apk')
        return

    sucNum = 0
    failNum = 0

    for channel in selected:
        ret = core.pack(game, channel, baseApkPath, isPublic)
        if ret:
            failNum = failNum + 1
        else:
            sucNum = sucNum + 1

    log_utils.info("<< success num:%s; failed num:%s >>", sucNum, failNum)
    if failNum > 0:
        log_utils.error("<< all done with error >>")
    else:
        log_utils.info("<< all nice done >>")
def main(game, isPublic, isFullRes = False):

    print(u"**********当前配置的渠道号**********")
    print(u"\t渠道名 \t\t 渠道号 \t\t 渠道 \n")

    appName = game['appName']

    channels = config_utils.getAllChannels(appName, isPublic)

    if channels is None or len(channels) == 0:
        print("没有任何可以打包的渠道")
        return

    for ch in channels:
        name = ch['name']
        if len(name) <= 6:
            chStr = u"\t%s \t\t\t %s \t\t %s " % (ch['name'], ch['id'], ch['desc'])
        elif len(name) > 6 and len(name) <= 13:
            chStr = u"\t%s \t\t %s \t\t %s " % (ch['name'], ch['id'], ch['desc'])
        else:
            chStr = u"\t%s \t %s \t\t %s " % (ch['name'], ch['id'], ch['desc'])
        
        print(chStr)


    selected = []

    while(True):
        sys.stdout.write(u"请选择需要打包的渠道(渠道名),全部输入*,多个用逗号分割:")
        sys.stdout.flush()

        target = raw_input()

        if target == '*':
            selected = channels
        else:
            for t in target.split(','):
                t = t.strip()
                matchChannels = [c for c in channels if c['name'].lower() == t.lower()]
                if len(matchChannels) > 0:
                    selected.append(matchChannels[0])

        if len(selected) == 0:
            print(u"\n无效的渠道名,请重新输入!!\n")
        else:
            break

    clen = len(selected)
    log_utils.info("now hava %s channels to package...", clen)
    baseApkPath = file_utils.getFullPath('games/'+game['appName']+'/u8.apk')
    log_utils.info("the base apk file is : %s", baseApkPath)

    if not os.path.exists(baseApkPath):
        log_utils.error('the base apk file is not exists, must named with u8.apk')
        return

    sucNum = 0
    failNum = 0

    for channel in selected:
        ret = core.pack(game, channel, baseApkPath, isPublic)
        if ret:
            failNum = failNum + 1
        else:
            sucNum = sucNum + 1

    log_utils.info("<< success num:%s; failed num:%s >>", sucNum, failNum)
    if failNum > 0:
        log_utils.error("<< all done with error >>")
    else:
        log_utils.info("<< all nice done >>")
Beispiel #8
0
def game_config_xml():
    for filename in os.listdir(os.getcwd() + '/games'):
        filename = str(filename)
        if not (filename == 'sql.py' or filename == 'games.xml'
                or filename == 'games.py' or filename == '__pycache__'
                or filename == 'config_utils.py' or filename == 'file_utils.py'
                or filename == 'log_utils.py'
                or filename == 'log'):  #排除非正常目录文件
            print(filename)
            channels = config_utils.getAllChannels(filename,
                                                   isPublic)  #读取目录config内容
            for channel in channels:
                channel_sql_key = channel_sql_value = sdkParams_sql_key = sdkParams_sql_value = params_sql_key = params_sql_value = operations_sql_key = operations_sql_value = plugins_sql_key = plugins_sql_value = ''
                for channel_sub in channel:
                    channel_sub = str(channel_sub)
                    if not (channel_sub == 'params' or channel_sub
                            == 'operations' or channel_sub == 'plugins'
                            or channel_sub == 'sdkParams'
                            or channel_sub == 'third-plugins'):
                        # print(channel_sub+' : '+ channel[channel_sub])
                        channel_sql_key = channel_sql_key + '`' + str(
                            channel_sub) + '`,'
                        channel_sql_value = channel_sql_value + '"' + str(
                            channel[channel_sub]) + '",'

                    if channel_sub == 'sdkParams':
                        sdkParams = channel[channel_sub]
                        sdkParamint = 1
                        for sdkParam in sdkParams:
                            # print(sdkParam+' : ' + sdkParams[sdkParam])
                            sdkParams_sql_key = sdkParams_sql_key + '`key' + str(
                                sdkParamint) + '`,`value' + str(
                                    sdkParamint) + '`,'
                            sdkParams_sql_value = sdkParams_sql_value + '"' + str(
                                sdkParam) + '","' + str(
                                    sdkParams[sdkParam]) + '",'
                            sdkParamint = sdkParamint + 1

                    if channel_sub == 'params':
                        params = channel[channel_sub]
                        paramint = 1
                        for param in params:
                            for param_sub in param:
                                # print(param_sub+' : ' + param[param_sub])
                                params_sql_key = params_sql_key + '`' + str(
                                    param_sub) + str(paramint) + '`,'
                                params_sql_value = params_sql_value + '"' + str(
                                    param[param_sub]) + '",'
                            paramint = paramint + 1

                    if channel_sub == 'operations':
                        operations = channel[channel_sub]
                        operationint = 1
                        for operation in operations:
                            for operation_sub in operation:
                                # print(operation_sub+' : ' + operation[operation_sub])
                                operations_sql_key = operations_sql_key + '`' + str(
                                    operation_sub) + str(operationint) + '`,'
                                operations_sql_value = operations_sql_value + '"' + str(
                                    operation[operation_sub]) + '",'
                            operationint = operationint + 1

                    if channel_sub == 'plugins':
                        plugins = channel[channel_sub]
                        pluginint = 1
                        for plugin in plugins:
                            for plugin_sub in plugin:
                                # print(plugin_sub+' : ' + plugin[plugin_sub])
                                plugins_sql_key = plugins_sql_key + '`' + str(
                                    plugin_sub) + str(pluginint) + '`,'
                                plugins_sql_value = plugins_sql_value + '"' + str(
                                    plugin[plugin_sub]) + '",'
                            pluginint = pluginint + 1

                    if channel_sub == 'id':
                        channelid = str(channel[channel_sub])
                    if channel_sub == 'name':
                        gamename = str(channel[channel_sub])

                sql_sign = str(
                    int(time.time() * 10000000000) +
                    random.randint(0, 999999999))
                channel_sql_write = 'insert into channel (' + channel_sql_key + '`sdkParams`,`params`,`operations`,`plugins`,`game`) values (' + channel_sql_value + '"' + sql_sign + '","' + sql_sign + '","' + sql_sign + '","' + sql_sign + '","' + filename + '")'
                sdkParams_sql_write = 'insert into channel_sdkParams (' + sdkParams_sql_key + '`id`) values (' + sdkParams_sql_value + '"' + sql_sign + '")'
                params_sql_write = 'insert into channel_params (' + params_sql_key + '`id`) values (' + params_sql_value + '"' + sql_sign + '")'
                operations_sql_write = 'insert into channel_operations (' + operations_sql_key + '`id`) values (' + operations_sql_value + '"' + sql_sign + '")'
                plugins_sql_write = 'insert into channel_plugins (' + plugins_sql_key + '`id`) values (' + plugins_sql_value + '"' + sql_sign + '")'

                if query(filename, channelid, gamename):
                    if write(channel_sql_write):  # 写入渠道信息
                        write(sdkParams_sql_write)
                        write(params_sql_write)
                        write(operations_sql_write)
                        write(plugins_sql_write)

            print('===================================================')
Beispiel #9
0
def main(game, isPublic, channelName):

    appName = game['appName']

    baseApkPath = file_utils.getFullPath('games/' + appName + '/u8.apk')
    log_utils.info("the base apk file is : %s", baseApkPath)

    if not os.path.exists(baseApkPath):
        log_utils.error(
            'the base apk file is not exists, must named with u8.apk')
        return

    channels = config_utils.getAllChannels(appName, isPublic)

    if channels is None or len(channels) == 0:
        log_utils.info("没有任何可以打包的渠道")
        return

    if channelName is not None:

        if channelName == '*':
            packChannels(game, channels, baseApkPath, isPublic)
            return

        selectChannel = getChannelByName(channelName, channels)
        if selectChannel is None:
            log_utils.info("指定的渠道名不存在")
            return

        ret = core.pack(game, selectChannel, baseApkPath, isPublic)
        if ret:
            log_utils.error("<< all done with error >>")

        else:
            log_utils.info("<< all nice done >>")

        return

    print(u"################################################################")
    print(u"\t%-15s%-20s%-20s\n" % (u"渠道名", u"渠道号", u"渠道"))

    for ch in channels:
        print(u"\t%-20s%-20s%-20s" % (ch['name'], ch['id'], ch['desc']))

    print("")

    selected = []

    while (True):
        sys.stdout.write(u"请选择需要打包的渠道(渠道名),全部输入*,多个用逗号分割:")
        sys.stdout.flush()

        target = input()

        if target == '*':
            selected = channels
        else:
            for t in target.split(','):
                t = t.strip()
                matchChannels = [
                    c for c in channels if c['name'].lower() == t.lower()
                ]
                if len(matchChannels) > 0:
                    selected.append(matchChannels[0])

        if len(selected) == 0:
            print(u"\n无效的渠道名,请重新输入!!\n")
        else:
            break

    packChannels(game, selected, baseApkPath, isPublic)