-
Notifications
You must be signed in to change notification settings - Fork 1
/
uninstall_app.py
39 lines (31 loc) · 878 Bytes
/
uninstall_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python
import os.path
import sys
from subprocess import check_output, call
from simctl import SimControl
device_id = sys.argv[1]
app_id = sys.argv[2]
simctl = SimControl()
devices = simctl.deviceLookupHash()
device = devices[device_id]
shouldRun = not device.isBooted()
canUninstall = True
# only boot sim if it's not already
if shouldRun:
print 'Booting device'
result = simctl.bootDevice(device)
if not result:
print "Failed to boot simulator: %s" % (device_id)
canUninstall = False
# uninstall app
if canUninstall:
result = simctl.uninstallApp(device, app_id)
if result != True:
print "Failed to uninstall app: %s" % (app_id)
else:
print 'Successfully uninstalled %s' % (app_id)
# shutdown if we had to boot it
if shouldRun:
result = simctl.shutdownDevice(device)
if result != True:
print "Failed to shutdown simulator: %s" % (device_id)