Commit a42be7c4 authored by bongo0594's avatar bongo0594
Browse files

Load credentials into/from keyring

parent fdabcca5
......@@ -10,7 +10,8 @@ setup(name='tubtools',
import keyring
import keyring.errors
import logging
import getpass
def fallback(username):
log = logging.getLogger(__name__)
pw = getpass.getpass('Password:')
keyring.set_password('system', username, pw)
except keyring.errors.KeyringError:
log.error('Could not save credentials in the keyring!')
return pw
def load_credentials(username):
log = logging.getLogger(__name__)
pw = None
pw = keyring.get_password('system', username)
except keyring.errors.KeyringError:
log.error('Could not get credentials from keyring!')
if pw is None:
pw = fallback(username)
return pw
import getpass
import os
import argparse
from .login import login
from .extract import extract_all_submissions
from .credentials import load_credentials
import bs4
......@@ -65,7 +65,7 @@ def main():
args.user = input('Username:')
if not args.password:
args.password = getpass.getpass('Password:')
args.password = load_credentials(args.user)
s = login(args.user, args.password, ISIS_URL, ISIS_SHIB_URL)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment