posts - 134,  comments - 244,  trackbacks - 0

原来制成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 阅读(114) 评论(0)  编辑  收藏 所属分类: python

标题  
姓名  
主页
验证码 *  
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
 
 
相关链接:
网站导航:
<2008年6月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

常用链接

留言簿(11)

随笔分类(139)

随笔档案(134)

JAVA网站

关注的Blog

最新随笔

搜索

  •  

积分与排名

  • 积分 - 85666
  • 排名 - 94

最新评论

阅读排行榜

评论排行榜