[Freeipa-devel] [PATCH 0139] otptoken-add: improve the robustness of QR code printing to tty

Martin Babinsky mbabinsk at redhat.com
Tue Mar 8 16:45:52 UTC 2016


On 03/08/2016 05:35 PM, Jan Cholasta wrote:
> Hi,
>
> On 8.3.2016 16:21, Martin Babinsky wrote:
>> https://fedorahosted.org/freeipa/ticket/5700
>
> 1) Instead of checking for utf-8 in particular, I would prefer a more
> robust approach:
>
> try:
>      qr = qrcode.QRCode()
>      qr.add_data('test')
>      qr.make()
>      qr.print_ascii(tty=True)
> except UnicodeError:
>      # it is not printable
> else:
>      # it is printable
>
Now you mean the check in the _check_qrcode_capability() or the 
_print_qrcode() method itself?
>
> 2) There is no os.isatty() check to see if stdout is actually a tty.
>
This check is performed inside both print_ascii() and print_tty() 
methods of QRCode object, but you probably mean that I should put the 
check also into _check_qrcode_capability() method, right?
>
> Honza
>


-- 
Martin^3 Babinsky




More information about the Freeipa-devel mailing list