diff options
author | aeroniero33 <justthisthing@gmail.com> | 2016-06-12 14:19:35 +0000 |
---|---|---|
committer | Brian Dolbec <dolsen@gentoo.org> | 2018-07-06 22:22:09 -0700 |
commit | bab875f529ce6d334cbfe535b58b79d9a9064d6d (patch) | |
tree | c91fb262eecd74f1731c73e71e0d9383af210bcd | |
parent | Created the update-seed function (diff) | |
download | gentoo-keys-bab875f529ce6d334cbfe535b58b79d9a9064d6d.tar.gz gentoo-keys-bab875f529ce6d334cbfe535b58b79d9a9064d6d.tar.bz2 gentoo-keys-bab875f529ce6d334cbfe535b58b79d9a9064d6d.zip |
Updated the update-seed function and did a few improvements
-rw-r--r-- | gkeys/gkeys/action_map.py | 7 | ||||
-rw-r--r-- | gkeys/gkeys/actions.py | 39 |
2 files changed, 34 insertions, 12 deletions
diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py index 1bd0625..5433297 100644 --- a/gkeys/gkeys/action_map.py +++ b/gkeys/gkeys/action_map.py @@ -385,8 +385,8 @@ Found Failures: 'func': 'updateseed', 'options': ['category', 'nick', '1file', 'dest', 'signature', 'timestamp'], - 'desc': '''Update the selected seed file(s)''', - 'long_desc': '''Update the selected seed file(s)''', + 'desc': '''Update the selected seed file(s) or all categories if no arguments are given''', + 'long_desc': '''Update the selected seed file(s) or all categories if no arguments are given''', 'example': '''$ gkeys update-seed -C gentoo-devs Gkey task results: @@ -394,7 +394,8 @@ Found Failures: Key info...............: Gentoo-Linux Gentoo-keys Project Signing Key <gkeys>, 0xA41DBBD9151C3FC7 category, nick.....: gentoo gkeys - Update operation completed + Fetch operation completed + Completed ''', }), ('list-seed', { diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py index 3bc5f02..d319964 100644 --- a/gkeys/gkeys/actions.py +++ b/gkeys/gkeys/actions.py @@ -1,4 +1,4 @@ -# + #-*- coding:utf-8 -*- """ @@ -98,17 +98,39 @@ class Actions(ActionBase): return (False not in success, messages) def updateseed(self, args): - '''Updates seeds of a selected file''' + '''Updates seeds of a selected file or all categories if no args are given''' self.logger.debug(_unicode("ACTIONS: updateseed; args: %s") % _unicode(args)) + messages = [] + success = True + if not args.category: + '''Update all available categories''' + seed_categories = list(self.config.defaults['seeds']) + category_msgs = [] + for seed_category in seed_categories: + self.seeds = None + custom_args = args + custom_args.category = seed_category + category_success, messages = self.updateseed(custom_args) + category_msgs.extend(messages) + return (True, category_msgs) + print("Fetching seeds for %s category.\n" %args.category) fetch_success, fetch_messages = self.fetchseed(args) if fetch_success is not True: - return (False, fetch_messages) - install_success, install_messages = self.installkey(args) - if install_success is not True: - return (False, install_messages) - messages = fetch_messages + [install_messages] - return (True, messages) + success = False + messages = fetch_messages + print("Fetch failed.\n") + else: + print("Fetch succeeded.\n") + print("Installing or Refreshing keys for %s category." %args.category) + install_success, install_messages = self.installkey(args) + if install_success is not True: + print("Update failed.\n") + success = False + else: + print("Update succeeded.\n") + messages = fetch_messages + ["Update operation:"] + [install_messages] + return (success, messages) def addseed(self, args): '''Add or replace a key in the selected seed file''' @@ -313,7 +335,6 @@ class Actions(ActionBase): self.gpg.set_keydir(gkey.keydir, "recv-keys") self.gpg.set_keyseedfile() seeds = self.gpg.seedfile.seeds - #print(seeds) if seeds: self.logger.debug("ACTIONS: installkey; found installed seeds:" "\n %s" % seeds) |