-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
for computer use #9
Conversation
this one didn't have any byte/string issues cause its all data anyhow, but did need some CPythonification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment question re print(..., flush=True)
@@ -31,7 +35,7 @@ def get_fingerprint(): | |||
def get_fingerprint_detail(): | |||
"""Get a finger print image, template it, and see if it matches! | |||
This time, print out each error instead of just returning on failure""" | |||
print("Getting image...", end="") | |||
print("Getting image...", end="", flush=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In CircuitPython 3.x, extra keyword args to print()
are ignored. In 4.0, because of a merge we did from MicroPython, they are now checked, but flush=
is not an implemented keyword arg, and fails in 4.0:
Adafruit CircuitPython 4.0.0-alpha-922-g9da79c880-dirty on 2018-08-19; Adafruit Metro M0 Express with samd21g18
>>> print("abc", "def", sep=".")
abc.def
>>> print("abc", "def", sepx=".")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: extra keyword arguments given
>>> print("abc", "def", end=".")
abc def.>>> print("abc", "def", flush=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: extra keyword arguments given
>>>
So we need to handle flush
in 4.0, otherwise this code will fail.
Not sure if any reasonable change can be made in this library. Seems like I should open an issue for 4.0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yah plz do, but i think we should default to True - basically CPython wont actually emit the output otherwise. kinda lame!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or rather, there probably isnt a way for us to False not-flush. i dunno. we can ignore it but have the kwarg there? up to y'all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tannewt have a comment here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative here is just to print each of those status messages on their own lines (remove end=""
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
always an option, but it makes for a nice UI to keep :)
CPython is pickier about unpack lenghts, and requires a flush on no-end prints