cielavenir

applink (lesser) on PC

Mar 31st, 2012
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.19 KB | None | 0 0
  1. #!/usr/bin/python
  2. #applink (lesser)
  3.  
  4. #scp [email protected]:/var/mobile/Library/Caches/com.apple.mobile.installation.plist ./
  5. #plutil -i com.apple.mobile.installation.plist | applink.py xml.plist > applink.sh
  6. #scp applink.sh [email protected]:~/
  7. #sh applink.sh
  8.  
  9. PATH="/var/mobile/applink"
  10. applist={}
  11.  
  12. import sys,os,plistlib,codecs
  13.  
  14. # Gets the info from the MobileInstallation cache.
  15. def find_apps():
  16.  #if not os.path.exists(plist):
  17.  # sys.stderr.write("MobileInstallation cache not found. Fallback not available on PC.\n")
  18.   #find_apps_old()
  19.  # return
  20.  try:
  21.   mobileInstallationCache = plistlib.readPlist(sys.stdin)
  22.  except:
  23.   sys.stderr.write("Reading the MobileInstallation cache failed. Fallback not available on PC.\n")
  24.   #find_apps_old()
  25.   return
  26.  if "User" not in mobileInstallationCache:
  27.   sys.stderr.write("MobileInstallation cache doesn't have a User key. Fallback not available on PC.\n")
  28.   #find_apps_old()
  29.   return
  30.  appStoreApps = mobileInstallationCache["User"]
  31.  sys.stderr.write("Here are the app bundles I found:\n")
  32.  for key in appStoreApps:
  33.   i = appStoreApps[key]
  34.   path = "/".join(i["Path"].rstrip("/").split("/")[:-1])
  35.   if "CFBundleDisplayName" in i and i["CFBundleDisplayName"] != "": #os.path.exists(path)
  36.    #dotApp = i["Path"].rstrip("/").split("/")[-1]
  37.    #dotAppFull = path + "/" + dotApp
  38.    if path.startswith("/private"):
  39.     path = path.split("/private", 1)[1]
  40.    guid = path.split("/")[-1]
  41.    sys.stderr.write(guid+"\n")
  42.    if i["CFBundleDisplayName"] in applist:
  43.     sys.stderr.write("Duplicate name\n")
  44.     #sys.stdout.write("rm \""+i["CFBundleDisplayName"]+"_"+guid+"\"\n")
  45.     sys.stdout.write("ln -s \""+path+"\" \""+i["CFBundleDisplayName"]+"_"+guid+"\"\n")
  46.    else:
  47.     applist[i["CFBundleDisplayName"]]=guid
  48.     #sys.stdout.write("rm \""+i["CFBundleDisplayName"]+"\"\n")
  49.     sys.stdout.write("ln -s \""+path+"\" \""+i["CFBundleDisplayName"]+"\"\n")
  50.  
  51. #main
  52. sys.stdout = codecs.getwriter('utf_8')(sys.stdout)
  53. sys.stdout.write("#!/bin/sh\n")
  54. #sys.stdout.write("export LC_ALL=en_US.UTF-8\n")
  55. sys.stdout.write("rm -rf \""+PATH+"\"\n")
  56. sys.stdout.write("mkdir \""+PATH+"\"\n")
  57. sys.stdout.write("cd \""+PATH+"\"\n")
  58. find_apps()
Advertisement
Add Comment
Please, Sign In to add comment