Tizen 2.1 base
[external/libzypp-bindings.git] / examples / python / keyring.py
1 #!/usr/bin/python
2
3 # test loading of pywsman
4 import sys
5
6 # cmake build dir
7 sys.path.insert(0, '../../build/swig/python')
8
9 from zypp import ZYppFactory, Pathname, KeyRing, PublicKey
10
11
12 keyring = ZYppFactory.instance().getZYpp().keyRing()
13
14 path = Pathname("/suse/aschnell/tmp/repodata/repomd.xml.key")
15 print path
16
17 publickey = PublicKey(path)
18 print publickey
19
20 id = publickey.id()
21
22 print "is key known/trusted %s %s" % (keyring.isKeyKnown(id), keyring.isKeyTrusted(id))
23
24 keyring.importKey(publickey, True)
25
26 print "is key known/trusted %s %s" % (keyring.isKeyKnown(id), keyring.isKeyTrusted(id))
27
28 print "list of known keys:"
29 for key in keyring.publicKeys():
30     print key
31
32 print "list of trusted keys:"
33 for key in keyring.trustedPublicKeys():
34     print key
35