commit: 33aa21ef6e619c7776a4984370c7f01a15c0ec87 Author: aeroniero33 <justthisthing <AT> gmail <DOT> com> AuthorDate: Tue Jun 14 20:24:08 2016 +0000 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> CommitDate: Sat Dec 24 04:54:15 2016 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=33aa21ef
gkeys actions: Add keys updated reporting Report the updated/revoked keys during the update. <rebase edit> Replace print() with self.output() Whitespace cleanup Create a meaningful commit message </edit Brian Dolbec> gkeys/gkeys/actions.py | 18 +++++++++++++++++- gkeys/gkeys/seedhandler.py | 23 +++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 3d0399a..77d39b1 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -115,7 +115,9 @@ class Actions(ActionBase): category_msgs.extend(messages) return (True, category_msgs) self.output('', "Fetching seeds for %s category.\n" %args.category) + success, old_gkeys = self.listseed(args) fetch_success, fetch_messages = self.fetchseed(args) + self.seeds = None if fetch_success is not True: success = False messages = fetch_messages @@ -129,7 +131,21 @@ class Actions(ActionBase): success = False else: self.output('', "Update succeeded.\n") - messages = fetch_messages + ["Update operation:"] + [install_messages] + messages = fetch_messages + [" Update operation:"] + [install_messages] + success, new_gkeys = self.listseed(args) + added_gkeys, changed_gkeys = self.seedhandler.compare_seeds(old_gkeys, new_gkeys) + self.output('', "Updated revoked GKeys:") + if changed_gkeys: + for gkey in changed_gkeys: + self.output(['', changed_gkeys]) + else: + self.output('', "No GKeys were revoked") + self.output('', "Added GKeys:") + if added_gkeys: + for gkey in added_gkeys: + self.output(['', added_gkeys]) + else: + self.output('', "No GKeys were added") return (success, messages) def addseed(self, args): diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py index de2a6ad..c7dad2e 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -71,6 +71,29 @@ class SeedHandler(object): keyinfo[attr] = None return keyinfo + def compare_seeds(self, seeds1, seeds2) : + '''Compares two seed lists and returns the differences + + @param seeds1: set of seeds to be compared + @param seeds2: set of seeds to be compared + @return added_gkeys: list of keys that are included in seed2 but not seed1 + @return changed_gkeys: list of keys that are included in seed1 and seed2 but have been altered + ''' + old_gkeys = seeds1[1] + new_gkeys = seeds2[1] + changed_gkeys = [] + added_gkeys = [] + if old_gkeys: + for new_gkey in new_gkeys: + for old_gkey in old_gkeys: + if new_gkey.nick == old_gkey.nick and new_gkey != old_gkey: + changed_gkeys.append(new_gkey) + if new_gkey not in old_gkeys and new_gkey not in changed_gkeys: + added_gkeys.append(new_gkey) + else: + added_gkeys = new_gkeys + return(added_gkeys, changed_gkeys) + def load_seeds(self, seedfile=None, filepath=None, refresh=False): '''Load seed file