mirror of
https://gitlab.freedesktop.org/libfprint/fprintd.git
synced 2026-05-09 02:28:19 +02:00
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.
This commit is contained in:
parent
5611317c72
commit
110c0018a2
1 changed files with 19 additions and 12 deletions
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue