原來制成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 閱讀(641) 評論(0)  編輯  收藏 所屬分類: python

          常用鏈接

          留言簿(21)

          隨筆分類(265)

          隨筆檔案(242)

          相冊

          JAVA網站

          關注的Blog

          搜索

          •  

          積分與排名

          • 積分 - 914107
          • 排名 - 40

          最新評論

          主站蜘蛛池模板: 巴楚县| 望城县| 华池县| 三河市| 钟山县| 南澳县| 辽中县| 正宁县| 抚顺市| 德昌县| 新津县| 萍乡市| 司法| 三门峡市| 紫云| 甘南县| 武夷山市| 博乐市| 波密县| 青龙| 平罗县| 榕江县| 巴南区| 武平县| 平阳县| 镶黄旗| 马公市| 日照市| 榆社县| 兴和县| 尉氏县| 邯郸市| 桂平市| 武乡县| 柘城县| 甘肃省| 浮山县| 永城市| 都兰县| 阳曲县| 运城市|