diff options
author | 2016-06-14 20:24:08 +0000 | |
---|---|---|
committer | 2018-07-06 22:22:10 -0700 | |
commit | 0710c57b01f666c0f0a0b4af3edc1eb086411279 (patch) | |
tree | 58f3ee196768c5a211a0ffd03088a4ee34537d0e | |
parent | gkeys/actions: Update the update-seed function (diff) | |
download | gentoo-keys-0710c57b01f666c0f0a0b4af3edc1eb086411279.tar.gz gentoo-keys-0710c57b01f666c0f0a0b4af3edc1eb086411279.tar.bz2 gentoo-keys-0710c57b01f666c0f0a0b4af3edc1eb086411279.zip |
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>
-rw-r--r-- | gkeys/gkeys/actions.py | 17 | ||||
-rw-r--r-- | gkeys/gkeys/seedhandler.py | 23 |
2 files changed, 39 insertions, 1 deletions
diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 3450277..02c21d7 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -115,6 +115,7 @@ 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: @@ -130,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 3eadcd6..4d094b2 100644 --- a/gkeys/gkeys/seedhandler.py +++ b/gkeys/gkeys/seedhandler.py @@ -101,6 +101,29 @@ class SeedHandler(object): added_gkeys = new_gkeys return(added_gkeys, changed_gkeys, removed_gkeys) + 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 |