Commit b5ab95c3 authored by Harry Cutts's avatar Harry Cutts Committed by Commit Bot

ozone: evdev: make test data capture scripts Python 3-compatible

Python 3 became the default in January, causing the scripts to error
unless explicitly run with Python 2 (which will be removed from test
images soon).

Bug: none
Test: run scripts with Python 2 then 3, and compare the output
Change-Id: I6d4aef94cb3de45f710875f04449f756d0592cec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414769
Auto-Submit: Harry Cutts <hcutts@chromium.org>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Commit-Queue: Michael Spang <spang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807552}
parent 65fda063
......@@ -17,16 +17,16 @@ TEST_DATA_GROUP_SIZE = 64 # Aligns with sysfs on 64-bit devices.
def bits_to_groups(bits):
return (bits + TEST_DATA_GROUP_SIZE - 1) / TEST_DATA_GROUP_SIZE
return (bits + TEST_DATA_GROUP_SIZE - 1) // TEST_DATA_GROUP_SIZE
# As in /sys/class/input/input*/capabilities/*
def serialize_bitfield(bitfield, max_bit):
result = ""
group_count = bits_to_groups(max_bit)
for group in xrange(group_count - 1, -1, -1):
for group in range(group_count - 1, -1, -1):
group_val = 0
for group_bit in xrange(TEST_DATA_GROUP_SIZE):
for group_bit in range(TEST_DATA_GROUP_SIZE):
code = group * TEST_DATA_GROUP_SIZE + group_bit
if code in bitfield:
group_val |= (1 << group_bit)
......
......@@ -35,7 +35,7 @@ def dump_events(out, dev):
'code': CODE_NAMES[event.code],
'value': event.value
})
except KeyboardInterrupt, e:
except KeyboardInterrupt as e:
pass
out.write('};\n')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment