Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #
  2. # Tool to extract atp files from the asset server cache.
  3. # Usage: python2 atp-extract.py -[lxa] [filename]
  4. #
  5. # cd into the c:\Users\BettySpaghetti\AppData\Roaming\High Fidelity\assignment-client\assets dir
  6. # run 'python2 atp-extract.py -l' to list all files
  7. # run 'python2 atp-extract.py -x file' to extract that particular file to the current directory.
  8. # run 'python2 atp-extract.py -a' to extract all files.
  9. #
  10.  
  11. import os, json, sys, shutil
  12.  
  13. def loadMapFile(filename):
  14. with open(filename, 'r') as f:
  15. return json.load(f)
  16.  
  17. def extractFile(assetMap, filename):
  18. if filename != None:
  19. assetFilename = assetMap.get("/" + filename)
  20. if assetFilename != None:
  21. dir = os.path.dirname(filename)
  22. if dir != "" and not os.path.exists(dir):
  23. os.makedirs(dir)
  24. shutil.copy("files/" + assetFilename, filename)
  25. return True
  26. return False
  27.  
  28. option = sys.argv[1]
  29. if option == '-l':
  30. assetMap = loadMapFile("map.json")
  31. for key, value in assetMap.iteritems():
  32. print key[1:]
  33. elif option == '-x':
  34. assetMap = loadMapFile("map.json")
  35. outputFilename = sys.argv[2]
  36. if not extractFile(assetMap, outputFilename):
  37. print("Error could not extract file: \"" + outputFilename + "\"")
  38. elif option == '-a':
  39. assetMap = loadMapFile("map.json")
  40. for key, value in assetMap.iteritems():
  41. print("Extracting " + key[1:])
  42. extractFile(assetMap, key[1:])
  43. else:
  44. print("unsuported option \"" + option + "\"")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement