def updateXiaoASOkeyword(jsonData, isHd):
    jsonfile = GetJsonFile(isHd)
    isOld = IsOldVersion(jsonData)
    if isOld:
        APPSTORE_KEYWORD = jsonData["APPSTORE_KEYWORD"]
        strStart = "XIAOMI_KEYWORD"
    else:
        APPSTORE_KEYWORD = jsonData["appstore"]["aso"]
        strStart = "aso_xiaomi"

    cn = APPSTORE_KEYWORD["cn"]
    en = APPSTORE_KEYWORD["en"]
    cn = cn.replace(",", " ")
    en = en.replace(",", " ")

    strEnd = "\""

    strFile = common.GetFileString(jsonfile)

    strMid = "\"cn\": \""
    strFile = replaceString2(strFile, strStart, strMid, strEnd, cn)

    strMid = "\"en\": \""
    strFile = replaceString2(strFile, strStart, strMid, strEnd, en)
    common.saveString2File(strFile, jsonfile)
Пример #2
0
 def SaveJson(self, filePath, dataRoot):
     # 保存json
     # json.dumps(dataRoot, f, ensure_ascii=False,indent=4,sort_keys = True).encode('utf8',"ignore")
     json_str = json.dumps(dataRoot,
                           ensure_ascii=False,
                           indent=4,
                           sort_keys=True)
     common.saveString2File(json_str, filePath)
def replaceScreenOrientation(filePath, isHd):
    strFile = common.GetFileString(filePath)

    str = "sensorPortrait"
    if isHd:
        str = "sensorLandscape"

    strFile = strFile.replace("_SCREENORIENTATION_", str)

    common.saveString2File(strFile, filePath)
def CopyAndroidJavaFile_Weixin(rootStudio, isHD):
    dirroot = common.GetProjectConfigApp()
    strFileFrom = dirroot + "/android/src/wxapi/WXEntryActivity.java"
    strFileTo = rootStudio + "/src/main/java/com/moonma/common/share/wxapi/WXEntryActivity.java"

    # loadJson
    package = AppInfo.GetPackage(source.ANDROID, isHD)
    # 替换包名
    f = open(strFileFrom, 'r')
    strFile = f.read()
    f.close()

    strOut = strFile.replace("_PACKAGE_", package)
    common.saveString2File(strOut, strFileTo)
def UpdateXcodeProjectFile(fileProject, isHD):
    flag = os.path.exists(fileProject)
    if not flag:
        return

    package = AppInfo.GetPackage(source.IOS, isHD)

    # 读取xcode文件的包名
    # PRODUCT_BUNDLE_IDENTIFIER = com.moonma.xiehanzi.pad;
    strFile = common.GetFileString(fileProject)
    strHead = "PRODUCT_BUNDLE_IDENTIFIER = "
    strEnd = ";"
    idx = strFile.find(strHead)
    if idx >= 0:
        idx += len(strHead)
        strOther = strFile[idx:]
        idx = strOther.find(strEnd)
        packageold = strOther[0:idx]
        print("packageold=" + packageold)
        strFile = strFile.replace(packageold, package)
        common.saveString2File(strFile, fileProject)
    def ConfigXcodeProjectFile(self, fileProject):
        strFile = common.GetFileString(fileProject)

        #  		OTHER_LDFLAGS = (
        # 					"$(inherited)",
        # 					"-weak_framework",
        # 					CoreMotion,
        # 					"-weak-lSystem",
        # 				);
        #
        strold = "\"-weak-lSystem\","
        strnew = "\"-weak-lSystem\",\n\"-ObjC\","
        idx = strFile.find(strnew)
        if idx >= 0:
            return

        strFile = strFile.replace(strold, strnew)

        # DEVELOPMENT_TEAM
        strold = "DEVELOPMENT_TEAM = \"\""
        strnew = "DEVELOPMENT_TEAM = \"Y9ZUK2WTEE\""
        strFile = strFile.replace(strold, strnew)

        common.saveString2File(strFile, fileProject)
Пример #7
0
    def UpdateApp(self, isHD):
        # self.UpdateAppOld(isHD)
        # return
        old_window = self.driver.current_window_handle
        webcmd = WebDriverCmd(self.driver)
        # 打开新标签
        # self.driver.find_element_by_xpath('//body').send_keys(Keys.CONTROL,"t")
        # js = "window.open('')"
        # self.driver.execute_script(js)
        # time.sleep(2)

        appid = AppInfo.GetAppId(isHD, source.HUAWEI)
        # https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/myApp/101054959
        url = "https://developer.huawei.com/consumer/cn/service/josp/agc/index.html#/myApp/" + appid
        self.driver.get(url)
        time.sleep(1)
        # 等待网页加载成功
        key = "//iframe[@id='mainIframeView']"
        while True:
            time.sleep(1)
            print("web is loading...")
            if self.IsElementExist(key) == True:
                print("web loading finish")
                break

        self.driver.switch_to.frame("mainIframeView")
        time.sleep(3)

        key = "//span[@class='green-circle']"

        # red-circle
        if self.IsElementExist(key) == False:
            # 待修改
            key = "//span[@class='red-circle']"
            if self.IsElementExist(key) == False:
                key = "//span[@class='yellow-circle']"
                # 第一次上传apk
                # self.PreSubmitApp(isHD)
                # return
        if self.IsElementExist(key) == False:
            print("key fail key=", key)
            print("self.driver.current_url fail=", self.driver.current_url)
            # print(self.driver.page_source)
            common.saveString2File(self.driver.page_source, "1.html")

        item = self.driver.find_element(By.XPATH, key)
        item.click()
        time.sleep(5)

        # 跳转到新的页面
        print("self.driver.current_url=", self.driver.current_url)
        # self.driver.switch_to.window(self.driver.window_handles[0])
        for win in self.driver.window_handles:
            if win != old_window:
                self.driver.switch_to.window(win)
        time.sleep(3)
        print("self.driver.current_url 2=", self.driver.current_url)

        self.driver.switch_to.frame("mainIframeView")

        old_window = self.driver.current_window_handle
        # 升级按钮
        key = "//a[@id='VersionUpgradeButton']"
        if self.IsElementExist(key):
            item = self.driver.find_element(By.XPATH, key)
            item.click()
            time.sleep(2)

        # 跳转到新的页面
        print("self.driver.current_url=", self.driver.current_url)
        # self.driver.switch_to.window(self.driver.window_handles[0])
        for win in self.driver.window_handles:
            if win != old_window:
                self.driver.switch_to.window(win)
        time.sleep(3)
        print("self.driver.current_url 2=", self.driver.current_url)

        self.driver.switch_to.frame("mainIframeView")
        time.sleep(3)

        self.UpdateApk(isHD)

        time.sleep(1)

        # 隐私政策网址
        key = "//input[@id='VerInfoPrivacyPolicyInputBox']"
        webcmd.AddCmd(CmdType.INPUT, key, AppInfo.GetAppPrivacyUrl(isHD))
        webcmd.Run(True)

        # 不申请
        key = "//span[@id='VerInfoNotApplyButton']"
        if self.IsElementExist(key):
            webcmd.AddCmd(CmdType.CLICK_Action, key)
            webcmd.Run(True)

        # item = self.driver.find_element(By.XPATH, "//span[@id='VerInfoNotApplyButton']")
        # item.click()
        # time.sleep(1)

        # 提交审核
        item = self.driver.find_element(By.XPATH,
                                        "//a[@id='VerInfoSubmitButton']")
        item.click()
        time.sleep(3)

        # 确定
        item = self.driver.find_element(By.XPATH,
                                        "//a[@id='AppSubmitConfirmButtonOk']")
        item.click()
        time.sleep(3)
def updateName(isHd, isAuto):
    appinfoOld = AppInfoOld(isHd)
    if appinfoOld.IsOldVersion():
        # 转换
        ConvertOld2New(isHd, appinfoOld)

    rootConfig = common.GetProjectConfigApp()
    strHD = "HD"

    project_ios = rootConfig + "/ios/project"
    project_android = rootConfig + "/android/project"

    if isHd:
        project_ios = rootConfig + "/ios/project_hd"
        project_android = rootConfig + "/android/project_hd"

    # android
    file_name_cn_android = project_android + "/res/values/strings.xml"
    file_name_en_android = project_android + "/res/values-en/strings.xml"
    file_AndroidManifest = project_android + "/xml/AndroidManifest.xml"
    file_AndroidManifest_GP = project_android + "/xml_gp/AndroidManifest.xml"

    file_google_service_android = project_android + "/config/google-services.json"

    # ios
    file_name_cn_ios = project_ios + "/appname/zh-Hans.lproj/InfoPlist.strings"
    file_name_en_ios = project_ios + "/appname/en.lproj/InfoPlist.strings"
    file_info_plist_ios = project_ios + "/Info.plist"

    # loadJson
    data = loadJson(isHd)

    isOld = IsOldVersion(data)
    global versionCode

    if not isOld:
        appname = data["appname"]

    if isOld:
        APP_NAME_CN_ANDROID = data["APP_NAME_CN_ANDROID"]
        APP_NAME_EN_ANDROID = data["APP_NAME_EN_ANDROID"]
        APP_NAME_CN_IOS = data["APP_NAME_CN_IOS"]
        APP_NAME_EN_IOS = data["APP_NAME_EN_IOS"]
        PACKAGE_ANDROID = data["PACKAGE_ANDROID"]
        PACKAGE_IOS = data["PACKAGE_IOS"]
        versionCode = data["APPVERSION_CODE_ANDROID"]
        APPVERSION_IOS = data["APPVERSION_IOS"]
        appid_huawei = GetConfigDataAppId(source.ANDROID, source.HUAWEI, isHd)
    else:
        APP_NAME_CN_ANDROID = appname[source.ANDROID]["cn"]
        APP_NAME_EN_ANDROID = appname[source.ANDROID]["en"]
        APP_NAME_CN_IOS = appname[source.IOS]["cn"]
        APP_NAME_EN_IOS = appname[source.IOS]["en"]
        PACKAGE_ANDROID = data["apppackage"][source.ANDROID]["default"]
        PACKAGE_IOS = data["apppackage"][source.IOS]["default"]
        versionCode = data["appversion"][source.ANDROID]["code"]
        APPVERSION_IOS = data["appversion"][source.IOS]["value"]

        #appid
        appid_ios = GetJsonAppId(data, source.APPSTORE)
        appid_taptap = GetJsonAppId(data, source.TAPTAP)
        appid_huawei = GetJsonAppId(data, source.HUAWEI)
        SetConfigDataAppId(source.IOS, source.APPSTORE, appid_ios, isHd)
        SetConfigDataAppId(source.ANDROID, source.TAPTAP, appid_taptap, isHd)
        SetConfigDataAppId(source.ANDROID, source.HUAWEI, appid_huawei, isHd)
        UpdateLanguageName(APP_NAME_CN_ANDROID, APP_NAME_EN_ANDROID, isHd)

    # if data.has_key("PACKAGE_HD_ANDROID"):
    #     PACKAGE_HD_ANDROID = data["PACKAGE_HD_ANDROID"]

    if isAuto == True:
        autoPlusVersion(isHd, data)
        # 重新加载
        data = loadJson(isHd)

    APPVERSION_ANDROID = versionCodeToVersion()
    APPVERSION_CODE_ANDROID = versionCode

    # appversion.json
    if isAuto == False:
        src = common.GetProjectConfigDefault() + "/appinfo/appversion.json"
        dst = common.GetProjectConfigApp() + "/appinfo/appversion.json"
        flag = os.path.exists(dst)
        #
        if not isHd:
            shutil.copyfile(src, dst)

        strfile = common.GetFileString(dst)
        key = "_VERSION_ANDROID_"
        if isHd:
            key = "_VERSION_HD_ANDROID_"

        version_web = mainAppVersionHuawei.ParseVersion(appid_huawei)
        strfile = strfile.replace(key, version_web)
        common.saveString2File(strfile, dst)

        filepath = common.GetProjectConfigAppType() + "/appversion.json"
        flag = os.path.exists(filepath)
        strFileJson = "{}"
        if flag:
            strFileJson = common.GetFileString(filepath)
        dataRoot = json.loads(strFileJson)
        dataRoot[common.getGameName()] = json.loads(strfile)
        common.SaveJson(filepath, dataRoot)

    print(APP_NAME_CN_ANDROID)
    print(APP_NAME_EN_ANDROID)
    print(APP_NAME_CN_IOS)
    print(APP_NAME_EN_IOS)
    print(PACKAGE_ANDROID)

    print("android version:" + APPVERSION_ANDROID)
    print("ios version:" + APPVERSION_IOS)

    # android
    # name
    strStart = "app_name\">"
    strEnd = "<"
    # cn
    strOut = replaceStringOfFile(file_name_cn_android, strStart, strEnd,
                                 APP_NAME_CN_ANDROID)
    saveString2File(strOut, file_name_cn_android)
    # en
    strOut = replaceStringOfFile(file_name_en_android, strStart, strEnd,
                                 APP_NAME_EN_ANDROID)
    saveString2File(strOut, file_name_en_android)

    updateAndroidManifest(file_AndroidManifest, PACKAGE_ANDROID,
                          APPVERSION_ANDROID, APPVERSION_CODE_ANDROID, isHd)
    updateAndroidManifest(file_AndroidManifest_GP, PACKAGE_ANDROID,
                          APPVERSION_ANDROID, APPVERSION_CODE_ANDROID, isHd)

    # admob
    replaceGoogleServiceFile(file_google_service_android, PACKAGE_ANDROID)

    # ios

    #appname
    replaceFile(file_info_plist_ios, "_APP_NAME_", APP_NAME_CN_IOS)
    file_name_cn_ios = project_ios + "/appname/zh-Hans.lproj/InfoPlist.strings"
    file_name_en_ios = project_ios + "/appname/en.lproj/InfoPlist.strings"
    # cn
    replaceFile(file_name_cn_ios, "_APP_NAME_", APP_NAME_CN_IOS)
    # en
    replaceFile(file_name_en_ios, "_APP_NAME_", APP_NAME_EN_IOS)

    # package
    replaceFile(file_info_plist_ios, "_APP_PACKAGE_", PACKAGE_IOS)

    # version
    replaceFile(file_info_plist_ios, "_APP_VERSION_", APPVERSION_IOS)

    #admob appid
    appid = adconfig.GetCommonAppId(source.ADMOB, source.IOS, isHd)
    replaceFile(file_info_plist_ios, "_APP_ID_ADMOB_", appid)

    # CFBundleURLSchemes
    src = source.WEIBO
    appid = config.GetShareAppId(src, source.IOS, isHd)
    replaceXcodeUrlScheme(file_info_plist_ios, src, appid, 0)

    src = source.WEIXIN
    appid = config.GetShareAppId(src, source.IOS, isHd)
    replaceXcodeUrlScheme(file_info_plist_ios, src, appid, 0)

    src = source.QQ
    appid = config.GetShareAppId(src, source.IOS, isHd)
    replaceXcodeUrlScheme(file_info_plist_ios, src, appid, 0)
    replaceXcodeUrlScheme(file_info_plist_ios, src, appid, 1)

    # xiaomi aso keyword
    updateXiaoASOkeyword(data, isHd)

    # win
    updateNameWin(isHd, isAuto)
def saveString2File(str, file):
    common.saveString2File(str, file)
def replaceFile(filePath, key, value):
    strFile = common.GetFileString(filePath)
    strFile = strFile.replace(key, value)
    common.saveString2File(strFile, filePath)
def replaceFileForKey(filePath, key, content):
    # f = open(filePath, 'rb')
    # f = open(filePath,'r', encoding='utf-8')
    strFile = common.GetFileString(filePath)
    strFile = strFile.replace(key, content)
    common.saveString2File(strFile, filePath)
def replacePackage(filePath, package):
    strFile = common.GetFileString(filePath)
    strFile = strFile.replace("_PACKAGE_", package)
    common.saveString2File(strFile, filePath)