原來制成tar+gzip ,還是很簡單的:

          # -*- coding:utf-8 -*-
          #===================================================================
          #
          #?? brief?? :??? 制作viruswall 的離線升級數(shù)據(jù)
          #
          #?? 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")
          ???
          #當然我發(fā)現(xiàn)里面的tar 名字不用,于是就搞一個改名的邏輯在里面,具體代碼省略。

          posted on 2008-06-26 15:06 -274°C 閱讀(644) 評論(0)  編輯  收藏 所屬分類: python

          常用鏈接

          留言簿(21)

          隨筆分類(265)

          隨筆檔案(242)

          相冊

          JAVA網(wǎng)站

          關注的Blog

          搜索

          •  

          積分與排名

          • 積分 - 916096
          • 排名 - 40

          最新評論

          主站蜘蛛池模板: 泽州县| 南通市| 保德县| 渭南市| 盐城市| 湄潭县| 望江县| 麻栗坡县| 江津市| 陇川县| 德令哈市| 黄山市| 高青县| 寻乌县| 杂多县| 镇赉县| 五大连池市| 郧西县| 保康县| 阿拉善左旗| 夏邑县| 宿松县| 和平区| 元阳县| 屏山县| 射阳县| 景谷| 雅江县| 大田县| 桓仁| 临武县| 永丰县| 贵阳市| 牙克石市| 麟游县| 法库县| 和龙市| 桃园市| 定远县| 青浦区| 辉县市|