Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_client_and_authenticate(ctx):
"""Create a client and authenticate."""
host = ctx.config['server_url']
port = ctx.config['port']
api_path = ctx.config['api_path']
api_key = ctx.config['api_key']
info(f"Connecting to server at '{host}:{port}{api_path}'")
username = q.text("Username:").ask()
password = q.password("Password:").ask()
client = Client(host, port, api_path)
try:
client.authenticate(username, password)
except Exception as e:
error("Could not authenticate with server!")
debug(e)
exit(1)
return client
def ask_pystyle(**kwargs):
# create the question object
question = questionary.password(
"Enter your git password", style=custom_style_dope, **kwargs
)
# prompt the user for an answer
return question.ask()
import questionary
from examples import custom_style_dope
if __name__ == "__main__":
questionary.text("What's your first name").ask()
questionary.password("What's your secret?").ask()
questionary.confirm("Are you amazed?").ask()
questionary.select(
"What do you want to do?",
choices=["Order a pizza", "Make a reservation", "Ask for opening hours"],
).ask()
questionary.rawselect(
"What do you want to do?",
choices=["Order a pizza", "Make a reservation", "Ask for opening hours"],
).ask()
questionary.checkbox(
"Select toppings", choices=["foo", "bar", "bazz"], style=custom_style_dope
).ask()
("qmark", "fg:#e91e63 bold"),
("answer", "fg:#fac731"),
("instruction", "fg:#f06292"),
("separator", "fg:#cc5454"),
("selected", "fg:#7fc97f"),
("pointer", "fg:#fdc086"),
("question", "fg:#d3d7cF"),
]
)
github_username = questionary.text("GitHub Username:", style=style).ask()
PASS_SAVED = is_pass_saved(github_username)
if not PASS_SAVED:
github_password = (
questionary.password("GitHub Password:", style=style)
.skip_if(PASS_SAVED, default=False)
.ask()
)
else:
github_password = retrieve_pass(github_username)
password_save = (
questionary.select(
"Do you want to save your password?", choices=["Yes", "No"], style=style
)
.skip_if(PASS_SAVED, default=False)
.ask()
)
repo_name = questionary.text("Repository Name:", style=style).ask()
repo_type = questionary.select(