Created
October 21, 2011 21:05
-
-
Save eberle1080/1304965 to your computer and use it in GitHub Desktop.
Python KWallet sample usage (command line)
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
# I just wanted to find a simple way to store credentials in KWallet, and fetch it from | |
# a command line application. Here's how (assumes the credentials are already set): | |
def getCredentials(): | |
from PyKDE4.kdeui import KWallet | |
from PyQt4 import QtGui | |
from PyQt4 import QtCore | |
app = QtGui.QApplication([]) | |
wallet = KWallet.Wallet.openWallet(KWallet.Wallet.LocalWallet(), 0) | |
if not wallet.hasFolder("myapp"): | |
wallet.createFolder("myapp") | |
wallet.setFolder("myapp") | |
key, quname = wallet.readPassword('username') | |
key, qpass = wallet.readPassword('password') | |
return str(quname), str(qpass) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment