SHARE
TWEET

restore.py

a guest Mar 24th, 2011 663 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2. import os
  3. import hashlib
  4. import cPickle
  5. import zipfile
  6. dir_backup="Directory"
  7. os.system("7za x delta.7z")
  8. os.system("7za -y x delta.zip")
  9. os.remove("delta.7z")
  10. os.remove("delta.zip")
  11. remove=open("remove.txt","r")
  12. for line in remove:
  13.   line=line.rstrip('\n')
  14.   os.remove(line)
  15. remove.close()
  16. os.remove("remove.txt")
  17. dict={}
  18. checksum=open(os.path.join(dir_backup,"..","chksm.txt"),'w')
  19.  
  20. for (path,dirs,files) in os.walk(dir_backup):
  21.   if ((dirs == [] ) & (files == [])):
  22.     os.rmdir(path)
  23.  
  24. for (path,dirs,files) in os.walk(dir_backup):
  25.   for filename in files:
  26.     f_temp=open(os.path.join(path,filename),'r')
  27.     content=f_temp.read()
  28.     m=hashlib.md5()
  29.     m.update(content)
  30.     dict[os.path.join(path,filename)]=m.hexdigest()
  31.     f_temp.close()
  32. cPickle.dump(dict,checksum)
RAW Paste Data
Top