原來制成tar+gzip ,還是很簡單的:
# -*- coding:utf-8 -*-
#===================================================================
#
#?? brief?? :??? 制作viruswall 的離線升級數據
#
#?? author? :??? hechangmin
#
#?? date??? :??? 2008.6
#
#?? notice? :??? 先變成tar 文件
#====================================================================
import os
import tarfile
import gzip
import string
import shutil
def zipDir(src,dst):
???
??? initPath = os.getcwd()
??? #tempDST =? os.path.join(os.getcwd(),dst)
??? #tempSRC =? os.path.join(os.getcwd(),src)
??? os.chdir( src )
??? files = os.listdir(src)
??? if dst.find("\\") != -1:
??????? temp = dst.rsplit("\\",1)
??????? dstname = temp[1]
??????? dstpath = temp[0]
??? #print files
????tar = tarfile.open(dstname,"gz")
??? for file in files:
??????? tar.add(file)
??? tar.close()
??? os.chdir( initPath )
??? if os.path.isfile(dst) == True:
??????? os.remove(dst)
??? shutil.copy(os.path.join(src,dstname), dst)
??? os.remove(os.path.join(src,dstname))
??? print os.getcwd()
#test ok
if __name__ == '__main__':
???
??? zipDir("D:\\AutoUpdate\\DataDist\\viruswall\\Data\\KSVW-VirusDB\\","d:\\AutoUpdate\\DataDist\\viruswall\\Data\\update\\KSVW-VirusDB.tgz")
???
#當然我發現里面的tar 名字不用,于是就搞一個改名的邏輯在里面,具體代碼省略。