Created
October 28, 2014 07:09
-
-
Save ziggear/d1dd5470185427c9c7ec to your computer and use it in GitHub Desktop.
Revisions
-
ziggear created this gist
Oct 28, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ import os, re, commands temp_file_name = "temp.txt" command = "xcrun simctl list > %s" % temp_file_name os.popen(command) ios_list = {} cur_ios = None regex_block = re.compile(r"-- (iOS [5-8].[0-9]) --") regex_inner = re.compile(r"(.*?)([0-9A-Za-z]*)\((.*?)\) \((.*?)\)") temp_file = open(temp_file_name) user_root = commands.getoutput("echo ~") simulator_root = "%s/iPhone Simulators" % (user_root) cmd = "mkdir \"%s\"" % (simulator_root) os.popen(cmd) if temp_file : while 1: line = temp_file.readline() if not line: break res = regex_block.findall(line) if (len(res)) : cur_ios = res[0] if ios_list.get(cur_ios) == None : ios_list[cur_ios] = [] cmd = "mkdir '%s/%s'" % (simulator_root, cur_ios) os.popen(cmd) else : res = regex_inner.findall(line) if (len(res)) and cur_ios != None : device_name = res[0][0].strip() device_id = res[0][2] device_path = "%s/Library/Developer/CoreSimulator/Devices/%s/" % (user_root, device_id) cmd = "ln -s \"%s\" \"%s/%s/%s\" " % (device_path, simulator_root, cur_ios, device_name) os.popen(cmd) temp_file.close() os.popen("rm temp.txt")