Created
October 6, 2012 14:27
-
-
Save inky/3845055 to your computer and use it in GitHub Desktop.
List the UDIDs in a provisioning profile. (For iOS/OS X developers.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import optparse | |
import os | |
import plistlib | |
import sys | |
PLIST_START = '<?xml' | |
PLIST_END = '</plist>' | |
def udidlist(fn): | |
fn = os.path.expanduser(fn) | |
with open(fn) as fp: | |
data = fp.read() | |
xml = data[data.find(PLIST_START) : data.find(PLIST_END) + len(PLIST_END)] | |
pl = plistlib.readPlistFromString(xml) | |
udids = pl['ProvisionedDevices'] | |
return sorted(udids) | |
def main(): | |
parser = optparse.OptionParser() | |
parser.add_option('-f', '--file', dest='filename', help='read UDID list from FILE', metavar='FILE') | |
(options, args) = parser.parse_args() | |
if options.filename: | |
try: | |
udids = udidlist(options.filename) | |
except Exception as e: | |
sys.stderr.write('Error reading UDIDs from %s\n' % options.filename) | |
return 1 | |
if udids: | |
print '\n'.join(udids) | |
else: | |
parser.print_help() | |
return 1 | |
if __name__ == '__main__': | |
sys.exit(main()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python udidlist.py -f ~/Library/MobileDevice/Provisioning\ Profiles/FILENAME.mobileprovision |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment