Skip to content

Instantly share code, notes, and snippets.

@eberle1080
Created October 21, 2011 21:05
Show Gist options
  • Save eberle1080/1304965 to your computer and use it in GitHub Desktop.
Save eberle1080/1304965 to your computer and use it in GitHub Desktop.
Python KWallet sample usage (command line)
# 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