modem: Do not connect to the systembus until a modem is in use

In case of the "virtual" tests we:

* Don't use ofono based modems (they are physical for now).
* Run in an environment that doesn't naturally run a dbus-daemon

Modify the code to memoize the bus by hand.

Change-Id: Ieae4bf819903402f7f715eb489e0a96ed59dc3f8
This commit is contained in:
Holger Hans Peter Freyther 2019-02-20 08:57:46 +00:00 committed by Harald Welte
parent c1d705f28e
commit ae0dae821c
1 changed files with 3 additions and 1 deletions

View File

@ -29,7 +29,7 @@ from gi.module import get_introspection_module
Gio = get_introspection_module('Gio')
from gi.repository import GLib
bus = SystemBus()
bus = None
I_MODEM = 'org.ofono.Modem'
I_NETREG = 'org.ofono.NetworkRegistration'
@ -66,6 +66,8 @@ def dbus_connect(dbus_iface, handler):
def systembus_get(path):
global bus
if not bus:
bus = SystemBus()
return bus.get('org.ofono', path)
def list_modems():