diff options
| author | Lukas Waymann <lukas.waymann@canonical.com> | 2020-11-16 15:30:16 +0800 |
|---|---|---|
| committer | Lukas Waymann <lukas.waymann@canonical.com> | 2020-11-25 18:19:56 +0800 |
| commit | 58d8ce0e09242fdc8a79dead627a45ddd265e64f (patch) | |
| tree | d99865e6f82d8e5777de1cd1b9486dad0ae20d7d | |
| parent | 22dda6a1fa8d68d0466b5cfc87b96e0c5ed36180 (diff) | |
Just use tty0 for camera/roundtrip-qrcode_* tests
tty0 always points to the current virtual console, so we don't need any code for detecting which virtual console (tty1, tty2, ...) is selected.
| -rwxr-xr-x | bin/roundtrip_qr.py | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/bin/roundtrip_qr.py b/bin/roundtrip_qr.py index c3494e2..3c1b98a 100755 --- a/bin/roundtrip_qr.py +++ b/bin/roundtrip_qr.py @@ -61,14 +61,8 @@ def generate_qr_code(data): return pyqrcode.create(data) -def get_active_tty(): - with open('/sys/class/tty/tty0/active', 'r') as active_f: - return active_f.read().strip() - - -def display_code(qr, tty): - device = '/dev/{}'.format(tty) - with open(device, 'wb+', buffering=0) as term: +def display_code(qr): + with open('/dev/tty0', 'wb+', buffering=0) as term: # clear the tty so the qr is always printed at the top of the sceen term.write(str.encode('\033c')) # print the qr code @@ -104,15 +98,8 @@ def main(): print('Generating QR code...', flush=True) qr = generate_qr_code(test_str) - tty = 'tty1' - try: - tty = get_active_tty() - print('Identified {} as the active vt'.format(tty)) - except IOError: - print('Failed to read active tty, using default {}'.format(tty)) - print('Displaying on screen', flush=True) - display_code(qr, tty) + display_code(qr) print('Capture image of screen', flush=True) if name == 'vchiq': |
