From 9880b1ebc1892e0559c816aa21d06dd9e5087624 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Wed, 19 Oct 2011 05:55:36 +0200 Subject: [PATCH] client-barcode: Turn off console echo (experiment for now, idea by Andy Gunschl) --- client-barcode/freitagskasse.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/client-barcode/freitagskasse.py b/client-barcode/freitagskasse.py index d3e377d..01e2de7 100644 --- a/client-barcode/freitagskasse.py +++ b/client-barcode/freitagskasse.py @@ -19,6 +19,8 @@ import os import time import urllib2 import select +import termios +import atexit from display import Display from thread import start_new_thread, allocate_lock @@ -458,8 +460,25 @@ def read_line(f, timeout, timeout_func): return '' +def enable_echo(fd, enabled): + (iflag, oflag, cflag, lflag, ispeed, ospeed, cc) = termios.tcgetattr(fd) + if enabled: + lflag |= termios.ECHO + else: + lflag &= ~termios.ECHO + new_attr = [iflag, oflag, cflag, lflag, ispeed, ospeed, cc] + termios.tcsetattr(fd, termios.TCSANOW, new_attr) + + def main(): + debugging = bool(os.environ.get('BARCODE_PLUGIN_DEBUG', False)) + colorama.init() + + if not debugging: + atexit.register(enable_echo, sys.stdin.fileno(), True) + enable_echo(sys.stdin.fileno(), False) + status = Status() global scroll_line1,scroll_line2 global myDisplay @@ -474,7 +493,8 @@ def main(): while True: clear() status.dump() - print_prompt() + if debugging: + print_prompt() line = read_line(sys.stdin, timeout=3*60.0, timeout_func=status.logout) if line: myDisplay.write('\x0cRFID/Barcode:\n%20s' % line[:20])