Skip to content
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

Merged
merged 2 commits into from
Aug 19, 2018
Merged

for computer use #9

merged 2 commits into from
Aug 19, 2018

Conversation

ladyada
Copy link
Member

@ladyada ladyada commented Aug 19, 2018

CPython is pickier about unpack lenghts, and requires a flush on no-end prints

@ladyada
Copy link
Member Author

ladyada commented Aug 19, 2018

this one didn't have any byte/string issues cause its all data anyhow, but did need some CPythonification

Copy link
Contributor

@dhalbert dhalbert left a 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)
Copy link
Contributor

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

Copy link
Member Author

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!

Copy link
Member Author

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

Copy link
Contributor

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?

Copy link
Contributor

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="").

Copy link
Member Author

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants