Skip to content

Commit

Permalink
Add flushing of stdout after the prints
Browse files Browse the repository at this point in the history
  • Loading branch information
bofh69 committed Mar 9, 2024
1 parent fb8665f commit 388de6f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions nfc2klipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 388de6f

Please sign in to comment.