Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-keys:master commit in: gkeys-gen/gkeygen/
Date: Thu, 01 Jan 2015 17:45:00
Message-Id: 1420079992.198f91d769e9573f63cfcb3379c009957658f961.dolsen@gentoo
1 commit: 198f91d769e9573f63cfcb3379c009957658f961
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Wed Dec 31 06:40:26 2014 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Thu Jan 1 02:39:52 2015 +0000
6 URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=198f91d7
7
8 gkeygen/actions.py: Py 3 fixes
9
10 Both downloads in py3 are byte strings. Need to decode them.
11 Change the "No password given" messages.
12 Add a logger.eror message with the GpgmeError received.
13
14 ---
15 gkeys-gen/gkeygen/actions.py | 11 ++++++-----
16 1 file changed, 6 insertions(+), 5 deletions(-)
17
18 diff --git a/gkeys-gen/gkeygen/actions.py b/gkeys-gen/gkeygen/actions.py
19 index e329397..8ddf624 100644
20 --- a/gkeys-gen/gkeygen/actions.py
21 +++ b/gkeys-gen/gkeygen/actions.py
22 @@ -99,7 +99,7 @@ class Actions(object):
23 shutil.copy('/usr/share/gnupg/gpg-conf.skel', newgpgconfpath)
24 with open(newgpgconfpath, 'a') as conf:
25 for line in urlopen(self.config.get_key('gpg-urls', args.spec)):
26 - conf.write(_unicode(line))
27 + conf.write(_unicode(line.decode('utf-8')))
28 # Key generation
29 ctx = gpgme.Context()
30 self.logger.info("MAIN: _action_genkey: Generating GPG key...")
31 @@ -109,9 +109,10 @@ class Actions(object):
32 " This helps the random number generator work effectively"])
33 try:
34 result = ctx.genkey(key_params)
35 - except gpgme.GpgmeError:
36 - self.logger.debug("MAIN: _action_genkey: Aborting... No given password.")
37 - messages.extend(['', "Aborting... No given password."])
38 + except gpgme.GpgmeError as e:
39 + self.logger.error("MAIN: _action_genkey: GpgmeError: %s" % str(e))
40 + self.logger.debug("MAIN: _action_genkey: Aborting... Failed to get a password.")
41 + messages.extend(['', "Aborting... Failed to get a password."])
42 return (False, messages)
43 key = ctx.get_key(result.fpr, True)
44 self.logger.debug("MAIN: _action_genkey: Generated key: %s - %s"
45 @@ -139,5 +140,5 @@ class Actions(object):
46 print("\nReview:\n Full Name: %s\n Email: %s\n" % (name, email))
47 url = self.config.get_key('spec-urls', args.spec)
48 key_properties = urlopen(url).read()
49 - return _unicode(key_properties).format(name, email)
50 + return _unicode(key_properties.decode('utf-8')).format(name, email)