Skip to content

Instantly share code, notes, and snippets.

@Halicea
Created October 2, 2013 19:25
Show Gist options
  • Select an option

  • Save Halicea/6799164 to your computer and use it in GitHub Desktop.

Select an option

Save Halicea/6799164 to your computer and use it in GitHub Desktop.
python_install_ios_provisioning_profile
import os
import sys
import codecs
from subprocess import call
import shutil
from os.path import expanduser
profiles_dir = expanduser("~/Library/MobileDevice/Provisioning Profiles")
import argparse
def get_id(path):
f = open(path, 'r')
t = f.read()
ind = t.index('<key>UUID</key>\n')+len('<key>UUID</key>\n')
l = t.index('<string>', ind)+len('<string>')
r = t.index('</string>', ind)
return t[l:r]
def install_profile(path):
id = get_id(path)
shutil.copy(path, os.path.join(profiles_dir, '%s.mobileprovision'%id))
def uninstall_profile(path):
id = get_id(path)
os.remove(os.path.join(profiles_dir, '%s.mobileprovision'%id))
if __name__=='__main__':
parser = argparse.ArgumentParser(prog="iOS Provisioning Profiles Utility")
parser.add_argument('f')
parser.add_argument('--install')
parser.add_argument('--uninstall')
args = parser.parse_args(sys.argv[1:])
if args.install:
install_profile(args.f)
elif args.uninstall:
uninstall_profile(args.f)
#install_profile(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment