diff options
author | 2015-01-08 21:57:34 -0800 | |
---|---|---|
committer | 2015-01-08 22:07:44 -0800 | |
commit | 622f59e420f92062cc093b6ba540a15f03e56358 (patch) | |
tree | f4312101157daeeb8b431e3a3e953914f5ac89af | |
parent | gkeys/seed.py: Rename search() to regex_search() (diff) | |
download | gentoo-keys-622f59e420f92062cc093b6ba540a15f03e56358.tar.gz gentoo-keys-622f59e420f92062cc093b6ba540a15f03e56358.tar.bz2 gentoo-keys-622f59e420f92062cc093b6ba540a15f03e56358.zip |
gkeys/actions.py: Partially update removekey()
The removal code is completely wrong if there are multiple keys installed in one keyring.
Everything below my comments needs a complete re-do.
Disabling the remove-key action until refactored.
-rw-r--r-- | gkeys/gkeys/action_map.py | 2 | ||||
-rw-r--r-- | gkeys/gkeys/actions.py | 37 |
2 files changed, 29 insertions, 10 deletions
diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py index fc5bfb0..b9224ea 100644 --- a/gkeys/gkeys/action_map.py +++ b/gkeys/gkeys/action_map.py @@ -18,7 +18,7 @@ Seed_Actions = ['----seeds----', 'add-seed', 'fetch-seed', 'list-seed', 'list-seedfiles', 'remove-seed'] Key_Actions = ['----keys-----', 'check-key', 'installed', - 'install-key', 'list-key', 'refresh-key', 'remove-key', + 'install-key', 'list-key', 'refresh-key', 'search-key', 'spec-check'] General_Actions = ['---general---', 'list-cats', 'sign','verify'] diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 59929cd..23c71fc 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -491,21 +491,40 @@ class Actions(object): handler = SeedHandler(self.logger, self.config) kwargs = handler.build_gkeydict(args) self.logger.debug("ACTIONS: removekey; kwargs: %s" % str(kwargs)) - success, installed_keys = self.installed(args)[1] - for gkey in installed_keys: - if kwargs['nick'] not in gkey.nick: - messages = ["%s does not seem to be a valid key." % kwargs['nick']] + seeds = handler.load_category(args.category) + messages = [] + if args.nick == '*': + self.output([''],'Remove All keys in category: %s' % args.category) + ans = py_input ("Do you really want to remove ALL of keys?[y/n]: ") + while ans not in ["yes", "y", "no", "n"]: + ans = py_input ("Do you really want to remove ALL keys?[y/n]: ") + if ans in ["no", "n"]: + messages.append("Key removal aborted... Nothing to be done.") + return (True, messages) + keyresults = seeds.seeds + else: + keyresults = seeds.list(**kwargs) + self.output('', '\n Removing keys...') + success = True + print(keyresults) + for gkey in sorted(keyresults): + if kwargs['nick'] != '*' and kwargs['nick'] not in gkey.nick: + messages.append("%s does not seem to be a valid key." % kwargs['nick']) success = False else: self.output(['', [gkey]], '\n Found GKEY seed:') ans = py_input ("Do you really want to remove %s?[y/n]: " - % kwargs['nick']).lower() + % kwargs['nick'].lower()) while ans not in ["yes", "y", "no", "n"]: ans = py_input ("Do you really want to remove %s?[y/n]: " - % kwargs['nick']).lower() + % kwargs['nick'].lower()) if ans in ["no", "n"]: - messages = ["Key removal aborted... Nothing to be done."] + messages.append("Key removal aborted... Nothing to be done.") else: + ## This next code is total crap now + ## re-write it from scratch + ## there could be multiple keys installed in one keyring + ## this code just rm's everything. keyring = self.config.get_key('keyring') catdir = os.path.join(keyring, args.category) rm_candidate = os.path.join(catdir, gkey.nick) @@ -513,9 +532,9 @@ class Actions(object): if args.category: try: rmtree(rm_candidate) - messages = ["Done removing %s key." % kwargs['nick']] + messages.append("Done removing %s key." % kwargs['nick']) except OSError: - messages = ["%s directory does not exist." % rm_candidate] + messages.append("%s directory does not exist." % rm_candidate) success = False return (success, messages) |