From cc143d5fec7a14f9ac0ccd55d066884867070c89 Mon Sep 17 00:00:00 2001 From: Kaifeng Date: Wed, 5 Dec 2018 21:06:45 +0800 Subject: [PATCH] kasli_tester: add support for windows platform. (#1204) --- .../kasli_basic/repository/kasli_tester.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/artiq/examples/kasli_basic/repository/kasli_tester.py b/artiq/examples/kasli_basic/repository/kasli_tester.py index b47a1e0c6..8cc708d53 100644 --- a/artiq/examples/kasli_basic/repository/kasli_tester.py +++ b/artiq/examples/kasli_basic/repository/kasli_tester.py @@ -1,8 +1,12 @@ import sys +import os import select from artiq.experiment import * +if os.name == "nt": + import msvcrt + def chunker(seq, size): res = [] @@ -16,11 +20,17 @@ def chunker(seq, size): def is_enter_pressed() -> TBool: - if select.select([sys.stdin,], [], [], 0.0)[0]: - sys.stdin.read(1) - return True + if os.name == "nt": + if msvcrt.kbhit() and msvcrt.getch() == b"\r": + return True + else: + return False else: - return False + if select.select([sys.stdin, ], [], [], 0.0)[0]: + sys.stdin.read(1) + return True + else: + return False class KasliTester(EnvExperiment):