aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraeroniero33 <justthisthing@gmail.com>2016-06-17 17:40:01 +0000
committerBrian Dolbec <dolsen@gentoo.org>2018-07-06 22:22:10 -0700
commit47a65ab2d5dade6b2cae6d2f2834f0075b4840f2 (patch)
tree0d7cf8846a46293b051ca92082e74b1e9835c3b0
parentgkeys actions: Add keys updated reporting (diff)
downloadgentoo-keys-47a65ab2d5dade6b2cae6d2f2834f0075b4840f2.tar.gz
gentoo-keys-47a65ab2d5dade6b2cae6d2f2834f0075b4840f2.tar.bz2
gentoo-keys-47a65ab2d5dade6b2cae6d2f2834f0075b4840f2.zip
gkeys actions: Added automatic seeds,keys update capability
Add more detailed update reporting including the keys removed, revoked/changed, added. <rebase edit> Convert print() to proper self.output() Whitespace cleanup Commit message improvements </edit Brian Dolbec>
-rw-r--r--gkeys/gkeys/actions.py20
-rw-r--r--gkeys/gkeys/base.py8
-rw-r--r--gkeys/gkeys/seedhandler.py9
3 files changed, 24 insertions, 13 deletions
diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 02c21d7..71ed081 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -133,19 +133,19 @@ class Actions(ActionBase):
self.output('', "Update succeeded.\n")
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])
+ added_gkeys, changed_gkeys, removed_gkeys = self.seedhandler.compare_seeds(old_gkeys, new_gkeys)
+ for gkey in changed_gkeys:
+ self.output([changed_gkeys], "Updated or revoked GKeys:")
else:
- self.output('', "No GKeys were revoked")
- self.output('', "Added GKeys:")
- if added_gkeys:
- for gkey in added_gkeys:
- self.output(['', added_gkeys])
+ self.output('', "No GKeys were updated or revoked")
+ for gkey in added_gkeys:
+ self.output([added_gkeys], "Added GKeys:")
else:
self.output('', "No GKeys were added")
+ for gkey in removed_gkeys:
+ self.output([removed_gkeys], "Removed GKeys:")
+ else:
+ self.output('', "No GKeys were removed")
return (success, messages)
def addseed(self, args):
diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 783b0a5..3ecbd1b 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -366,7 +366,7 @@ class CliBase(object):
'''
# establish our actions instance
self.actions = self.cli_config['Actions'](self.config, self.output_results, self.logger)
- # check for seed update
+ # check for seed update
from sslfetch.connections import Connector
connector_output = {
'info': self.logger.info,
@@ -418,7 +418,11 @@ class CliBase(object):
elif False not in successes:
print("Seeds are up to date")
else:
- print("Seed update check failed, check your internet connection.")
+<<<<<<< HEAD
+ print("Seed update check failed, check your internet connection.")
+=======
+ print("Seed update check failed, check your internet connection.")
+>>>>>>> b9e64a9... gkeys actions: Added automatic seeds,keys update capability
# run the action
func = getattr(self.actions, '%s'
% self.cli_config['Action_Map'][args.action]['func'])
diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 4d094b2..62173c1 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -108,21 +108,28 @@ class SeedHandler(object):
@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
+ @return removed_gkeys: list of keys that are included in seed1 but not in seed2
'''
old_gkeys = seeds1[1]
new_gkeys = seeds2[1]
changed_gkeys = []
+ old_changed_gkeys = []
+ removed_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)
+ old_changed_gkeys.append(old_gkey)
if new_gkey not in old_gkeys and new_gkey not in changed_gkeys:
added_gkeys.append(new_gkey)
+ for old_gkey in old_gkeys:
+ if old_gkey not in new_gkeys and old_gkey not in old_changed_gkeys:
+ removed_gkeys.append(old_gkey)
else:
added_gkeys = new_gkeys
- return(added_gkeys, changed_gkeys)
+ return(added_gkeys, changed_gkeys, removed_gkeys)
def load_seeds(self, seedfile=None, filepath=None, refresh=False):
'''Load seed file