Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import contextlib
- import subprocess
- import tempfile
- @contextlib.contextmanager
- def authfile(username, password):
- auth = dict(username=username, password=password)
- with tempfile.TemporaryDirectory() as tempdir:
- auth_file = os.path.join(tempdir, 'auth.json')
- with open(auth_file, 'w') as fd:
- json.dump(auth, fd)
- yield auth_file
- def main():
- username = "foo"
- password = "bar"
- auth_file = authfile(username, password)
- subprocess.check_call(['prog', '--autfile', auth_file])
Add Comment
Please, Sign In to add comment