From 110c0018a25bf83bdf811dd23f6a3797696b143a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 6 Nov 2020 17:38:51 +0100 Subject: [PATCH] tests/fprintd: Make possible to call gdbus client as an async process As per this refactor the sync call we already had so that reuses the same code. --- tests/fprintd.py | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/tests/fprintd.py b/tests/fprintd.py index 4ac94f8..9d7e1aa 100644 --- a/tests/fprintd.py +++ b/tests/fprintd.py @@ -314,20 +314,27 @@ class FPrintdTest(dbusmock.DBusTestCase): con.sendall(encoded_img) + def gdbus_device_method_call_process(self, method, args=[]): + return subprocess.Popen([ + 'gdbus', + 'call', + '--system', + '--dest', + self.device.get_name(), + '--object-path', + self.device.get_object_path(), + '--method', + '{}.{}'.format(self.device.get_interface_name(), method), + ] + args, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) + def call_device_method_from_other_client(self, method, args=[]): try: - return subprocess.check_output([ - 'gdbus', - 'call', - '--system', - '--dest', - self.device.get_name(), - '--object-path', - self.device.get_object_path(), - '--method', - '{}.{}'.format(self.device.get_interface_name(), method), - ] + args, stderr=subprocess.STDOUT, timeout=5) - except subprocess.CalledProcessError as e: + proc = self.gdbus_device_method_call_process(method, args) + proc.wait(timeout=5) + if proc.returncode != 0: + raise GLib.GError(proc.stdout.read()) + return proc.stdout.read() + except subprocess.TimeoutExpired as e: raise GLib.GError(e.output)