[Pgp-tools-commit] r650 - trunk/keyart
Guilhem Moulin
guilhem-guest at moszumanska.debian.org
Wed Jun 18 13:39:19 UTC 2014
Author: guilhem-guest
Date: 2014-06-18 13:39:19 +0000 (Wed, 18 Jun 2014)
New Revision: 650
Modified:
trunk/keyart/keyart
Log:
keyart: refactoring
1. Make only one call to gpg, regardless of the number of key IDs
provided.
2. Use 'gpg --with-colons --fingerprint --no-default-keyring --keyring=/path/to/keyring [--keyring=/path/to/keyring2 ...]'
contruction, which is immune to GnuPG bug #1640.
Modified: trunk/keyart/keyart
===================================================================
--- trunk/keyart/keyart 2014-06-18 13:39:14 UTC (rev 649)
+++ trunk/keyart/keyart 2014-06-18 13:39:19 UTC (rev 650)
@@ -18,31 +18,6 @@
help='A publicly exported GPG key or keyring.')
ARGS = PARSER.parse_args()
-def fix_gpg(gpg_bin, keyid, keyfile):
- """Temporary work around for GnuPG bug #1640.
- See https://bugs.g10code.com/gnupg/issue1640."""
- with open(os.devnull, 'wb') as devnull:
- cmd = (gpg_bin, '--quiet', '--yes', '--output', '/tmp/.0x%s.gpg' % keyid,
- '--no-default-keyring', '--keyring=%s' % keyfile, '--export', '--',
- keyid)
- gpg = subprocess.Popen(cmd, stdout=devnull)
- gpg.communicate()
-
- cmd = (gpg_bin, '--quiet', '--import', '/tmp/.0x%s.gpg' % keyid)
- gpg = subprocess.Popen(cmd, stdout=devnull)
- gpg.communicate()
-
- os.remove('/tmp/.0x%s.gpg' % keyid)
-
- cmd = (gpg_bin, '--fingerprint', '--with-colons', keyid)
- gpg = subprocess.Popen(cmd, stdout=subprocess.PIPE)
- cmd = ('grep', '^fpr')
- grep = subprocess.Popen(cmd, stdin=gpg.stdout, stdout=subprocess.PIPE)
- out = grep.communicate()[0]
- fpr = out.split(':')[9]
-
- return fpr
-
def test_env():
"""Test if and where GPG is installed."""
try:
@@ -259,38 +234,22 @@
if __name__ == '__main__':
gpg_bin = test_env()
- if ARGS.id:
- for key in ARGS.id:
- cmd = (gpg_bin, '--fingerprint', '--with-colons', '--', key)
- gpg = subprocess.Popen(cmd, stdout=subprocess.PIPE)
- for lines in gpg.communicate()[0].split('\n'):
- colons = lines.split(':')
- if colons[0] == 'pub':
- size = colons[2]
- algo = colons[3]
- elif colons[0] == 'fpr':
- print draw_art(size, algo, colons[9])
- size = None
- algo = None
-
-
+ cmd = [ gpg_bin, '--with-colons', '--fingerprint' ]
if ARGS.file:
- for key in ARGS.file:
- cmd = (gpg_bin, '--with-fingerprint', '--with-colons', '--', key)
- gpg = subprocess.Popen(cmd, stdout=subprocess.PIPE)
- cmd = ('grep', '-E', '^(pub|fpr)')
- grep = subprocess.Popen(cmd, stdin=gpg.stdout,
- stdout=subprocess.PIPE)
- out = grep.communicate()[0].split('\n')
+ cmd.append('--no-default-keyring')
+ cmd.extend([ '--keyring=%s' % keyring for keyring in ARGS.file ])
- for i in xrange(len(out)):
- if out[i].split(':')[0] == 'pub':
- size = out[i].split(':')[2]
- algo = out[i].split(':')[3]
- if out[i+1].split(':')[0] == 'fpr':
- fpr = out[i+1].split(':')[9]
- else:
- keyid = out[i].split(':')[4]
- fpr = fix_gpg(gpg_bin, keyid, os.path.abspath(key))
+ if ARGS.id:
+ cmd.append('--')
+ cmd.extend(ARGS.id)
- print draw_art(size, algo, fpr)
+ gpg = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ for lines in gpg.communicate()[0].split('\n'):
+ colons = lines.split(':')
+ if colons[0] == 'pub':
+ size = colons[2]
+ algo = colons[3]
+ elif colons[0] == 'fpr':
+ print draw_art(size, algo, colons[9])
+ size = None
+ algo = None
More information about the Pgp-tools-commit
mailing list