1 |
commit: c2e01ecee2f14ca8a4419433e43a50f5f7489376 |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Dec 31 02:50:20 2014 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jan 1 02:39:51 2015 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=c2e01ece |
7 |
|
8 |
gkeys-gen: Add spec option |
9 |
|
10 |
Action config changes |
11 |
|
12 |
--- |
13 |
gkeys-gen/gkeygen/actions.py | 13 ++++++++----- |
14 |
gkeys/gkeys/base.py | 5 +++++ |
15 |
2 files changed, 13 insertions(+), 5 deletions(-) |
16 |
|
17 |
diff --git a/gkeys-gen/gkeygen/actions.py b/gkeys-gen/gkeygen/actions.py |
18 |
index b3aecb9..e329397 100644 |
19 |
--- a/gkeys-gen/gkeygen/actions.py |
20 |
+++ b/gkeys-gen/gkeygen/actions.py |
21 |
@@ -30,7 +30,7 @@ from gkeys.fileops import ensure_dirs |
22 |
Available_Actions = ["gen-key"] |
23 |
|
24 |
Action_Options = { |
25 |
- 'gen-key': ['dest'], |
26 |
+ 'gen-key': ['dest', 'spec'], |
27 |
} |
28 |
|
29 |
Action_Map = { |
30 |
@@ -77,7 +77,9 @@ class Actions(object): |
31 |
return (False, messages) |
32 |
self.logger.debug("MAIN: _action_genkey; setting gpghome destination: %s" % gpghome) |
33 |
self.logger.debug("MAIN: _action_genkey; args= %s" % str(args)) |
34 |
- key_params = self.get_input() |
35 |
+ if not args.spec: |
36 |
+ args.spec = self.config.get_key('spec', 'default-spec') |
37 |
+ key_params = self.get_input(args) |
38 |
ack = None |
39 |
while ack not in ["y", "yes", "n", "no"]: |
40 |
ack = py_input("Continue?[y/n]: ").lower() |
41 |
@@ -96,7 +98,7 @@ class Actions(object): |
42 |
newgpgconfpath = os.path.join(gpghome, 'gpg.conf') |
43 |
shutil.copy('/usr/share/gnupg/gpg-conf.skel', newgpgconfpath) |
44 |
with open(newgpgconfpath, 'a') as conf: |
45 |
- for line in urlopen(self.config.defaults['gpg.conf-url']): |
46 |
+ for line in urlopen(self.config.get_key('gpg-urls', args.spec)): |
47 |
conf.write(_unicode(line)) |
48 |
# Key generation |
49 |
ctx = gpgme.Context() |
50 |
@@ -125,7 +127,7 @@ class Actions(object): |
51 |
return (True, messages) |
52 |
|
53 |
|
54 |
- def get_input(self): |
55 |
+ def get_input(self, args): |
56 |
'''Interactive user input''' |
57 |
self.output(["\nGPG key creator based on GLEP 63\n" |
58 |
"(https://wiki.gentoo.org/wiki/GLEP:63)\n"]) |
59 |
@@ -135,6 +137,7 @@ class Actions(object): |
60 |
self.output(["\nBad email input. Try again."]) |
61 |
email = py_input("Give your Email: ") |
62 |
print("\nReview:\n Full Name: %s\n Email: %s\n" % (name, email)) |
63 |
- key_properties = urlopen(self.config.defaults['key-spec-url']).read() |
64 |
+ url = self.config.get_key('spec-urls', args.spec) |
65 |
+ key_properties = urlopen(url).read() |
66 |
return _unicode(key_properties).format(name, email) |
67 |
|
68 |
|
69 |
diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py |
70 |
index 6e53f87..5c9505d 100644 |
71 |
--- a/gkeys/gkeys/base.py |
72 |
+++ b/gkeys/gkeys/base.py |
73 |
@@ -174,6 +174,11 @@ class CliBase(object): |
74 |
help='The path/URL to use for the signature') |
75 |
|
76 |
@staticmethod |
77 |
+ def _option_spec(parser=None): |
78 |
+ parser.add_argument('-S', '--spec', dest='spec', default=None, |
79 |
+ help='The spec file to use from the gkeys-gen.conf file') |
80 |
+ |
81 |
+ @staticmethod |
82 |
def _option_timestamp(parser=None): |
83 |
parser.add_argument('-t', '--timestamp', dest='timestamp', |
84 |
action='store_true', default=False, |