主要功能
- 将指定C#输出文件夹中的指定文件输出打包
- 使用字典,可以支持多个项目
- 输出打包格式为*.zip,并自动加上时间戳
- 调用IE自动弹出窗体并选中打包后的zip文件(360会拦截)
用法
$ python TMake.py key version
# Author: Hao, Wei (郝伟老师)
# Author's Webpage: https://blog.csdn.net/weixin_43145361
# Please keep the head part when coping.
# Date: 2018/12/25
# Version: 1.2
#!/usr/bin/python
# coding=gbk to support Chinese just in case
import os, sys, time, shutil, zipfile
# usage
# python TMake.py T1709 1.0.1
# Three arguments:TMake.py, transducer name and version
if len(sys.argv) != 3:
exit(0)
# input directory and files to be copied
indirs = {
'T1709':R"Z:\QTransducer\2017年\2017_09_Antai_Zeiss\QTransducer\QDasTransfer\bin\Debug"
}
filelists ={
"T1709": ["QDasTransducer.exe", "WindGoes.dll"]
}
# tranducer name, version and output zip filename.
tname = sys.argv[1]
version = sys.argv[2]
outfile = "T20" + tname[1:] + "_" + version + time.strftime("_%Y%m%d%H%M%S", time.localtime()) + ".zip";
# input and output directories.
indir = indirs[tname] + "\\"
outdir = indir + "..\\..\\..\\..\\Released\\"
# create outdir if not existed.
if not os.path.exists(outdir):
os.mkdir(outdir)
# to-be-copied files
zipf = zipfile.ZipFile(outdir + outfile, 'w')
for file in filelists[tname]:
zipf.write(indir + file, "T20" + tname[1:] + "_" + version + "\\" + file)
zipf.close
# view in Explorer (I hate 360).
os.system("explorer /e, /select, " + outdir + outfile)