From e3af6d53e46d0a8d8797b83731a805a3b05c1bb3 Mon Sep 17 00:00:00 2001 From: Martin Date: Sat, 20 Jan 2024 22:35:53 +0100 Subject: [PATCH] Set username, password and server forom env props --- token_extractor.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/token_extractor.py b/token_extractor.py index d9f51ac..f416a27 100644 --- a/token_extractor.py +++ b/token_extractor.py @@ -251,12 +251,18 @@ def print_entry(key, value, tab): def main(): servers = ["cn", "de", "us", "ru", "tw", "sg", "in", "i2"] servers_str = ", ".join(servers) - print("Username (email or user ID):") - username = input() - print("Password:") - password = getpass("") - print(f"Server (one of: {servers_str}) Leave empty to check all available:") - server = input() + username = os.getenv('XIAOMI_USERNAME') + if username is None: + print("Username (email or user ID):") + username = input() + password = os.getenv('XIAOMI_PASSWORD') + if password is None: + print("Password:") + password = getpass("") + server = os.getenv('XIAOMI_SERVER') + if server is None: + print(f"Server (one of: {servers_str}) Leave empty to check all available:") + server = input() while server not in ["", *servers]: print(f"Invalid server provided. Valid values: {servers_str}") print("Server:")