forked from liuchuancong/pure_live
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pure_live_rename.py
59 lines (52 loc) · 2.05 KB
/
pure_live_rename.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import os
import shutil
import time
source_dir_name = 'E:/project/pure_live_release/'
target_files = ['app-arm64-v8a-release.apk','app-armeabi-v7a-release.apk','app-release.apk','pure_live.msix']
build_path = []
buildcellctions = []
target_win_app_name = 'E:/project/pure_live/build/windows/x64/runner/Release/'
target_apk_dir_name = 'E:/project/pure_live/build/app/outputs/flutter-apk/'
# target_win_app_name = 'D:/flutter/pure_live/build/windows/x64/runner/Release/'
# target_apk_dir_name = 'D:/flutter/pure_live/build/app/outputs/flutter-apk/'
files = []
dirArr = ['安卓_手机高版本.apk','安卓_手机低版本.apk','安卓_手机All.apk','win10以上系统下载.msix']
def traversal_dirs(path):
for item in os.scandir(path):
if item.is_dir():
shutil.rmtree(item.path)
else:
os.remove(item.path)
def traversal_files(path):
for item in os.scandir(path):
if item.is_file():
fileName = item.path.split('/')[-1].split('\\')[-1]
if fileName in target_files:
buildcellctions.append(item.path)
def traversal_target_files(path,version):
if (len(buildcellctions)!=len(dirArr)):
print('请全部打包')
return
for i in range(0,len(dirArr)):
src = os.path.join(path,version + '-' +dirArr[i])
source = buildcellctions[i]
shutil.copy(source, src)
def zip_dirs(path):
for file in os.listdir(path):
file_path = os.path.join(path, file)
if os.path.isdir(file_path):
shutil.make_archive(file_path, 'zip', file_path)
def main():
version = str(input("请输入你想发布的版本:"))
# 先改名字12
traversal_dirs(source_dir_name)
# 复制文件
traversal_files(target_apk_dir_name)
traversal_files(target_win_app_name)
traversal_target_files(source_dir_name,version)
# print(buildcellctions)
# 压缩为zip
# zip_dirs(source_dir_name)
# 12
if __name__ == '__main__':
main()