原來制成tar+gzip ,還是很簡(jiǎn)單的:

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

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

          常用鏈接

          留言簿(21)

          隨筆分類(265)

          隨筆檔案(242)

          相冊(cè)

          JAVA網(wǎng)站

          關(guān)注的Blog

          搜索

          •  

          積分與排名

          • 積分 - 916869
          • 排名 - 40

          最新評(píng)論

          主站蜘蛛池模板: 邢台市| 翁牛特旗| 花垣县| 浠水县| 光山县| 丰台区| 高唐县| 理塘县| 巧家县| 陕西省| 大理市| 石景山区| 瓦房店市| 花莲市| 黄陵县| 清远市| 宝应县| 新乐市| 金昌市| 永丰县| 清河县| 新宁县| 嘉定区| 洛南县| 昌图县| 绵竹市| 伊春市| 贡嘎县| 白山市| 永胜县| 永清县| 五莲县| 昭觉县| 张家港市| 乌恰县| 瑞金市| 富平县| 正安县| 习水县| 黑水县| 连云港市|