update test, stream for multibutton

master
Bel LaPointe 2022-04-11 07:52:29 -06:00
parent e2f0e2d046
commit 342dcf4bc9
2 changed files with 15 additions and 17 deletions

View File

@ -4,24 +4,23 @@ from time import sleep
def main(): def main():
args = get_args() args = get_args()
buckets = {}
with open(args.p, "r") as f: with open(args.p, "r") as f:
f.seek(0, os.SEEK_END) f.seek(0, os.SEEK_END)
while True: while True:
line = f.readline() line = f.readline().strip()
key = line.strip("/")
if not line: if not line:
sleep(0.1) sleep(0.25)
continue continue
if line[0] == "T": if not key in buckets:
for char in args.b: buckets[key] = False
print(char) buckets[key] = line[0] != "/"
else: print(sorted([int(i) for i in buckets if buckets[i]]))
print("")
def get_args(): def get_args():
ap = argparse.ArgumentParser() ap = argparse.ArgumentParser()
ap.add_argument("-p", type=str, help="path to write out to", default="/tmp/cbappend.both.txt") ap.add_argument("-p", type=str, help="path to write out to", default="/tmp/cbappend.both.txt")
ap.add_argument("-b", type=str, help="keys to send while on", default="a")
return ap.parse_args() return ap.parse_args()
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -9,13 +9,12 @@ cleanup() {
trap cleanup EXIT trap cleanup EXIT
python3 ./state_to_buttons.py & python3 ./state_to_buttons.py &
python3 testdata/rand_0_13_stream.py \
( | (
while echo $((RANDOM%2)); do while read -r line; do
if [ 0 == $((RANDOM%4)) ]; then #echo $line >&2
sleep 3 echo $line
fi
date >&2
done done
) | python3 ./stream_to_state.py ) \
| python3 ./stream_to_state.py