aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraeroniero33 <justthisthing@gmail.com>2016-06-14 20:24:08 +0000
committerBrian Dolbec <dolsen@gentoo.org>2018-07-06 22:22:09 -0700
commit9e30a9d18f400b75b955a6e79e714c724f35bed9 (patch)
tree7fd8980b12b5bd0df048ad9a08061bb8d0c15c6a
parentUpdated the update-seed function and did a few improvements (diff)
downloadgentoo-keys-9e30a9d18f400b75b955a6e79e714c724f35bed9.tar.gz
gentoo-keys-9e30a9d18f400b75b955a6e79e714c724f35bed9.tar.bz2
gentoo-keys-9e30a9d18f400b75b955a6e79e714c724f35bed9.zip
Updated update-seed to display the updated keys when it's used
-rw-r--r--gkeys/gkeys/actions.py18
-rw-r--r--gkeys/gkeys/seedhandler.py23
2 files changed, 40 insertions, 1 deletions
diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index d319964..fe45222 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)
print("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:
print("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)
+ print("Updated revoked GKeys:")
+ if changed_gkeys:
+ for gkey in changed_gkeys:
+ self.output(['', changed_gkeys])
+ else:
+ print("No GKeys were revoked")
+ print("Added GKeys:")
+ if added_gkeys:
+ for gkey in added_gkeys:
+ self.output(['', added_gkeys])
+ else:
+ print("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..993f260 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -70,6 +70,29 @@ class SeedHandler(object):
if attr in GKEY._fields:
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