From 388de6f1d9172ee99bb3653ec68477efd2e23318 Mon Sep 17 00:00:00 2001 From: Sebastian Andersson Date: Sat, 9 Mar 2024 20:23:57 +0100 Subject: [PATCH] Add flushing of stdout after the prints --- nfc2klipper.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nfc2klipper.py b/nfc2klipper.py index f559cab..794edef 100755 --- a/nfc2klipper.py +++ b/nfc2klipper.py @@ -56,10 +56,10 @@ def set_spool_and_filament(url: str, spool: int, filament: int): set_spool_and_filament.old_spool == spool and set_spool_and_filament.old_filament == filament ): - print("Read same spool & filament") + print("Read same spool & filament", flush=True) return - print(f"Sending spool #{spool}, filament #{filament} to klipper") + print(f"Sending spool #{spool}, filament #{filament} to klipper", flush=True) commands = { "commands": [ @@ -125,7 +125,7 @@ def get_data_from_ndef_records(records): if line[0] == FILAMENT: filament = line[1] else: - print(f"Read other record: {record}") + print(f"Read other record: {record}", flush=True) return spool, filament @@ -134,14 +134,14 @@ def on_nfc_connect(tag): """Handles a read tag""" if tag.ndef is None: - print("The tag doesn't have NDEF records") + print("The tag doesn't have NDEF records", flush=True) return True spool, filament = get_data_from_ndef_records(tag.ndef.records) if not args.clear: if not (spool and filament): - print("Did not find spool and filament records in tag") + print("Did not find spool and filament records in tag", flush=True) if args.clear or (spool and filament): if not spool: spool = 0