diff options
author | Brian Dolbec <dolsen@gentoo.org> | 2014-12-30 18:50:20 -0800 |
---|---|---|
committer | Brian Dolbec <dolsen@gentoo.org> | 2014-12-31 18:39:51 -0800 |
commit | c2e01ecee2f14ca8a4419433e43a50f5f7489376 (patch) | |
tree | 5088d8f3f801c11aae6b55817fb02840d157b0d4 /gkeys-gen/gkeygen | |
parent | gkeys-gen: Initial migration to use gkeys.base.CliBase class (diff) | |
download | gentoo-keys-c2e01ecee2f14ca8a4419433e43a50f5f7489376.tar.gz gentoo-keys-c2e01ecee2f14ca8a4419433e43a50f5f7489376.tar.bz2 gentoo-keys-c2e01ecee2f14ca8a4419433e43a50f5f7489376.zip |
gkeys-gen: Add spec option
Action config changes
Diffstat (limited to 'gkeys-gen/gkeygen')
-rw-r--r-- | gkeys-gen/gkeygen/actions.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/gkeys-gen/gkeygen/actions.py b/gkeys-gen/gkeygen/actions.py index b3aecb9..e329397 100644 --- a/gkeys-gen/gkeygen/actions.py +++ b/gkeys-gen/gkeygen/actions.py @@ -30,7 +30,7 @@ from gkeys.fileops import ensure_dirs Available_Actions = ["gen-key"] Action_Options = { - 'gen-key': ['dest'], + 'gen-key': ['dest', 'spec'], } Action_Map = { @@ -77,7 +77,9 @@ class Actions(object): return (False, messages) self.logger.debug("MAIN: _action_genkey; setting gpghome destination: %s" % gpghome) self.logger.debug("MAIN: _action_genkey; args= %s" % str(args)) - key_params = self.get_input() + if not args.spec: + args.spec = self.config.get_key('spec', 'default-spec') + key_params = self.get_input(args) ack = None while ack not in ["y", "yes", "n", "no"]: ack = py_input("Continue?[y/n]: ").lower() @@ -96,7 +98,7 @@ class Actions(object): newgpgconfpath = os.path.join(gpghome, 'gpg.conf') shutil.copy('/usr/share/gnupg/gpg-conf.skel', newgpgconfpath) with open(newgpgconfpath, 'a') as conf: - for line in urlopen(self.config.defaults['gpg.conf-url']): + for line in urlopen(self.config.get_key('gpg-urls', args.spec)): conf.write(_unicode(line)) # Key generation ctx = gpgme.Context() @@ -125,7 +127,7 @@ class Actions(object): return (True, messages) - def get_input(self): + def get_input(self, args): '''Interactive user input''' self.output(["\nGPG key creator based on GLEP 63\n" "(https://wiki.gentoo.org/wiki/GLEP:63)\n"]) @@ -135,6 +137,7 @@ class Actions(object): self.output(["\nBad email input. Try again."]) email = py_input("Give your Email: ") print("\nReview:\n Full Name: %s\n Email: %s\n" % (name, email)) - key_properties = urlopen(self.config.defaults['key-spec-url']).read() + url = self.config.get_key('spec-urls', args.spec) + key_properties = urlopen(url).read() return _unicode(key_properties).format(name, email) |