原来制成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 名字不用,于是就搞一个改名的逻辑在里面,具体代码省略。

posted on 2008-06-26 15:06 -274°C 阅读(627) 评论(0)  编辑  收藏 所属分类: python

只有注册用户登录后才能发表评论。


网站导航:
 

常用链接

留言簿(21)

随笔分类(265)

随笔档案(242)

相册

JAVA网站

关注的Blog

搜索

  •  

积分与排名

  • 积分 - 909109
  • 排名 - 40

最新评论