Guest User

Untitled

a guest
Jun 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. import platform, os, sqlite3
  2.  
  3. """
  4. Note: Compatible with Python 2.5+, on Darwin 9.7 (OSX 10.5+), Windows XP, Windows Vista, Server 2008, and 7.
  5. """
  6.  
  7. def sqliteClean(sqliteFile):
  8. print("Optimizing " + os.path.basename(sqliteFile) + "...")
  9. conn = sqlite3.connect(sqliteFile)
  10. cursor = conn.cursor()
  11. cursor.execute("vacuum")
  12. cursor.close()
  13.  
  14. def cleanFolder(profilesPath):
  15. for profileFolder in os.listdir(profilesPath):
  16. if os.path.isdir(os.path.join(profilesPath, profileFolder)):
  17. for dirItem in os.listdir(os.path.join(profilesPath, profileFolder)):
  18. if os.path.isfile(os.path.join(profilesPath, profileFolder, dirItem)) and os.path.splitext(dirItem)[1] == ".sqlite":
  19. sqliteClean(os.path.join(profilesPath, profileFolder, dirItem))
  20.  
  21. if platform.system() == "Windows":
  22. ffProfile = "Mozilla\Firefox\Profiles"
  23. if platform.release() == "XP":
  24. cleanFolder(os.path.join(os.environ['APPDATA'], ffProfile))
  25. cleanFolder(os.path.join(os.environ['USERPROFILE'], "Local Settings\Application Data", ffProfile))
  26. if platform.release() == "Vista" or platform.release() == "post2008server":
  27. cleanFolder(os.path.join(os.environ['APPDATA'], ffProfile))
  28. cleanFolder(os.path.join(os.environ['LOCALAPPDATA'], ffProfile))
  29. elif platform.system() == "Darwin":
  30. ffProfile = "Library/Application Support/Firefox/Profiles"
  31. cleanFolder(os.path.join(os.environ['HOME'], ffProfile))
Add Comment
Please, Sign In to add comment