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

prompt password issue #1112

Closed
1 task done
dmtzs opened this issue Jan 6, 2025 · 1 comment
Closed
1 task done

prompt password issue #1112

dmtzs opened this issue Jan 6, 2025 · 1 comment

Comments

@dmtzs
Copy link

dmtzs commented Jan 6, 2025

Privileged issue

  • I'm @tiangolo or he asked me directly to create an issue here.

Issue Content

I have a code snippet like the next:

import qrcode
from app import app
from typer import Option
from typing_extensions import Annotated

@app.command()
def wifiqr(
    password: Annotated[
        str, Option(prompt=True, confirmation_prompt=True, hide_input=True, help="The password of the network.")
    ],
    ssid: str = Option(..., help="The SSID of the network."),
    encryption: str = Option("WPA", help="The encryption type of the network."),
    hidden: bool = Option(False, help="Whether the network is hidden."),
    ascii: bool = Option(False, help="Print the QR code as ASCII in terminal, otherwise an image will be saved."),
) -> None:
    """
    Generate a QR code for a WiFi network.

    The QR code will contain the SSID, password, encryption, and hidden status.

    Args:
        - ssid (str): The SSID of the network.
        - password (str): The password of the network.
        - encryption (str): The encryption type of the network.
        - hidden (bool): Whether the network is hidden.
    """
    wifi_data = f"WIFI:S:{ssid};T:{encryption};P:{password};H:{int(hidden)};;"
    qr = qrcode.QRCode()
    qr.add_data(wifi_data)
    qr.make()
    if ascii:
        qr.print_ascii(invert=True)
    else:
        qr.make_image(fill_color="black", back_color="white").save("wifi.png")

But it pops up the next error:
image

@dmtzs
Copy link
Author

dmtzs commented Jan 6, 2025

NA

@dmtzs dmtzs closed this as completed Jan 6, 2025
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

No branches or pull requests

1 participant