mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-04-24 09:10:46 +02:00
tools: factor out a sanity check in libinput-replay
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
4f9a795765
commit
73849515ef
1 changed files with 12 additions and 7 deletions
|
|
@ -149,14 +149,7 @@ def wrap(func, *args):
|
|||
|
||||
|
||||
def loop(args, recording):
|
||||
version = fetch(recording, 'version')
|
||||
if version != SUPPORTED_FILE_VERSION:
|
||||
raise YamlException('Invalid file format: {}, expected {}'.format(version, SUPPORTED_FILE_VERSION))
|
||||
|
||||
ndevices = fetch(recording, 'ndevices')
|
||||
devices = fetch(recording, 'devices')
|
||||
if ndevices != len(devices):
|
||||
error('WARNING: truncated file, expected {} devices, got {}'.format(ndevices, len(devices)))
|
||||
|
||||
for idx, d in enumerate(devices):
|
||||
uinput = create(d)
|
||||
|
|
@ -182,6 +175,17 @@ def loop(args, recording):
|
|||
del processes
|
||||
|
||||
|
||||
def check_file(recording):
|
||||
version = fetch(recording, 'version')
|
||||
if version != SUPPORTED_FILE_VERSION:
|
||||
raise YamlException('Invalid file format: {}, expected {}'.format(version, SUPPORTED_FILE_VERSION))
|
||||
|
||||
ndevices = fetch(recording, 'ndevices')
|
||||
devices = fetch(recording, 'devices')
|
||||
if ndevices != len(devices):
|
||||
error('WARNING: truncated file, expected {} devices, got {}'.format(ndevices, len(devices)))
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Replay a device recording'
|
||||
|
|
@ -194,6 +198,7 @@ def main():
|
|||
try:
|
||||
with open(args.recording) as f:
|
||||
y = yaml.safe_load(f)
|
||||
check_file(recording)
|
||||
loop(args, y)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue