38
42
script_proxy.SetPath(script_dir)
39
43
script_proxy.Run("sms.js")
40
44
shutil.rmtree(script_dir)
48
bus = dbus.SystemBus()
50
manager = dbus.Interface(bus.get_object('org.ofono', '/'),
52
except dbus.exceptions.DBusException:
55
modems = manager.GetModems()
57
for path, properties in modems:
58
if path == '/phonesim':
64
def is_phonesim_running():
65
"""Determine whether we are running with phonesim."""
66
phonesim = get_phonesim()
67
return phonesim is not None
70
def ensure_ofono_account():
71
# oFono modems are now set online by NetworkManager, so for the tests
72
# we need to manually put them online.
73
subprocess.check_call(['/usr/share/ofono/scripts/enable-modem',
75
subprocess.check_call(['/usr/share/ofono/scripts/online-modem',
78
# wait until the modem is actually online
79
for index in range(10):
80
phonesim = get_phonesim()
81
if phonesim['Online'] == 1:
85
raise exceptions.RuntimeError("oFono simulator didn't get online.")
87
# this is a bit drastic, but sometimes mission-control-5 won't recognize
88
# clients installed after it was started, so, we make sure it gets
90
subprocess.check_call(['pkill', '-9', 'mission-control'])
92
if not _is_ofono_account_set():
93
subprocess.check_call(['ofono-setup'])
94
if not _is_ofono_account_set():
95
sys.stderr.write('ofono-setup failed to create ofono account!\n')
99
def _is_ofono_account_set():
100
mc_tool = subprocess.Popen(
104
], stdout=subprocess.PIPE, universal_newlines=True)
105
mc_accounts = mc_tool.communicate()[0]
106
return 'ofono/ofono/account' in mc_accounts