Esempio n. 1
0
    def BuildProject(self, isHD, channel):
        name = self.GetProjectName(channel)
        dirproject = mainResource.GetRootCocosBuildOutput() + "/" + name
        appid = mainAppInfo.GetAppId(isHD, channel)
        if name == Source.ProjectNameMiniGameWeixin or name == Source.ProjectNameMiniGameByte:
            filepath = mainResource.GetProjectConfigDefault(
            ) + "/" + name + "/game.json"
            strfile = FileUtil.GetFileString(filepath)
            strfile = strfile.replace("_Orientation_", "portrait")
            filepath = dirproject + "/game.json"
            FileUtil.RemoveFile(filepath)
            FileUtil.SaveString2File(strfile, filepath)

            filepath = mainResource.GetProjectConfigDefault(
            ) + "/" + name + "/project.config.json"
            strfile = FileUtil.GetFileString(filepath)
            print("BuildWeixin  appid=" + appid)
            # wx3e44af039aee1b96
            strfile = strfile.replace("_APPID_", appid)
            # print("BuildWeixin  strfile="+strfile)
            filepath = dirproject + "/project.config.json"
            FileUtil.RemoveFile(filepath)
            FileUtil.SaveString2File(strfile, filepath)

        # python 里无法直接执行cd目录,要用chdir改变当前的工作目录
        if os.path.exists(dirproject):
            os.chdir(dirproject)
        print("dirproject:" + dirproject)
        if name == Source.ProjectNameMiniGameVivo:
            os.system("npm install")
            os.system("npm run build")
    def UploadIAPInfo(self, isHd, stros):
        package = mainAppInfo.GetAppPackage(stros, isHd)
        rootJson = self.LoadJsonIAP(isHd, stros)
        rootConfig = mainResource.GetProjectConfigDefault()
        striap = FileUtil.GetFileString(rootConfig + "/appstore/KEY_IAP.xml")

        listIAP = []
        for item in rootJson["items"]:
            if item["isSkip"]:
                continue

            name = item["key"]
            striap = striap.replace("_NAME_", name)
            product_id = package + "." + item["id"]
            striap = striap.replace("_ID_", product_id)

            # consumable non-consumable
            isConsume = item["isConsume"]
            product_type = "non-consumable"
            if isConsume:
                product_type = "consumable"

            striap = striap.replace("_TYPE_", product_type)

            title_cn = item["title"]["cn"]
            striap = striap.replace("_TITLE_CN_", title_cn)
            title_en = item["title"]["en"]
            striap = striap.replace("_TITLE_EN_", title_en)

            title_cn = item["detail"]["cn"]
            striap = striap.replace("_DETAIL_CN_", title_cn)
            title_en = item["detail"]["en"]
            striap = striap.replace("_DETAIL_EN_", title_en)

            price = item["price_tier"]
            striap = striap.replace("_PRICE_", price)

            listIAP.append(striap)

        str_metadata_xml = FileUtil.GetFileString(rootConfig +
                                                  "/appstore/IAP_metadata.xml")
        str_metadata_xml = str_metadata_xml.replace(
            "_VENDOR_ID_", mainAppInfo.GetAppSKU(isHd))
        strkeyiap = ""
        for strtmp in listIAP:
            strkeyiap += strtmp

        str_metadata_xml = str_metadata_xml.replace("_KEY_IAP_", strkeyiap)

        rootConfig = mainResource.GetProjectConfigApp()
        file_metadata_ios = rootConfig + "/appstore/ios/app.itmsp/metadata.xml"
        if isHd:
            file_metadata_ios = rootConfig + "/appstore/ios/app_pad.itmsp/metadata.xml"

        FileUtil.SaveString2File(str_metadata_xml, file_metadata_ios)
        mainAppstoreUploadiOS.Run(isHd)
Esempio n. 3
0
    def updateXiaoASOkeyword(self,jsonData,isHd):
        jsonfile = self.GetJsonFile(isHd)
        isOld = self.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 = FileUtil.GetFileString(jsonfile)

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

        strMid = "\"en\": \""
        strFile = self.replaceString2(strFile, strStart, strMid, strEnd, en)
        FileUtil.SaveString2File(strFile, jsonfile)
Esempio n. 4
0
 def loadJson(self,isHd): 
     # if self.rootJson!=None:
     #     return self.rootJson
     jsonfile = self.GetJsonFile(isHd) 
     strfile = FileUtil.GetFileString(jsonfile)
     self.rootJson = json.loads(strfile)
     return self.rootJson
Esempio n. 5
0
 def GetKEY_PRIVATE(self):
     dir = os.getcwd()
     filepath = dir + "/AppStore/AuthKey_" + self.API_KEY_ID + ".p8"
     filepath = os.path.normpath(filepath)
     # print(filepath)
     KEY_PRIVATE = FileUtil.GetFileString(filepath)
     return KEY_PRIVATE
Esempio n. 6
0
 def replaceStringOfFile2(self,filePath, strStart, strMid, strEnd, strReplace):
     strFile = FileUtil.GetFileString(filePath)
     # print strFile
     strOut = self.replaceString2(strFile, strStart, strMid, strEnd, strReplace)
     # print strOut
     # fp_name.seek(0)
     # fp_name.write(strOut) 
     return strOut
    def ScanImageFile(self, dir, filejson):
        # if not os.path.exists(dir):
        #     return

        listFile = []
        if os.path.exists(dir):
            FileUtil.GetFileList(dir, "png", listFile)
            FileUtil.GetFileList(dir, "jpg", listFile)
            print("listFile len=" + str(len(listFile)))
        dataRootOld = None
        if os.path.exists(filejson) == True:
            print("filejson = " + filejson)
            strfile = FileUtil.GetFileString(filejson)
            # print("strfile = "+strfile)
            dataRootOld = json.loads(strfile)
            if dataRootOld is None:
                print("dataRootOld is  none")
                print("strfile = " + strfile)
            # remove
            os.remove(filejson)

        dataRoot = json.loads("{}")
        #        "BtnIconPlay" : {
        #     "path" : "App/UI/Common/Button/BtnIconPlay.png"
        # },
        for fileimage in listFile:

            item = json.loads("{}")
            filepath = fileimage.replace(
                mainResource.GetRootUnityAssets() + "/", "")
            filepath = filepath.replace(self.dirCloudResHead, "")

            item["path"] = filepath
            name = FileUtil.GetPathNameWithoutExt(fileimage)

            # 从原来的json中恢复board
            if dataRootOld is not None:
                # print("dataRootOld is not none")
                if name in dataRootOld:
                    # print("dataRootOld  name="+name)
                    dataitem = dataRootOld[name]
                    key = "board"
                    # key = "path"
                    # if name =="BtnCommon":
                    #     # key = "board"
                    #     print("dataitem[key] = "+dataitem[key]+" name="+name)

                    if key in dataitem:
                        print("key = " + key + " name=" + name)
                        item[key] = dataitem[key]

            dataRoot[name] = item

        json_str = json.dumps(dataRoot,
                              ensure_ascii=False,
                              indent=4,
                              sort_keys=True)
        FileUtil.SaveString2File(json_str, filejson)
Esempio n. 8
0
 def AddCookie(self,filepath):
     flag = os.path.exists(filepath)
     if flag ==False:
         return
     self.driver.delete_all_cookies()
     strfile = FileUtil.GetFileString(filepath) 
     list_cookies=json.loads(strfile)
     # cookies=self.getPureDomainCookies(list_cookies)
     for i in list_cookies:
         self.driver.add_cookie(i)
Esempio n. 9
0
    def replaceScreenOrientation(self,filePath,isHd):
        strFile = FileUtil.GetFileString(filePath)

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

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

        FileUtil.SaveString2File(strFile,filePath)
Esempio n. 10
0
    def UpdateLanguageName(self,csvfile,name_cn,name_en,ishd): 
        strContent = FileUtil.GetFileString(csvfile)
        key_name = self.GetCSVName(strContent,ishd) 

        head = "APP_NAME"
        if ishd:
            head = "APP_NAME_HD"

        str_new = head+","+name_cn+"," +name_en
        # +"\n"
        self.replaceFile(csvfile,key_name,str_new)
Esempio n. 11
0
 def replaceStringOfFile(self,filePath, strStart, strEnd, strReplace):
     # f = open(filePath)
     # f = open(filePath,'r', encoding='UTF-8') 
     strFile = FileUtil.GetFileString(filePath)
     # strFile.decode('utf-8')
     # print strFile
     strOut = self.replaceString(strFile, strStart, strEnd, strReplace)
     # print strOut
     # fp_name.seek(0)
     # fp_name.write(strOut) 
     return strOut
Esempio n. 12
0
    def GetPackageAndroidFromXml(self):
        fileXml = self.GetRootDirAndroidStudio(
        ) + "/src/main/AndroidManifest.xml"
        strFile = FileUtil.GetFileString(fileXml)
        # package="com.moonma.shapecolor.pad"
        strHead = "package=\""
        strEnd = "\""
        idx = strFile.find(strHead)
        package = ""
        if idx >= 0:
            idx += len(strHead)
            strOther = strFile[idx:]
            idx = strOther.find(strEnd)
            package = strOther[0:idx]

        return package
Esempio n. 13
0
    def DeleteAllScreenshots(self, isHd):
        verison = mainAppInfo.GetAppVersion(Source.IOS, isHd)

        rootConfig = mainResource.GetProjectConfigDefault()
        str_metadata_xml = FileUtil.GetFileString(
            rootConfig + "/appstore/metadata_clear_screenshots.xml")
        str_metadata_xml = str_metadata_xml.replace(
            "_VENDOR_ID_", mainAppInfo.GetAppSKU(isHd))
        str_metadata_xml = str_metadata_xml.replace("_VERSION_", verison)

        rootConfig = mainResource.GetProjectConfigApp()
        file_metadata_ios = rootConfig + "/appstore/ios/app.itmsp/metadata.xml"
        if isHd:
            file_metadata_ios = rootConfig + "/appstore/ios/app_pad.itmsp/metadata.xml"

        FileUtil.SaveString2File(str_metadata_xml, file_metadata_ios)
        mainAppstoreUploadiOS.Run(isHd)
Esempio n. 14
0
    def LoadJsonIAP(self, isHD, stros):

        if stros == Source.ANDROID:
            jsonfile = mainResource.GetConfigDataDir(
            ) + "/IAP/IAP_android.json"
            if isHD:
                jsonfile = mainResource.GetConfigDataDir(
                ) + "/IAP/IAP_android_hd.json"

        if stros == Source.IOS:
            jsonfile = mainResource.GetConfigDataDir() + "/IAP/IAP_ios.json"
            if isHD:
                jsonfile = mainResource.GetConfigDataDir(
                ) + "/IAP/IAP_ios_hd.json"

        jsonfile = os.path.normpath(jsonfile)
        strfile = FileUtil.GetFileString(jsonfile)
        return json.loads(strfile)
Esempio n. 15
0
    def replaceXcodeUrlScheme(self,filePath, src, appid,idx):
        strFile = FileUtil.GetFileString(filePath)

        # <string>WEIXIN_APPID</string>
        if src==Source.WEIXIN or src==Source.WEIXINFRIEND:
            strOld = "<string>WEIXIN_APPID</string>"
        if src==Source.WEIBO:
            strOld = "<string>WEIBO_APPID</string>"
        if src==Source.QQ or src==Source.QQZONE:
            if idx==0:
                strOld = "<string>QQ_APPID0</string>"
            if idx==1:
                strOld = "<string>QQ_APPID1</string>"

        strNew = "<string>"+mainConfig.XcodeUrlScheme(src,appid,idx)+"</string>"  

        strOut = strFile.replace(strOld, strNew) 
        self.saveString2File(strOut,filePath)
Esempio n. 16
0
    def GetAppVersionIos(self):
        xcode_plist = self.GetRootDirXcode() + "/Info.plist"
        print("xcode_plist=" + xcode_plist)
        strFile = FileUtil.GetFileString(xcode_plist)
        # 		<key>CFBundleIdentifier</key>
        #	<string>com.moonma.pinpinle.nongchang</string>
        strHead = "CFBundleShortVersionString"
        strMid = "<string>"
        strEnd = "</string>"
        idx = strFile.find(strHead)
        package = ""
        if idx >= 0:
            idx += len(strHead)
            strOther = strFile[idx:]
            idx = strOther.find(strMid)
            if idx >= 0:
                idx += len(strMid)
                strOther = strOther[idx:]
                idx = strOther.find(strEnd)
                package = strOther[0:idx]

        return package
Esempio n. 17
0
 def replaceFile(self,filePath, strOld, strReplace): 
     strFile = FileUtil.GetFileString(filePath)
     strOut = strFile.replace(strOld, strReplace) 
     self.saveString2File(strOut, filePath)
Esempio n. 18
0
 def replacePackage(self,filePath,package):
     strFile = FileUtil.GetFileString(filePath) 
     strFile = strFile.replace("_PACKAGE_", package)
     FileUtil.SaveString2File(strFile,filePath)
Esempio n. 19
0
 def disableXmlKey(self, filePath, key):
     strFrom = "<" + key + ">" + "</" + key + ">"
     strTo = "<!-- <" + key + ">" + "</" + key + "> -->"
     strFile = FileUtil.GetFileString(filePath)
     strFile = strFile.replace(strFrom, strTo)
     self.saveString2File(strFile, filePath)
Esempio n. 20
0
    def updateName(self,isHd,isAuto):

        name = mainAppInfo.GetAppStoreAcount(isHd,Source.HUAWEI)
        mainHuaweiAppGalleryApi.ClientId = mainAppStoreAcount.GetClientId(Source.HUAWEI,name)
        mainHuaweiAppGalleryApi.ClientSecret = mainAppStoreAcount.GetClientSecret(Source.HUAWEI,name) 
        
        appinfoOld = AppInfoOld(isHd)
        if appinfoOld.IsOldVersion():
            # 转换
            self.ConvertOld2New(isHd,appinfoOld)


        rootConfig = mainResource.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 = self.loadJson(isHd) 

        
        appname = data["appname"]
 
        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"]
        self.versionCode = data["appversion"][Source.ANDROID]["code"]
        APPVERSION_IOS =  data["appversion"][Source.IOS]["value"]
        
        #appid 
        appid_ios = self.GetJsonAppId(data,Source.APPSTORE)
        appid_taptap = self.GetJsonAppId(data,Source.TAPTAP)
        appid_huawei = self.GetJsonAppId(data,Source.HUAWEI)
        self.SetConfigDataAppId(Source.IOS,Source.APPSTORE,appid_ios,isHd)
        self.SetConfigDataAppId(Source.ANDROID,Source.TAPTAP,appid_taptap,isHd)
        self.SetConfigDataAppId(Source.ANDROID,Source.HUAWEI,appid_huawei,isHd)

        csvfile = mainResource.GetConfigDataDir()+"/language/language.csv" 
        self.UpdateLanguageName(csvfile,APP_NAME_CN_ANDROID,APP_NAME_EN_ANDROID,isHd)

        csvfile = mainResource.GetRootUnityAssetsResource()+"/ConfigData/language/language.csv" 
        self.UpdateLanguageName(csvfile,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: 
            self.autoPlusVersion(isHd,data)
            # 重新加载
            data = self.loadJson(isHd)
            APPVERSION_IOS =  data["appversion"][Source.IOS]["value"]
          
            self.versionCode = data["appversion"][Source.ANDROID]["code"]

        APPVERSION_ANDROID = self.versionCodeToVersion(self.versionCode)
        APPVERSION_CODE_ANDROID = self.versionCode
        

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

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

            # 保存版本
            # android
            print("appid_huawei=",appid_huawei+" ishd=",isHd)
            # if len(appid_huawei)>1: 
            version_web = mainHuaweiAppGalleryApi.GetVersion(appid_huawei)
            strfile = strfile.replace(key,version_web) 
            FileUtil.SaveString2File(strfile,dst)
            self.SetAppVersion(isHd,Source.ANDROID,version_web)
            strcode = version_web.replace(".","")
            self.SetAppVersionCode(isHd,Source.ANDROID,strcode)
                
                
       

            # ios
            appid_apple = self.GetJsonAppId(data,Source.APPSTORE)
            version_web = mainAppVersionApple.ParseVersion(appid_apple)
            print("AppVersionApple=",version_web+" appid_apple=",appid_apple)
            self.SetAppVersion(isHd,Source.IOS,version_web)
            strcode = version_web.replace(".","")
            self.SetAppVersionCode(isHd,Source.IOS,strcode)

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


            

        # 重新加载
        data = self.loadJson(isHd)
        APPVERSION_IOS =  data["appversion"][Source.IOS]["value"] 
        self.versionCode = data["appversion"][Source.ANDROID]["code"]
        APPVERSION_ANDROID = self.versionCodeToVersion(self.versionCode)
        APPVERSION_CODE_ANDROID = self.versionCode

        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 = self.replaceStringOfFile(
            file_name_cn_android, strStart, strEnd, APP_NAME_CN_ANDROID)
        self.saveString2File(strOut, file_name_cn_android)
        # en
        strOut = self.replaceStringOfFile(
            file_name_en_android, strStart, strEnd, APP_NAME_EN_ANDROID)
        self.saveString2File(strOut, file_name_en_android)

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

        # admob
        self.replaceGoogleServiceFile(file_google_service_android, PACKAGE_ANDROID)

    # ios

        #appname
        self.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
        self.replaceFile(file_name_cn_ios,"_APP_NAME_",APP_NAME_CN_IOS) 
        # en
        self.replaceFile(file_name_en_ios,"_APP_NAME_",APP_NAME_EN_IOS)  


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

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

        #admob appid  
        appid = mainAdConfig.GetCommonAppId(Source.ADMOB,Source.IOS,isHd)
        self.replaceFile(file_info_plist_ios,"_APP_ID_ADMOB_",appid) 

        # CFBundleURLSchemes
        src = Source.WEIBO
        appid = mainConfig.GetShareAppId(src,Source.IOS,isHd)
        self.replaceXcodeUrlScheme(file_info_plist_ios,src,appid,0)

        src = Source.WEIXIN
        appid = mainConfig.GetShareAppId(src,Source.IOS,isHd)
        self.replaceXcodeUrlScheme(file_info_plist_ios,src,appid,0)

        src = Source.QQ
        appid = mainConfig.GetShareAppId(src,Source.IOS,isHd)
        self.replaceXcodeUrlScheme(file_info_plist_ios,src,appid,0)
        self.replaceXcodeUrlScheme(file_info_plist_ios,src,appid,1)

        # xiaomi aso keyword
        self.updateXiaoASOkeyword(data,isHd)



    # win
        self.updateNameWin(isHd,isAuto)
Esempio n. 21
0
 def LoadJsonConfigCommon(self):  
     jsonfile = mainResource.GetConfigDataDir()+"/config/config_common.json"  
     jsonfile = os.path.normpath(jsonfile)
     strfile = FileUtil.GetFileString(jsonfile)
     return json.loads(strfile) 
Esempio n. 22
0
 def LoadJson(self):
     strjson = FileUtil.GetFileString(self.fileJosn)
     self.dataRoot = json.loads(strjson)
Esempio n. 23
0
 def replaceFileForKey(self,filePath,key,content):
     # f = open(filePath, 'rb')
     # f = open(filePath,'r', encoding='utf-8')
     strFile = FileUtil.GetFileString(filePath) 
     strFile = strFile.replace(key, content)
     FileUtil.SaveString2File(strFile,filePath)
Esempio n. 24
0
 def replaceFile(self,filePath,key,value):
     strFile = FileUtil.GetFileString(filePath) 
     strFile = strFile.replace(key, value)
     FileUtil.SaveString2File(strFile,filePath)