update-keyring.py 751 Bytes
Newer Older
1 2
#!/usr/bin/env python

3
from __future__ import print_function
4 5 6 7 8 9 10 11 12 13 14 15 16
import subprocess
import sys
import os
import itertools

# vague approximation of correct. solution: review changes to mailmap

mailmap = sys.argv[1]

os.environ['GNUPGHOME'] = os.path.relpath('.gnupg', os.path.dirname(mailmap))

key_lines = [
        l.split(b' # ')[-1] 
17
        for l in open(mailmap, 'rb')
18 19 20
        if b' # ' in l]
valid_keys = []
for line in key_lines:
21
    valid_keys.extend(map(bytes.strip, line.split(b' ')))
22 23 24

for key in valid_keys:
    print("Fetching key {}".format(key))
25 26 27 28 29
    try:
        subprocess.call(['gpg2', '--keyserver', 'pool.sks-keyservers.net', '--recv-keys', key])
    except subprocess.CalledProcessError:
        print("Failed!")
    print("Success!")