Created
August 22, 2021 23:28
-
-
Save rgardner/8d88c657225c7cc662fff88e376468b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Wraps EXE to use keyring to fetch the password securely.""" | |
import os | |
import subprocess | |
import sys | |
import keyring | |
EXE = "roam-api" | |
SERVICE = "https://www.roamresearch.com" | |
USERNAME_ENV_VAR = "ROAM_API_EMAIL" | |
PASSWORD_ENV_VAR = "ROAM_API_PASSWORD" | |
username = os.environ[USERNAME_ENV_VAR] | |
password = keyring.get_password(SERVICE, username) | |
env = os.environ.copy() | |
env[PASSWORD_ENV_VAR] = password | |
subprocess.run([EXE, *sys.argv[1:]], check=True, env=env) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment