|
125
by siretart
new script to fetch keys from launchpad |
1 |
#!/usr/bin/env python
|
2 |
||
3 |
import RDF |
|
4 |
import os, os.path, sys |
|
5 |
import shutil |
|
6 |
||
7 |
#some variables set that somewhere else
|
|
8 |
||
9 |
class RevuKeyUpdater: |
|
10 |
"""Retrieves Fingerprints from a launchpad group by parsing the group rdf
|
|
11 |
stores corresponding keys in a new gpg keyring
|
|
12 |
"""
|
|
|
127.2.2
by revu1
fix paths to new location |
13 |
def __init__(self, lpgroup = 'ubuntu-universe-contributors', revubase = '/srv/revu1-production'): |
|
125
by siretart
new script to fetch keys from launchpad |
14 |
" initializes this class"
|
15 |
self.lpgroup = lpgroup |
|
16 |
self.keyserver = 'keyserver.ubuntu.com' |
|
17 |
self.keyring = "%s/launchpad.gpg" % revubase |
|
18 |
self.gpgopts = "--no-options --no-default-keyring " |
|
19 |
self.gpgopts += "--secret-keyring %s/secring.gpg" % revubase |
|
20 |
self.gpgopts += " --trustdb-name %s/trustdb.gpg" % revubase |
|
21 |
self.gpgopts += " --keyring %s" % self.keyring |
|
22 |
self.gpgopts += " --keyserver keyserver.ubuntu.com" |
|
23 |
self.fingerprints = [] |
|
24 |
||
25 |
def get_fingerprints(self): |
|
26 |
"parses fingerprints from the rdf"
|
|
27 |
model = RDF.Model() |
|
28 |
model.load('https://launchpad.net/people/%s/+rdf' % self.lpgroup) |
|
29 |
q = RDF.Query("SELECT ?fingerprint WHERE (?any, <http://xmlns.com/wot/0.1/fingerprint>, ?fingerprint )") |
|
30 |
||
31 |
results = q.execute(model) |
|
32 |
for statement in results: |
|
33 |
self.fingerprints.append(statement['fingerprint'].literal_value['string']) |
|
34 |
||
35 |
def do_update(self): |
|
36 |
"handles calling gpg for all found fingerprints"
|
|
37 |
self.get_fingerprints() |
|
38 |
||
39 |
for fingerprint in self.fingerprints: |
|
40 |
# get the keyid from the fingerprint
|
|
41 |
key = fingerprint[-8:] |
|
42 |
os.system("gpg %s --recv-key %s" % (self.gpgopts, key)) |
|
43 |
||
44 |
||
45 |
if __name__ == '__main__': |
|
|
127.2.2
by revu1
fix paths to new location |
46 |
updater = RevuKeyUpdater(revubase='/srv/revu1-production') |
|
125
by siretart
new script to fetch keys from launchpad |
47 |
updater.do_update() |