aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/run_ios_simulator.py
diff options
context:
space:
mode:
authormonster <monster@ydb.tech>2022-07-07 14:41:37 +0300
committermonster <monster@ydb.tech>2022-07-07 14:41:37 +0300
commit06e5c21a835c0e923506c4ff27929f34e00761c2 (patch)
tree75efcbc6854ef9bd476eb8bf00cc5c900da436a2 /build/scripts/run_ios_simulator.py
parent03f024c4412e3aa613bb543cf1660176320ba8f4 (diff)
downloadydb-06e5c21a835c0e923506c4ff27929f34e00761c2.tar.gz
fix ya.make
Diffstat (limited to 'build/scripts/run_ios_simulator.py')
-rw-r--r--build/scripts/run_ios_simulator.py79
1 files changed, 0 insertions, 79 deletions
diff --git a/build/scripts/run_ios_simulator.py b/build/scripts/run_ios_simulator.py
deleted file mode 100644
index 052c855b77..0000000000
--- a/build/scripts/run_ios_simulator.py
+++ /dev/null
@@ -1,79 +0,0 @@
-import argparse
-import json
-import os
-import subprocess
-import sys
-
-
-def just_do_it():
- parser = argparse.ArgumentParser()
- parser.add_argument("--action", choices=["create", "spawn", "kill"])
- parser.add_argument("--simctl", help="simctl binary path")
- parser.add_argument("--profiles", help="profiles path")
- parser.add_argument("--device-dir", help="devices directory")
- parser.add_argument("--device-name", help="temp device name")
- args, tail = parser.parse_known_args()
- if args.action == 'create':
- action_create(args.simctl, args.profiles, args.device_dir, args.device_name, tail)
- elif args.action == "spawn":
- action_spawn(args.simctl, args.profiles, args.device_dir, args.device_name, tail)
- elif args.action == "kill":
- action_kill(args.simctl, args.profiles, args.device_dir, args.device_name)
-
-
-def action_create(simctl, profiles, device_dir, name, args):
- parser = argparse.ArgumentParser()
- parser.add_argument("--device-type", default="com.apple.CoreSimulator.SimDeviceType.iPhone-X")
- parser.add_argument("--device-runtime", default="com.apple.CoreSimulator.SimRuntime.iOS-12-1")
- args = parser.parse_args(args)
- all_devices = list(get_all_devices(simctl, profiles, device_dir))
- if filter(lambda x: x["name"] == name, all_devices):
- raise Exception("Device named {} already exists".format(name))
- subprocess.check_call([simctl, "--profiles", profiles, "--set", device_dir, "create", name, args.device_type, args.device_runtime])
- created = filter(lambda x: x["name"] == name, get_all_devices(simctl, profiles, device_dir))
- if not created:
- raise Exception("Creation error: temp device named {} not found".format(name))
- created = created[0]
- if created["availability"] != "(available)":
- raise Exception("Creation error: temp device {} status is {} ((available) expected)".format(name, created["availability"]))
-
-
-def action_spawn(simctl, profiles, device_dir, name, args):
- device = filter(lambda x: x["name"] == name, get_all_devices(simctl, profiles, device_dir))
- if not device:
- raise Exception("Can't spawn process: device named {} not found".format(name))
- if len(device) > 1:
- raise Exception("Can't spawn process: too many devices named {} found".format(name))
- device = device[0]
- os.execv(simctl, [simctl, "--profiles", profiles, "--set", device_dir, "spawn", device["udid"]] + args)
-
-
-def action_kill(simctl, profiles, device_dir, name):
- device = filter(lambda x: x["name"] == name, get_all_devices(simctl, profiles, device_dir))
- if not device:
- print >> sys.stderr, "Device named {} not found; do nothing".format(name)
- return
- if len(device) > 1:
- raise Exception("Can't remove: too many devices named {}:\n{}".format(name, '\n'.join(i for i in device)))
- device = device[0]
- os.execv(simctl, [simctl, "--profiles", profiles, "--set", device_dir, "delete", device["udid"]])
-
-
-def get_all_devices(simctl, profiles, device_dir):
- p = subprocess.Popen([simctl, "--profiles", profiles, "--set", device_dir, "list", "--json", "devices"], stdout=subprocess.PIPE)
- out, _ = p.communicate()
- rc = p.wait()
- if rc:
- raise Exception("Devices list command return code is {}\nstdout:\n{}".format(rc, out))
- raw_object = json.loads(out)
- if "devices" not in raw_object:
- raise Exception("Devices not found in\n{}".format(json.dumps(raw_object)))
- raw_object = raw_object["devices"]
- for os_name, devices in raw_object.items():
- for device in devices:
- device["os_name"] = os_name
- yield device
-
-
-if __name__ == '__main__':
- just_do_it()