|
@@ -31,13 +31,15 @@ keyFile = 'zooKeys.json'
|
|
|
|
|
|
|
|
|
|
|
|
-def replaceJarNameInFile(full_path, new_text, old_text):
|
|
|
+def replaceJarNameInFile(full_path, new_text, old_text, tag):
|
|
|
with open(full_path, "r") as fileObj:
|
|
|
all_text = fileObj.read()
|
|
|
fileObj.close()
|
|
|
if old_text:
|
|
|
- all_text = all_text.replace(old_text, new_text)
|
|
|
- print ("\t替换: %s -> %s" % (old_text, new_text))
|
|
|
+ oldjar = "%s_%s.jar" % (tag, old_text)
|
|
|
+ newjar = "%s_%s.jar" % (tag, new_text)
|
|
|
+ all_text = all_text.replace(oldjar, newjar)
|
|
|
+ print ("\t替换: %s -> %s" % (oldjar, newjar))
|
|
|
with open(full_path, "w") as fileObj:
|
|
|
fileObj.write(all_text)
|
|
|
fileObj.close()
|
|
@@ -54,6 +56,66 @@ def getoldJarDate(full_path):
|
|
|
old_text = (re.findall(r'jm_sdk_([^.jar]+)', all_text)[0])
|
|
|
return old_text
|
|
|
|
|
|
+def getoldNopayJarDate(full_path):
|
|
|
+ with open(full_path, "r") as fileObj:
|
|
|
+ all_text = fileObj.read()
|
|
|
+ fileObj.close()
|
|
|
+ # 提取jar包日期
|
|
|
+ if all_text.find("jm_sdk_nopay") > -1:
|
|
|
+ old_text = (re.findall(r'jm_sdk_nopay_([^.jar]+)', all_text)[0])
|
|
|
+ return old_text
|
|
|
+ return ""
|
|
|
+
|
|
|
+def replaceNopayJar():
|
|
|
+ global sdkpath
|
|
|
+ global currentSdkpath
|
|
|
+ print ('start replace jar ...')
|
|
|
+ print (sdkpath)
|
|
|
+ jarName = ''
|
|
|
+ for parent, folders, files in os.walk(currentSdkpath):
|
|
|
+ for file in files:
|
|
|
+ if file.find(".jar") > -1 and file.find("nopay") > -1:
|
|
|
+ jarName = file
|
|
|
+ print('jarName -->'+ jarName)
|
|
|
+ fullJarPath = os.path.join(currentSdkpath,jarName)
|
|
|
+ newDate = (re.findall(r'jm_sdk_nopay_([^.jar]+)', jarName)[0])
|
|
|
+
|
|
|
+ #修改config字段 及替换Jar包
|
|
|
+ list = os.listdir(sdkpath)
|
|
|
+ for l in list:
|
|
|
+ if l in ignore_sdk:
|
|
|
+ continue
|
|
|
+ full_l_path = os.path.join(sdkpath,l)
|
|
|
+ full_lib_path = os.path.join(full_l_path,'libs')
|
|
|
+ if os.path.isdir(full_l_path):
|
|
|
+ configPath = os.path.join(full_l_path,'libs/config.json')
|
|
|
+ configPath = os.path.normcase(configPath)
|
|
|
+ if os.path.exists(configPath):
|
|
|
+ print(configPath)
|
|
|
+ oldDate = getoldNopayJarDate(configPath)
|
|
|
+ if oldDate == "":
|
|
|
+ continue
|
|
|
+ # 修改config字段
|
|
|
+ replaceJarNameInFile(configPath,newDate,oldDate,"jm_sdk_nopay")
|
|
|
+ oldJarPath = '%s/jm_sdk_nopay_%s.jar' % (full_lib_path,oldDate)
|
|
|
+ #删除旧文件
|
|
|
+ if os.path.exists(oldJarPath):
|
|
|
+ print ('delete ---> %s' % oldJarPath)
|
|
|
+ try:
|
|
|
+ os.remove(os.path.normcase(oldJarPath))
|
|
|
+ except Exception as e:
|
|
|
+ print (e)
|
|
|
+ else:
|
|
|
+ print("File is deleted successfully")
|
|
|
+ newJarPath = '%s/jm_sdk_nopay_%s.jar' % (full_lib_path,newDate)
|
|
|
+ print('复制: %s ---> %s' % (fullJarPath,newJarPath))
|
|
|
+ shutil.copyfile(fullJarPath, newJarPath) # 复制文件
|
|
|
+
|
|
|
+ print('-------------------------')
|
|
|
+
|
|
|
+ print ("\nfinished replace jar")
|
|
|
+
|
|
|
+
|
|
|
|
|
|
######修改config字段 及替换Jar包
|
|
|
def replaceJar():
|
|
@@ -64,7 +126,7 @@ def replaceJar():
|
|
|
jarName = ''
|
|
|
for parent, folders, files in os.walk(currentSdkpath):
|
|
|
for file in files:
|
|
|
- if file.find(".jar") > -1:
|
|
|
+ if file.find(".jar") > -1 and file.find("nopay") < 1:
|
|
|
jarName = file
|
|
|
print('jarName -->'+ jarName)
|
|
|
fullJarPath = os.path.join(currentSdkpath,jarName)
|
|
@@ -84,7 +146,7 @@ def replaceJar():
|
|
|
print(configPath)
|
|
|
oldDate = getoldJarDate(configPath)
|
|
|
# 修改config字段
|
|
|
- replaceJarNameInFile(configPath,newDate,oldDate)
|
|
|
+ replaceJarNameInFile(configPath,newDate,oldDate,"jm_sdk")
|
|
|
oldJarPath = '%s/jm_sdk_%s.jar' % (full_lib_path,oldDate)
|
|
|
#删除旧文件
|
|
|
if os.path.exists(oldJarPath):
|
|
@@ -149,7 +211,8 @@ def replaceRes():
|
|
|
print ("\nfinished replace res")
|
|
|
|
|
|
def main():
|
|
|
- replaceJar()
|
|
|
+ #replaceJar()
|
|
|
+ replaceNopayJar()
|
|
|
#####修改了资源文件,要替换#####
|
|
|
#replaceRes()
|
|
|
|