forked from drath/libratbag
tools/toolbox.py: add dbus sync helper function
A quick and easy way to sync anything coming from dbus (like property updates) without needing to be hooked into a glib mainloop directly. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -74,6 +74,7 @@ class TestRatbagCtl(unittest.TestCase):
|
||||
error = sys.stderr.getvalue()
|
||||
sys.stdout = stdout
|
||||
sys.stderr = stderr
|
||||
toolbox.sync_dbus()
|
||||
return returncode, output.rstrip('\n'), error.rstrip('\n')
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -29,6 +29,8 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from gi.repository import GLib
|
||||
|
||||
# various constants
|
||||
RATBAGCTL_NAME = 'ratbagctl'
|
||||
RATBAGCTL_PATH = os.path.join('@MESON_BUILD_ROOT@', RATBAGCTL_NAME)
|
||||
@@ -100,6 +102,12 @@ def terminate_ratbagd(ratbagd):
|
||||
ratbagd.kill()
|
||||
os.unlink(DBUS_CONF_PATH)
|
||||
|
||||
def sync_dbus():
|
||||
main_context = GLib.MainContext.default()
|
||||
while main_context.pending():
|
||||
main_context.iteration(False)
|
||||
|
||||
|
||||
ratbagctl = import_non_standard_path(RATBAGCTL_NAME, RATBAGCTL_PATH)
|
||||
|
||||
from ratbagctl import open_ratbagd, get_parser, RatbagError, RatbagErrorCapability
|
||||
|
||||
Reference in New Issue
Block a user