Last active
August 29, 2015 14:10
-
-
Save dearing/dd2963cffd1591905e94 to your computer and use it in GitHub Desktop.
inject keys into rings
This file contains 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/python2 | |
# req : pip install keyring | |
import sys | |
import keyring | |
# ERROR if not enough arguments supplied | |
if len(sys.argv) < 4: | |
print ''' | |
Usage: {0} [realm] [username] [password] | |
to inject a username/passsword for a realm | |
'''.format(sys.argv[0]) | |
exit() | |
realm = sys.argv[1] | |
username = sys.argv[2] | |
password = sys.argv[3] | |
try: | |
keyring.set_password(realm, username, password) | |
except keyring.errors.PasswordSetError: | |
print 'failed to store credentials' | |
print 'stored credentials for {0} at {1}'.format(sys.argv[2],sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment