public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2012-12-10  3:26 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2012-12-10  3:26 UTC (permalink / raw
  To: gentoo-commits

commit:     77ab04fd8aade18fe385d83963016ef5cb12cbd3
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec  9 15:16:01 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Dec  9 15:16:01 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=77ab04fd

New file seed.py, class  Seeds for all seed file handling, config fixes and extend GKEY capability.

---
 gkeys/config.py |   20 ++++++-
 gkeys/seed.py   |  154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 171 insertions(+), 3 deletions(-)

diff --git a/gkeys/config.py b/gkeys/config.py
index 1f6610c..a15ec55 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -42,7 +42,7 @@ class GKeysConfig(GPGConfig):
         if config:
             self.defaults['config'] = config
             self.defaults['configdir'] = os.path.dirname(config)
-        else
+        else:
             self.defaults['configdir'] = path([self.root, EPREFIX, '/etc/gentoo-keys'])
             self.defaults['config'] = '%(configdir)s/gkeys.conf'
         self.configparser = None
@@ -54,8 +54,10 @@ class GKeysConfig(GPGConfig):
     def _add_gkey_defaults(self):
         self.defaults['keysdir'] = path([self.root, EPREFIX, '/var/gentoo/gkeys'])
         self.defaults['devkeydir'] = '%(keysdir)s/devs'
-        self.defaults['releasekeydir'] = '%(keysdir)s/release')
+        self.defaults['releasekeydir'] = '%(keysdir)s/release'
         self.defaults['knownkeysfile'] = '%(keysdir)s/knownkeys'
+        self.fedualts['releaseseedfile'] = '%(configdir)s/release.seeds'
+        self.fedualts['devseedfile'] = '%(configdir)s/developer.seeds'
 
 
 
@@ -79,7 +81,19 @@ class GKeysConfig(GPGConfig):
 
 
 class GKEY(namedtuple('GKEY', ['name', 'keyid', 'longkeyid',
-    'fingerprint', 'keyring']):
+    'fingerprint', 'keyring'])):
     '''Class to hold the relavent info about a key'''
 
+    __slots__ = ()
+
+    def values(self):
+        '''Returns a list of the field values'''
+        v = []
+        for f in self._fields:
+            v.append(getattr(self, f))
+        return v
+
+    def value_string(self):
+        '''Returns a space separated string of the field values'''
+        return ' '.join([str(x) for x in self.values()])
 

diff --git a/gkeys/seed.py b/gkeys/seed.py
new file mode 100644
index 0000000..f473293
--- /dev/null
+++ b/gkeys/seed.py
@@ -0,0 +1,154 @@
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+
+'''Gentoo-keys - seed.py
+This is gentoo-keys superclass which wraps the pyGPG lib
+with gentoo-keys specific convienience functions.
+
+ Distributed under the terms of the GNU General Public License v2
+
+ Copyright:
+             (c) 2011 Brian Dolbec
+             Distributed under the terms of the GNU General Public License v2
+
+ Author(s):
+             Brian Dolbec <dolsen@gentoo.org>
+
+'''
+
+from gkeys.log import logger
+from gkeys.config import GKEY
+
+
+class Seeds(object):
+    '''Handles all seed key file operations'''
+
+    def __init__(self, filepath=None):
+        '''Seeds class init function
+
+        @param filepath: string of the file to load
+        '''
+        self.filename = filepath
+        self.seeds = []
+
+
+    def load(self, filename=None):
+        '''Load the seed file into memory'''
+        if filename:
+            self.filename = filename
+        if not self.filename:
+            logger.debug("Seed.load() Not a valid filename: '%s'" % str(self.filename))
+            return False
+        logger.debug("Begin loading seed file %s" % self.filename)
+        seedlines = None
+        self.seeds = []
+        try:
+            with open(self.filename) as seedfile:
+                seedlines = seedfile.readlines()
+        except IOError as err:
+            self._error(err)
+            return False
+
+        for seed in seedlines:
+            try:
+                parts = self._split_seed(seed)
+                self.seeds.append(GKEY._make(parts))
+            except Exception as err:
+                self._error(err)
+        logger.debug("Completed loading seed file %s" % self.filename)
+        return True
+
+
+    def save(self, filename=None):
+        '''Save the seeds to the file'''
+        if filename:
+            self.filename = filename
+        if not self.filename:
+            logger.debug("Seed.load() Not a valid filename: '%s'" % str(self.filename))
+            return False
+        logger.debug("Begin loading seed file %s" % self.filename)
+        try:
+            with open(self.filename, 'w') as seedfile:
+                seedlines = [x.value_string() for x in self.seeds]
+                seedfile.write('\n'.join(seedlines))
+                seedfile.write("\n")
+        except IOError as err:
+            self._error(err)
+            return
+
+
+    def add(self, gkey):
+        '''Add a new seed key to memory'''
+        if isinstance(gkey, GKEY):
+            self.seeds.append(gkey)
+            return True
+        return False
+
+
+
+    def delete(self, gkey=None, index=None):
+        '''Delete the key from the seeds in memory
+
+        @param gkey: GKEY, the matching GKEY to delete
+        @param index: int, '''
+        if gkey:
+            try:
+                self.seeds.remove(gkey)
+            except ValueError:
+                return False
+            return True
+        elif index:
+            self.seeds.pop(index)
+            return True
+
+
+    def list(self, **kwargs):
+        '''List the key or keys matching the kwargs argument or all
+
+        @param kwargs: dict of GKEY._fields and values
+        @returns list
+        '''
+        if not kwargs:
+            return self.seeds
+        # discard any invalid keys
+        keys = set(list(kwargs)).intersection(GKEY._fields)
+        result = self.seeds[:]
+        for key in keys:
+            result = [x for x in result if getattr(x , key) == kwargs[key]]
+        return result
+
+
+    def search(self, pattern):
+        '''Search for the keys matching the regular expression pattern'''
+        pass
+
+
+    def index(self, gkey):
+        '''The index of the gkey in the seeds list
+
+        @param gkey: GKEY, the matching GKEY to delete
+        @return int
+        '''
+        try:
+            index = self.seeds.index(gkey)
+        except ValueError:
+            return None
+        return index
+
+
+    def _error(self, err):
+        '''Class error logging function'''
+        logger.error("Error processing seed file %s" % self.filename)
+        logger.error("Error was: %s" % str(err))
+
+
+    @staticmethod
+    def _split_seed(seed):
+        '''Splits the seed string and
+        replaces all occurances of 'None' with the python type None'''
+        iterable = seed.split()
+        for i in range(len(iterable)):
+            if iterable[i] == 'None':
+                iterable[i] = None
+        return iterable
+


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2012-12-10  3:26 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2012-12-10  3:26 UTC (permalink / raw
  To: gentoo-commits

commit:     8c8c0b1679354c683beb8250d693bae127607a2f
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 10 03:25:47 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Dec 10 03:25:47 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=8c8c0b16

code list, add remove seeds. Very basic output printing for now.

---
 gkeys/cli.py |  206 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 202 insertions(+), 4 deletions(-)

diff --git a/gkeys/cli.py b/gkeys/cli.py
index 133cc1b..c3d0fd8 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -10,20 +10,218 @@
     @license: GNU GPL2, see COPYING for details.
 """
 
+from __future__ import print_function
+
+
+import argparse
+import sys
+
 from gkeys.log import logger
+from gkeys.config import GKeysConfig, GKEY
+from gkeys.seed import Seeds
+
+
+# set debug level to max
+logger.setLevel(1)
+
 
 class Main(object):
     '''Main command line interface class'''
 
-    def __init__(self, root=None):
+
+    def __init__(self, root=None, config=None, print_results=True):
         """ Main class init function.
 
         @param root: string, root path to use
         """
         self.root = root or "/"
+        self.config = config or GKeysConfig(root=root)
+        self.print_results = print_results
+        self.args = None
+
+
+    def __call__(self, args=None):
+        logger.debug("Main:__call__()")
+        if args:
+            self.run(self.parse_args(args))
+        else:
+            self.run(self.parse_args(sys.argv[1:]))
+
+
+    def parse_args(self, args):
+        '''Parse a list of aruments
+
+        @param args: list
+        @returns argparse.Namespace object
+        '''
+        logger.debug('args: %s' % args)
+        actions = ['listseed', 'addseed', 'removeseed', 'moveseed', 'listkey',
+            'addkey', 'removekey', 'movekey']
+        parser = argparse.ArgumentParser(
+            prog='gkeys',
+            description='Gentoo-keys manager program',
+            epilog='''Caution: adding untrusted keys to these keyrings can
+                be hazardous to your system!''')
+        # actions
+        parser.add_argument('action', choices=actions, nargs='?',
+            default='listseeds', help='Add to seed file or keyring')
+        # options
+        parser.add_argument('-c', '--config', dest='config', default=None,
+            help='The path to an alternate config file')
+        parser.add_argument('-f', '--fingerprint', dest='fingerprint', default=None,
+            help='The fingerprint of the the key')
+        parser.add_argument('-n', '--name', dest='name', default=None,
+            help='The name of the the key')
+        parser.add_argument('-k', '--keyid', dest='keyid', default=None,
+            help='The keyid of the the key')
+        parser.add_argument('-l', '--longkeyid', dest='longkeyid', default=None,
+            help='The longkeyid of the the key')
+        parser.add_argument('-r', '--keyring',
+            choices=['release', 'dev', 'overlays'], dest='keyring', default=None,
+            help='The keyring to use')
+        parser.add_argument('-s', '--seeds',
+            choices=['release', 'dev'], dest='seeds', default=None,
+            help='The seeds file to update')
+        parser.add_argument('-S', '--seedfile', dest='seedfile', default=None,
+            help='The seedfile path to use')
+
+        return parser.parse_args(args)
+
+
+    def run(self, args):
+        '''Run the args passed in
+
+        @param args: list or argparse.Namespace object
+        '''
+        if not args:
+            logger.error("Main.run() invalid args argument passed in")
+        if isinstance(args, list):
+            args = self.parse_args(args)
+        if args.config:
+            logger.debug("Found alternate config request: %s" % args.config)
+            self.config.defaults['config'] = args.config
+        # now make it load the config file
+        self.config.read_config()
+
+        func = getattr(self, '_action_%s' % args.action)
+        logger.debug('Found action: %s' % args.action)
+        results = func(args)
+        if self.print_results:
+            print('\n\nGkey results:')
+            print("\n".join([str(x) for x in results]))
+            print()
+
+
+    @staticmethod
+    def build_gkeydict(args):
+        keyinfo = {}
+        for x in GKEY._fields:
+            try:
+                value = getattr(args, x)
+                if value:
+                    keyinfo[x] = value
+            except AttributeError:
+                pass
+        return keyinfo
+
+
+    @staticmethod
+    def build_gkeylist(args):
+        keyinfo = []
+        for x in GKEY._fields:
+            try:
+                keyinfo.append(getattr(args, x))
+            except AttributeError:
+                keyinfo.append(None)
+        return keyinfo
+
+
+    def _load_seeds(self, filename):
+        filepath = self.config.get_key(filename + "-seedfile")
+        logger.debug("_load_seeds(); seeds filepath to load: "
+            "%s" % filepath)
+        seeds = Seeds()
+        seeds.load(filepath)
+        return seeds
+
 
-    def __call__(self):
-        logger.debug("CLI.__call__(): self.config.keys()"
-            " %s", str(self.config.keys()))
+    def _action_listseed(self, args):
+        '''Action listseed method'''
+        kwargs = self.build_gkeydict(args)
+        logger.debug("_action_listseed(); kwargs: %s" % str(kwargs))
+        seeds = self._load_seeds(args.seeds)
+        results = seeds.list(**kwargs)
+        return results
+
+
+    def _action_addseed(self, args):
+        '''Action addseed method'''
+        parts = self.build_gkeylist(args)
+        gkey = GKEY._make(parts)
+        logger.debug("_action_addseed(); new gkey: %s" % str(gkey))
+        seeds = self._load_seeds(args.seeds)
+        gkeys = self._action_listseed(args)
+        if len(gkeys) == 0:
+            logger.debug("_action_addkey(); now adding gkey: %s" % str(gkey))
+            success = seeds.add(gkey)
+            if success:
+                success = seeds.save()
+                return ["Successfully Added new seed: %s" % str(success), gkey]
+        else:
+            messages = ["Matching seeds found in seeds file",
+                "Aborting... \nMatching seeds:"]
+            messages.extend(gkeys)
+            return messages
+
+
+    def _action_removeseed(self, args):
+        '''Action removeseed method'''
+        parts = self.build_gkeylist(args)
+        searchkey = GKEY._make(parts)
+        logger.debug("_action_removeseed(); gkey: %s" % str(searchkey))
+        seeds = self._load_seeds(args.seeds)
+        gkeys = self._action_listseed(args)
+        if len(gkeys) == 1:
+            logger.debug("_action_removekey(); now deleting gkey: %s" % str(gkeys[0]))
+            success = seeds.delete(gkeys[0])
+            if success:
+                success = seeds.save()
+            return ["Successfully Removed seed: %s" % str(success),
+                gkeys[0]]
+        elif len(gkeys):
+            messages = ["Too many seeds found to remove"]
+            messages.extend(gkeys)
+            return messages
+        return ["Failed to Remove seed:", searchkey,
+            "No matching seed found"]
+
+
+    def _action_moveseed(self, args):
+        '''Action moveseed method'''
+        pass
+
+
+    def _action_listkey(self, args):
+        '''Action listskey method'''
+        pass
+
+
+    def _action_addkey(self, args):
+        '''Action addkey method'''
         pass
 
+
+    def _action_removekey(self, args):
+        '''Action removekey method'''
+        pass
+
+
+    def _action_movekey(self, args):
+        '''Action movekey method'''
+        pass
+
+
+
+
+
+


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2012-12-10  3:26 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2012-12-10  3:26 UTC (permalink / raw
  To: gentoo-commits

commit:     24923543e262aa5ffd7094ccafe69631256c26d8
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 10 03:24:37 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Dec 10 03:24:37 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=24923543

debug seed.py

---
 gkeys/seed.py |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gkeys/seed.py b/gkeys/seed.py
index f473293..7d85f6a 100644
--- a/gkeys/seed.py
+++ b/gkeys/seed.py
@@ -39,7 +39,7 @@ class Seeds(object):
         if not self.filename:
             logger.debug("Seed.load() Not a valid filename: '%s'" % str(self.filename))
             return False
-        logger.debug("Begin loading seed file %s" % self.filename)
+        logger.debug("Seeds: Begin loading seed file %s" % self.filename)
         seedlines = None
         self.seeds = []
         try:
@@ -74,7 +74,8 @@ class Seeds(object):
                 seedfile.write("\n")
         except IOError as err:
             self._error(err)
-            return
+            return False
+        return True
 
 
     def add(self, gkey):


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2012-12-10  3:26 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2012-12-10  3:26 UTC (permalink / raw
  To: gentoo-commits

commit:     00e9eee1729c000471036187bf6c09e890c7644b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec  9 15:22:26 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Dec  9 15:22:26 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=00e9eee1

add gkeys.__init__.py

---
 0 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/gkeys/__init__.py b/gkeys/__init__.py
new file mode 100644
index 0000000..e69de29


^ permalink raw reply	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2012-12-10  4:56 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2012-12-10  4:56 UTC (permalink / raw
  To: gentoo-commits

commit:     420c2ef794b9267f5fcf3a8bacfdb307f4942b03
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 10 04:56:34 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Dec 10 04:56:34 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=420c2ef7

fix missed copy/paste edit.

---
 gkeys/seed.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gkeys/seed.py b/gkeys/seed.py
index 7d85f6a..95aae9f 100644
--- a/gkeys/seed.py
+++ b/gkeys/seed.py
@@ -66,7 +66,7 @@ class Seeds(object):
         if not self.filename:
             logger.debug("Seed.load() Not a valid filename: '%s'" % str(self.filename))
             return False
-        logger.debug("Begin loading seed file %s" % self.filename)
+        logger.debug("Begin saving seed file %s" % self.filename)
         try:
             with open(self.filename, 'w') as seedfile:
                 seedlines = [x.value_string() for x in self.seeds]


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2012-12-10  4:56 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2012-12-10  4:56 UTC (permalink / raw
  To: gentoo-commits

commit:     ba85abe6630b8735459506ef210b4361c819174c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 10 04:56:08 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Dec 10 04:56:08 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=ba85abe6

add moveseed functionality.

---
 gkeys/cli.py |   45 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/gkeys/cli.py b/gkeys/cli.py
index c3d0fd8..b000f58 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -68,6 +68,8 @@ class Main(object):
         # options
         parser.add_argument('-c', '--config', dest='config', default=None,
             help='The path to an alternate config file')
+        parser.add_argument('-d', '--dest', dest='destination', default=None,
+            help='The destination seed file or keyring for move, copy operations')
         parser.add_argument('-f', '--fingerprint', dest='fingerprint', default=None,
             help='The fingerprint of the the key')
         parser.add_argument('-n', '--name', dest='name', default=None,
@@ -78,10 +80,10 @@ class Main(object):
             help='The longkeyid of the the key')
         parser.add_argument('-r', '--keyring',
             choices=['release', 'dev', 'overlays'], dest='keyring', default=None,
-            help='The keyring to use')
+            help='The keyring to use or update')
         parser.add_argument('-s', '--seeds',
             choices=['release', 'dev'], dest='seeds', default=None,
-            help='The seeds file to update')
+            help='The seeds file to use or update')
         parser.add_argument('-S', '--seedfile', dest='seedfile', default=None,
             help='The seedfile path to use')
 
@@ -106,6 +108,7 @@ class Main(object):
         func = getattr(self, '_action_%s' % args.action)
         logger.debug('Found action: %s' % args.action)
         results = func(args)
+        # super simple output for the time being
         if self.print_results:
             print('\n\nGkey results:')
             print("\n".join([str(x) for x in results]))
@@ -182,7 +185,7 @@ class Main(object):
         seeds = self._load_seeds(args.seeds)
         gkeys = self._action_listseed(args)
         if len(gkeys) == 1:
-            logger.debug("_action_removekey(); now deleting gkey: %s" % str(gkeys[0]))
+            logger.debug("_action_removeseed(); now deleting gkey: %s" % str(gkeys[0]))
             success = seeds.delete(gkeys[0])
             if success:
                 success = seeds.save()
@@ -198,7 +201,41 @@ class Main(object):
 
     def _action_moveseed(self, args):
         '''Action moveseed method'''
-        pass
+        parts = self.build_gkeylist(args)
+        searchkey = GKEY._make(parts)
+        logger.debug("_action_moveseed(); gkey: %s" % str(searchkey))
+        seeds = self._load_seeds(args.seeds)
+        kwargs = self.build_gkeydict(args)
+        sourcekeys = seeds.list(**kwargs)
+        dest = self._load_seeds(args.destination)
+        destkeys = dest.list(**kwargs)
+        messages = []
+        if len(sourcekeys) == 1 and destkeys == []:
+            logger.debug("_action_moveseed(); now adding destination gkey: %s"
+                % str(sourcekeys[0]))
+            success = dest.add(sourcekeys[0])
+            logger.debug("_action_moveseed(); success: %s" %str(success))
+            logger.debug("_action_moveseed(); now deleting sourcekey: %s" % str(sourcekeys[0]))
+            success = seeds.delete(sourcekeys[0])
+            if success:
+                success = dest.save()
+                logger.debug("_action_moveseed(); destination saved... %s" %str(success))
+                success = seeds.save()
+            messages.extend(["Successfully Moved %s seed: %s"
+                % (args.seeds, str(success)), sourcekeys[0]])
+            return messages
+        elif len(sourcekeys):
+            messages = ["Too many seeds found to remove"]
+            messages.extend(sourcekeys)
+            return messages
+        messages.append("Failed to Move seed:")
+        messages.append(searchkey)
+        messages.append('\n')
+        messages.append("Source seeds found...")
+        messages.extend(sourcekeys or ["None\n"])
+        messages.append("Destination seeds found...")
+        messages.extend(destkeys or ["None\n"])
+        return messages
 
 
     def _action_listkey(self, args):


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-06-23  7:13 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-06-23  7:13 UTC (permalink / raw
  To: gentoo-commits

commit:     6f3b196fe61f1cd20b23e5a08a9a9f238e2f5c4d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 22 01:43:33 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 22 15:42:31 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=6f3b196f

Add a configured separator for the in file seed info.

---
 gkeys/seed.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gkeys/seed.py b/gkeys/seed.py
index d045a22..4b4710a 100644
--- a/gkeys/seed.py
+++ b/gkeys/seed.py
@@ -23,6 +23,8 @@ from gkeys.config import GKEY
 class Seeds(object):
     '''Handles all seed key file operations'''
 
+    separator = '|'
+
     def __init__(self, filepath=None):
         '''Seeds class init function
 
@@ -69,7 +71,7 @@ class Seeds(object):
         logger.debug("Begin saving seed file %s" % self.filename)
         try:
             with open(self.filename, 'w') as seedfile:
-                seedlines = [x.value_string() for x in self.seeds]
+                seedlines = [x.value_string(self.separator) for x in self.seeds]
                 seedfile.write('\n'.join(seedlines))
                 seedfile.write("\n")
         except IOError as err:
@@ -147,7 +149,7 @@ class Seeds(object):
     def _split_seed(seed):
         '''Splits the seed string and
         replaces all occurances of 'None' with the python type None'''
-        iterable = seed.split()
+        iterable = seed.split(self.separator)
         for i in range(len(iterable)):
             if iterable[i] == 'None':
                 iterable[i] = None


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-06-23  7:13 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-06-23  7:13 UTC (permalink / raw
  To: gentoo-commits

commit:     5b31b5cbc9bf1ee54da8aa269d74e38c00bc5015
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 22 01:38:50 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 22 01:38:50 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=5b31b5cb

Add a --nick option.

Move the --name short option to -N, so -n could be for --nick.
Fix  a copied message that I failed to edit.

---
 gkeys/cli.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gkeys/cli.py b/gkeys/cli.py
index d3d0786..f9720f9 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -72,8 +72,10 @@ class Main(object):
             help='The destination seed file or keyring for move, copy operations')
         parser.add_argument('-f', '--fingerprint', dest='fingerprint', default=None,
             help='The fingerprint of the the key')
-        parser.add_argument('-n', '--name', dest='name', default=None,
+        parser.add_argument('-N', '--name', dest='name', default=None,
             help='The name of the the key')
+        parser.add_argument('-n', '--nick', dest='nick', default=None,
+            help='The nick associated with the the key')
         parser.add_argument('-k', '--keyid', dest='keyid', default=None,
             help='The keyid of the the key')
         parser.add_argument('-l', '--longkeyid', dest='longkeyid', default=None,
@@ -225,7 +227,7 @@ class Main(object):
                 % (args.seeds, str(success)), sourcekeys[0]])
             return messages
         elif len(sourcekeys):
-            messages = ["Too many seeds found to remove"]
+            messages = ["Too many seeds found to move"]
             messages.extend(sourcekeys)
             return messages
         messages.append("Failed to Move seed:")


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-06-23  7:13 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-06-23  7:13 UTC (permalink / raw
  To: gentoo-commits

commit:     c37261f1fdca7882af62d551790429c10653b9cc
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 22 01:42:03 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 22 01:42:03 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=c37261f1

Add keyring parameter to GkeysGPG class

---
 gkeys/lib.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gkeys/lib.py b/gkeys/lib.py
index cb6fb96..bbd126c 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -18,19 +18,23 @@ with gentoo-keys specific convienience functions.
 
 
 from pygpg.gpg import GPG
+from gkeys.log import logger
 
 
 class GkeysGPG(GPG):
     '''Gentoo-keys primary gpg class'''
 
 
-    def __init__(self, config):
+    def __init__(self, config, keyring):
         '''class init function
 
         @param config: GKeysConfig config instance to use
+        @param keyring: string, the path to the keyring to be used
+                        for all operations.
         '''
         GPG.__init__(self, config)
         self.config = config
+        self.keyring = keyring
 
 
     def add_key(self, gkey):
@@ -38,6 +42,7 @@ class GkeysGPG(GPG):
 
         @param gkey: GKEY namedtuple with (name, keyid/longkeyid, fingerprint)
         '''
+
         pass
 
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-06-23  7:13 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-06-23  7:13 UTC (permalink / raw
  To: gentoo-commits

commit:     e21ce0b047af8e7776ef6750ee1a29cd792aed89
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 23 07:04:36 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Dec 23 07:04:36 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=e21ce0b0

remove the shebang from all lib files, since they won't have an if __main__:

---
 gkeys/cli.py    | 2 +-
 gkeys/config.py | 2 +-
 gkeys/lib.py    | 5 +----
 gkeys/log.py    | 2 +-
 gkeys/seed.py   | 2 +-
 gkeys/utils.py  | 2 +-
 6 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/gkeys/cli.py b/gkeys/cli.py
index b000f58..d3d0786 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#
 #-*- coding:utf-8 -*-
 
 """

diff --git a/gkeys/config.py b/gkeys/config.py
index 3695242..1daca70 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#
 #-*- coding:utf-8 -*-
 
 """

diff --git a/gkeys/lib.py b/gkeys/lib.py
index cc95fca..cb6fb96 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#
 #-*- coding:utf-8 -*-
 
 '''Gentoo-keys - lib.py
@@ -98,6 +98,3 @@ class GkeysGPG(GPG):
         '''
         pass
 
-
-    def
-

diff --git a/gkeys/log.py b/gkeys/log.py
index a584f67..c0a33e7 100644
--- a/gkeys/log.py
+++ b/gkeys/log.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#
 #-*- coding:utf-8 -*-
 
 """

diff --git a/gkeys/seed.py b/gkeys/seed.py
index 95aae9f..d045a22 100644
--- a/gkeys/seed.py
+++ b/gkeys/seed.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#
 #-*- coding:utf-8 -*-
 
 '''Gentoo-keys - seed.py

diff --git a/gkeys/utils.py b/gkeys/utils.py
index bfbed83..0cbcdea 100644
--- a/gkeys/utils.py
+++ b/gkeys/utils.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#
 # -*- coding: utf-8 -*-
 
 '''# File:       xml.py


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-06-23  7:13 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-06-23  7:13 UTC (permalink / raw
  To: gentoo-commits

commit:     c418a8193a4efa791654fb2027195977a49cc6f8
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 22 01:40:42 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 22 01:40:42 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=c418a819

Add nick field to GKEY class

---
 gkeys/config.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/gkeys/config.py b/gkeys/config.py
index 1daca70..3da1c21 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -17,6 +17,7 @@ from collections import namedtuple
 
 from pygpg.config import GPGConfig
 
+from gkeys.log import logger
 from gkeys.utils import path
 
 
@@ -74,7 +75,7 @@ class GKeysConfig(GPGConfig):
         self.configparser.read(defaults['config'])
 
 
-    def get_key(self, key):
+    def get_key(self, key, subkey=None):
         return self._get_(key)
 
 
@@ -89,8 +90,8 @@ class GKeysConfig(GPGConfig):
         return None
 
 
-class GKEY(namedtuple('GKEY', ['name', 'keyid', 'longkeyid',
-    'fingerprint', 'keyring'])):
+class GKEY(namedtuple('GKEY', ['nick', 'name', 'keyid', 'longkeyid',
+    'keyring', 'fingerprint'])):
     '''Class to hold the relavent info about a key'''
 
     __slots__ = ()
@@ -102,7 +103,7 @@ class GKEY(namedtuple('GKEY', ['name', 'keyid', 'longkeyid',
             v.append(getattr(self, f))
         return v
 
-    def value_string(self):
+    def value_string(self, separator=' '):
         '''Returns a space separated string of the field values'''
-        return ' '.join([str(x) for x in self.values()])
+        return separator.join([str(x) for x in self.values()])
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-06-23  7:13 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-06-23  7:13 UTC (permalink / raw
  To: gentoo-commits

commit:     66cac951e6b1f7bbeedfcb9d0f8b5347b111658c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 23 01:22:02 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jun 23 04:30:59 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=66cac951

Fix a self error

---
 gkeys/seed.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gkeys/seed.py b/gkeys/seed.py
index fc71551..544ab02 100644
--- a/gkeys/seed.py
+++ b/gkeys/seed.py
@@ -41,21 +41,24 @@ class Seeds(object):
         if not self.filename:
             logger.debug("Seed: load; Not a valid filename: '%s'" % str(self.filename))
             return False
-        logger.debug("Seeds: Begin loading seed file %s" % self.filename)
+        logger.debug("Seeds: load; Begin loading seed file %s" % self.filename)
         seedlines = None
         self.seeds = []
         try:
             with open(self.filename) as seedfile:
                 seedlines = seedfile.readlines()
         except IOError as err:
+            logger.debug("Seed: load; IOError occurred while loading file")
             self._error(err)
             return False
 
         for seed in seedlines:
             try:
-                parts = self._split_seed(seed)
+                parts = self._split_seed(seed, self.separator)
                 self.seeds.append(GKEY._make(parts))
             except Exception as err:
+                logger.debug("Seed: load; Error splitting seed: %s" % seed)
+                logger.debug("Seed: load; ...............parts: %s" % str(parts))
                 self._error(err)
         logger.debug("Seed: load; Completed loading seed file %s" % self.filename)
         return True
@@ -146,10 +149,10 @@ class Seeds(object):
 
 
     @staticmethod
-    def _split_seed(seed):
+    def _split_seed(seed, separator):
         '''Splits the seed string and
         replaces all occurances of 'None' with the python type None'''
-        iterable = seed.split(self.separator)
+        iterable = seed.split(separator)
         for i in range(len(iterable)):
             if iterable[i] == 'None':
                 iterable[i] = None


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-07-06 19:02 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-07-06 19:02 UTC (permalink / raw
  To: gentoo-commits

commit:     cf1a206c19d679e67884633e0dda62454cad88c7
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 25 15:38:41 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jul  6 18:16:38 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=cf1a206c

Refactor GKEY calss to handle all packing and unpacking of data in order to handle list type field data.

---
 gkeys/config.py | 96 +++++++++++++++++++++++++++++++++++++++++++++++----------
 gkeys/seed.py   | 29 +++++------------
 2 files changed, 88 insertions(+), 37 deletions(-)

diff --git a/gkeys/config.py b/gkeys/config.py
index f775d23..8b8360f 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -10,7 +10,7 @@
     @license: GNU GNU GPL2, see COPYING for details.
 """
 
-
+import os
 import ConfigParser
 from collections import namedtuple
 
@@ -52,7 +52,7 @@ class GKeysConfig(GPGConfig):
 
 
     def _add_gkey_defaults(self):
-        self.defaults['key-sdir'] = path([self.root, EPREFIX, '/var/gentoo/gkeys'])
+        self.defaults['keysdir'] = path([self.root, EPREFIX, '/var/gentoo/gkeys'])
         self.defaults['dev-keydir'] = '%(keysdir)s/devs'
         self.defaults['release-keydir'] = '%(keysdir)s/release'
         self.defaults['overlays-keydir'] = '%(keysdir)s/overlays'
@@ -70,40 +70,104 @@ class GKeysConfig(GPGConfig):
             self.defaults['config'] = self.defaults['config'] \
                 % {'configdir': self.defaults['configdir']}
         defaults = self.get_defaults()
+        # remove some defaults from being entered into the configparser
+        for key in ['gpg_defaults', 'only_usable', 'refetch', 'tasks']:
+            defaults.pop(key)
         self.configparser = ConfigParser.ConfigParser(defaults)
         self.configparser.add_section('MAIN')
         self.configparser.read(defaults['config'])
 
 
     def get_key(self, key, subkey=None):
-        return self._get_(key)
+        return self._get_(key, subkey)
 
 
-    def _get_(self, key):
+    def _get_(self, key, subkey=None):
         if self.configparser and self.configparser.has_option('MAIN', key):
+            logger.debug("Found %s in configparser... %s"
+                % (key, str(self.configparser.get('MAIN', key))))
+            logger.debug("type(key)= %s"
+                % str(type(self.configparser.get('MAIN', key))))
             return self.configparser.get('MAIN', key)
-        elif key in self.options:
-            return self.options[key]
-        elif key in self.defaults:
-            return self.defaults[key]
-        logger.error("GKeysConfig: _get_; didn't find :", key)
-        return None
+        else:
+            return super(GKeysConfig, self)._get_(key, subkey)
+        #elif key in self.options:
+            #logger.debug("Found %s in options... %s"
+                #% (key, str(self.options[key])))
+            #return self.options[key]
+        #elif key in self.defaults:
+            #logger.debug("type(key)= %s" %str(type(self.defaults[key])))
+            #logger.debug("Found %s in defaults... %s"
+                #% (key, str(self.defaults[key])))
+            #logger.debug("type(key)= %s" %str(type(self.defaults[key])))
+            #return self.defaults[key]
+        #logger.error("GKeysConfig: _get_; didn't find :", key)
+        #return None
 
 
 class GKEY(namedtuple('GKEY', ['nick', 'name', 'keyid', 'longkeyid',
     'keyring', 'fingerprint'])):
     '''Class to hold the relavent info about a key'''
 
+    field_types = {'nick': str, 'name': str, 'keyid': list,
+        'longkeyid': list, 'keyring': str, 'fingerprint': list}
+    field_separator = "|"
+    list_separator = ":"
     __slots__ = ()
 
-    def values(self):
+    def _packed_values(self):
         '''Returns a list of the field values'''
         v = []
         for f in self._fields:
-            v.append(getattr(self, f))
+            v.append(self._pack(f))
         return v
 
-    def value_string(self, separator=' '):
-        '''Returns a space separated string of the field values'''
-        return separator.join([str(x) for x in self.values()])
-
+    @property
+    def packed_string(self):
+        '''Returns a separator joined string of the field values'''
+        return self.field_separator.join([x for x in self._packed_values()])
+
+    def _unpack_string(self, packed_data):
+        '''Returns a list of the separator joined string of the field values'''
+        values = []
+        data = packed_data.split(self.field_separator)
+        for x in self._fields:
+            values.append(self._unpack(x, data.pop(0)))
+        return values
+
+    def _pack(self, field):
+        '''pack field data into a string'''
+        if self.field_types[field] == str:
+            return getattr(self, field)
+        elif self.field_types[field] == list:
+            info = getattr(self, field)
+            if info:
+                return self.list_separator.join(info)
+            else:
+                # force an empty list to None
+                return 'None'
+        else:
+            raise "ERROR packing %s" %str(getattr(self, field))
+
+    def _unpack(self, field, data):
+        '''unpack field data to the desired type'''
+        if self.field_types[field] == str:
+            result = data
+            if result == 'None':
+                result = None
+        else:
+            if data == 'None':
+                # make it an empty list
+                result = []
+            else:
+                result = data.split(self.list_separator)
+        return result
+
+    def make_packed(self, packed_string):
+        '''Creates a new instance of Gkey from the packed
+        value string
+
+        @param packed_string: string of data separated by field_separator
+        @return new GKEY instance containing the data
+        '''
+        return self._make(self._unpack_string(packed_string))

diff --git a/gkeys/seed.py b/gkeys/seed.py
index 5cfa5fe..ba3614f 100644
--- a/gkeys/seed.py
+++ b/gkeys/seed.py
@@ -23,7 +23,6 @@ from gkeys.config import GKEY
 class Seeds(object):
     '''Handles all seed key file operations'''
 
-    separator = '|'
 
     def __init__(self, filepath=None):
         '''Seeds class init function
@@ -53,14 +52,13 @@ class Seeds(object):
             return False
 
         for seed in seedlines:
-            try:
-                seed = seed.strip('\n')
-                parts = self._split_seed(seed, self.separator)
-                self.seeds.append(GKEY._make(parts))
-            except Exception as err:
-                logger.debug("Seed: load; Error splitting seed: %s" % seed)
-                logger.debug("Seed: load; ...............parts: %s" % str(parts))
-                self._error(err)
+            #try:
+            seed = seed.strip('\n')
+            self.seeds.append(GKEY.make_packed(seed))
+            #except Exception as err:
+                #logger.debug("Seed: load; Error splitting seed: %s" % seed)
+                #logger.debug("Seed: load; ...............parts: %s" % str(parts))
+                #self._error(err)
         logger.debug("Seed: load; Completed loading seed file %s" % self.filename)
         return True
 
@@ -75,7 +73,7 @@ class Seeds(object):
         logger.debug("Seed: save; Begin saving seed file %s" % self.filename)
         try:
             with open(self.filename, 'w') as seedfile:
-                seedlines = [x.value_string(self.separator) for x in self.seeds]
+                seedlines = [x.packed_string for x in self.seeds]
                 seedfile.write('\n'.join(seedlines))
                 seedfile.write("\n")
         except IOError as err:
@@ -148,14 +146,3 @@ class Seeds(object):
         logger.error("Seed: Error processing seed file %s" % self.filename)
         logger.error("Seed: Error was: %s" % str(err))
 
-
-    @staticmethod
-    def _split_seed(seed, separator):
-        '''Splits the seed string and
-        replaces all occurances of 'None' with the python type None'''
-        iterable = seed.split(separator)
-        for i in range(len(iterable)):
-            if iterable[i] == 'None':
-                iterable[i] = None
-        return iterable
-


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-07-06 19:02 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-07-06 19:02 UTC (permalink / raw
  To: gentoo-commits

commit:     8f2e6092df5e9579668511350dad4eb268f697c7
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 26 08:31:00 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jul  6 18:16:51 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=8f2e6092

Work in progress changes to get add_key coded &  working.

---
 gkeys/cli.py    | 106 ++++++++++++++++++++++++++++++++++++++++++++++----------
 gkeys/config.py |   2 +-
 gkeys/lib.py    |  55 +++++++++++++++++++++++++----
 gkeys/seed.py   |   7 +++-
 4 files changed, 143 insertions(+), 27 deletions(-)

diff --git a/gkeys/cli.py b/gkeys/cli.py
index 743b622..3c9bc49 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -22,6 +22,7 @@ from gkeys.log import logger
 
 from gkeys.config import GKeysConfig, GKEY
 from gkeys.seed import Seeds
+from gkeys.lib import GkeysGPG
 
 
 # set debug level to min
@@ -41,6 +42,7 @@ class Main(object):
         self.config = config or GKeysConfig(root=root)
         self.print_results = print_results
         self.args = None
+        self.seeds = None
 
 
     def __call__(self, args=None):
@@ -114,6 +116,7 @@ class Main(object):
         # now make it load the config file
         self.config.read_config()
 
+        # run the action
         func = getattr(self, '_action_%s' % args.action)
         logger.debug('Main: run; Found action: %s' % args.action)
         results = func(args)
@@ -121,14 +124,19 @@ class Main(object):
             print("No results found.  Check your configuration and that the",
                 "seed file exists.")
             return
-        # super simple output for the time being
-        if self.print_results:
-            print('\n\nGkey results:')
-            print("\n".join([str(x) for x in results]))
+        if self.print_results and 'done' not in list(results):
+            self.output_results(results, '\n Gkey task results:')
             print()
 
 
     @staticmethod
+    def output_results(results, header):
+        # super simple output for the time being
+        print(header)
+        print("\n".join([str(x) for x in results]))
+
+
+    @staticmethod
     def build_gkeydict(args):
         keyinfo = {}
         for x in GKEY._fields:
@@ -167,9 +175,10 @@ class Main(object):
         '''Action listseed method'''
         kwargs = self.build_gkeydict(args)
         logger.debug("MAIN: _action_listseed; kwargs: %s" % str(kwargs))
-        seeds = self._load_seeds(args.seeds)
-        if seeds:
-            results = seeds.list(**kwargs)
+        if not self.seeds:
+            self.seeds = self._load_seeds(args.seeds)
+        if self.seeds:
+            results = self.seeds.list(**kwargs)
             return results
         return None
 
@@ -179,13 +188,12 @@ class Main(object):
         parts = self.build_gkeylist(args)
         gkey = GKEY._make(parts)
         logger.debug("MAIN: _action_addseed; new gkey: %s" % str(gkey))
-        seeds = self._load_seeds(args.seeds)
         gkeys = self._action_listseed(args)
         if len(gkeys) == 0:
             logger.debug("MAIN: _action_addkey; now adding gkey: %s" % str(gkey))
-            success = seeds.add(gkey)
+            success = self.seeds.add(gkey)
             if success:
-                success = seeds.save()
+                success = self.seeds.save()
                 return ["Successfully Added new seed: %s" % str(success), gkey]
         else:
             messages = ["Matching seeds found in seeds file",
@@ -199,13 +207,12 @@ class Main(object):
         parts = self.build_gkeylist(args)
         searchkey = GKEY._make(parts)
         logger.debug("MAIN: _action_removeseed; gkey: %s" % str(searchkey))
-        seeds = self._load_seeds(args.seeds)
         gkeys = self._action_listseed(args)
         if len(gkeys) == 1:
             logger.debug("MAIN: _action_removeseed; now deleting gkey: %s" % str(gkeys[0]))
-            success = seeds.delete(gkeys[0])
+            success = self.seeds.delete(gkeys[0])
             if success:
-                success = seeds.save()
+                success = self.seeds.save()
             return ["Successfully Removed seed: %s" % str(success),
                 gkeys[0]]
         elif len(gkeys):
@@ -221,9 +228,10 @@ class Main(object):
         parts = self.build_gkeylist(args)
         searchkey = GKEY._make(parts)
         logger.debug("MAIN: _action_moveseed; gkey: %s" % str(searchkey))
-        seeds = self._load_seeds(args.seeds)
+        if not self.seeds:
+            self.seeds = self._load_seeds(args.seeds)
         kwargs = self.build_gkeydict(args)
-        sourcekeys = seeds.list(**kwargs)
+        sourcekeys = self.seeds.list(**kwargs)
         dest = self._load_seeds(args.destination)
         destkeys = dest.list(**kwargs)
         messages = []
@@ -233,11 +241,11 @@ class Main(object):
             success = dest.add(sourcekeys[0])
             logger.debug("MAIN: _action_moveseed; success: %s" %str(success))
             logger.debug("MAIN: _action_moveseed; now deleting sourcekey: %s" % str(sourcekeys[0]))
-            success = seeds.delete(sourcekeys[0])
+            success = self.seeds.delete(sourcekeys[0])
             if success:
                 success = dest.save()
                 logger.debug("MAIN: _action_moveseed; destination saved... %s" %str(success))
-                success = seeds.save()
+                success = self.seeds.save()
             messages.extend(["Successfully Moved %s seed: %s"
                 % (args.seeds, str(success)), sourcekeys[0]])
             return messages
@@ -262,7 +270,59 @@ class Main(object):
 
     def _action_addkey(self, args):
         '''Action addkey method'''
-        pass
+        kwargs = self.build_gkeydict(args)
+        logger.debug("MAIN: _action_listseed; kwargs: %s" % str(kwargs))
+        self.seeds = self._load_seeds(args.seeds)
+        if self.seeds:
+            # get the desired seed
+            keyresults = self.seeds.list(**kwargs)
+            if keyresults and not args.nick == '*':
+                self.output_results(keyresults, "\n Found GKEY seeds:")
+            elif keyresults:
+                self.output_results(['all'], "\n Installing seeds:")
+            else:
+                logger.info("MAIN: _action_addkey; "
+                    "Matching seed entry not found")
+                if args.nick:
+                    return {"Search failed for: %s" % args.nick: False}
+                elif args.name:
+                    return {"Search failed for: %s" % args.name: False}
+                else:
+                    return {"Search failed for search term": False}
+            # get confirmation
+            # fill in code here
+            keydir = self.config.get_key(args.seeds + "-keydir")
+            logger.debug("MAIN: _action_addkey; keysdir = %s" % keydir)
+            self.gpg = GkeysGPG(self.config, keydir)
+            results = {}
+            failed = []
+            for key in keyresults:
+                if not key.keyid and not key.longkeyid and not args.nick == '*':
+                    logger.debug("MAIN: _action_addkey; NO key id's to add... Ignoring")
+                    return {"Failed: No keyid's found for %s" % key.name : ''}
+                elif not key.keyid and not key.longkeyid:
+                    print("No keyid's found for:", key.nick, key.name, "Skipping...")
+                    failed.append(key)
+                    continue
+                logger.debug("MAIN: _action_addkey; adding key:")
+                logger.debug("MAIN: " + str(key))
+                results[key.name] = self.gpg.add_key(key)
+                for result in results[key.name]:
+                    logger.debug("MAIN: _action_addkey; result.failed = " +
+                        str(result.failed))
+                if self.print_results:
+                    for result in results[key.name]:
+                        print("key desired:", key.name, ", key added:",
+                            result.username, ", succeeded:",
+                            not result.failed, ", keyid:", result.keyid,
+                            ", fingerprint:", result.fingerprint)
+                        logger.debug("stderr_out: " + str(result.stderr_out))
+                        if result.failed:
+                            failed.append(key)
+            if failed:
+                self.output_results(failed, "\n Failed to install:")
+            return {'Completed'}
+        return {"No seeds to search or install": False}
 
 
     def _action_removekey(self, args):
@@ -275,7 +335,15 @@ class Main(object):
         pass
 
 
+    def user_confirm(self, message):
+        '''Get input from the user to confirm to proceed
+        with the desired action
 
+        @param message: string, user promt message to display
+        @return boolean: confirmation to proceed or abort
+        '''
+        pass
 
 
-
+    def output_failed(self, failed):
+        pass

diff --git a/gkeys/config.py b/gkeys/config.py
index 8b8360f..e78f487 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -170,4 +170,4 @@ class GKEY(namedtuple('GKEY', ['nick', 'name', 'keyid', 'longkeyid',
         @param packed_string: string of data separated by field_separator
         @return new GKEY instance containing the data
         '''
-        return self._make(self._unpack_string(packed_string))
+        return GKEY._make(self._unpack_string(packed_string))

diff --git a/gkeys/lib.py b/gkeys/lib.py
index bbd126c..cae7f07 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -16,6 +16,7 @@ with gentoo-keys specific convienience functions.
 
 '''
 
+from os.path import join as pjoin
 
 from pygpg.gpg import GPG
 from gkeys.log import logger
@@ -25,25 +26,67 @@ class GkeysGPG(GPG):
     '''Gentoo-keys primary gpg class'''
 
 
-    def __init__(self, config, keyring):
+    def __init__(self, config, keydir):
         '''class init function
 
         @param config: GKeysConfig config instance to use
-        @param keyring: string, the path to the keyring to be used
+        @param keyring: string, the path to the keydir to be used
                         for all operations.
         '''
         GPG.__init__(self, config)
         self.config = config
-        self.keyring = keyring
+        self.keydir = keydir
 
 
     def add_key(self, gkey):
         '''Add the specified key to the specified keyring
 
-        @param gkey: GKEY namedtuple with (name, keyid/longkeyid, fingerprint)
+        @param gkey: GKEY namedtuple with
+            (name, keyid/longkeyid, keyring, fingerprint,)
         '''
-
-        pass
+        logger.debug("keydir: %s, keyring: %s" % (self.keydir, gkey.keyring))
+        keypath = pjoin(self.keydir, gkey.keyring)
+        # --keyring file |  Note that this adds a keyring to the current list.
+        # If the intent is to use the specified keyring alone,
+        # use  --keyring  along with --no-default-keyring.
+        self.config['tasks']['recv-keys'] = [
+            '--no-default-keyring', '--keyring', keypath,
+            ]
+        # prefer the longkeyid if available
+        #logger.debug("LIB: add_key; keyids %s, %s"
+        #    % (str(gkey.longkeyid), str(gkey.keyid)))
+        if gkey.longkeyid != []:
+            keyids = gkey.longkeyid
+        #    logger.debug("LIB: add_key; found gkey.longkeyid", keyids, type(gkey.longkeyid)
+        elif gkey.keyid != []:
+            keyids = gkey.keyid
+        #    logger.debug("LIB: add_key; found gkey.keyid" + str(keyids))
+        results = []
+        for keyid in keyids:
+            logger.debug("LIB: add_key; final keyids" + keyid)
+            logger.debug("** Calling runGPG with Running 'gpg %s --recv-keys %s' for: %s"
+                % (' '.join(self.config['tasks']['recv-keys']),
+                    keyid, gkey.name)
+                )
+            result = self.runGPG(task='recv-keys', inputfile=keyid)
+            logger.info('GPG return code: ' + str(result.returncode))
+            if result.fingerprint in gkey.fingerprint:
+                result.failed = False
+                message = "Fingerprints match... Import successful: "
+                message += "key: %s" %keyid
+                message += "\n    result len: %s, %s" %(len(result.fingerprint), result.fingerprint)
+                message += "\n    gkey len: %s, %s" %(len(gkey.fingerprint[0]), gkey.fingerprint[0])
+                logger.info(message)
+            else:
+                result.failed = True
+                message = "Fingerprints do not match... Import failed for "
+                message += "key: %s" %keyid
+                message += "\n     result:   %s" %(result.fingerprint)
+                message += "\n     gkey..: %s" %(str(gkey.fingerprint))
+                logger.error(message)
+            results.append(result)
+            print result.stderr_out
+        return results
 
 
     def del_key(self, gkey, keyring):

diff --git a/gkeys/seed.py b/gkeys/seed.py
index ba3614f..1dd8fc4 100644
--- a/gkeys/seed.py
+++ b/gkeys/seed.py
@@ -51,10 +51,12 @@ class Seeds(object):
             self._error(err)
             return False
 
+        # initialize a dummy instance, so it can make new ones
+        gkey = GKEY._make([None,None,None,None,None,None])
         for seed in seedlines:
             #try:
             seed = seed.strip('\n')
-            self.seeds.append(GKEY.make_packed(seed))
+            self.seeds.append(gkey.make_packed(seed))
             #except Exception as err:
                 #logger.debug("Seed: load; Error splitting seed: %s" % seed)
                 #logger.debug("Seed: load; ...............parts: %s" % str(parts))
@@ -115,6 +117,9 @@ class Seeds(object):
         '''
         if not kwargs:
             return self.seeds
+        if kwargs['nick'] == '*':
+            return self.seeds[:]
+        # proceed with the search
         # discard any invalid keys
         keys = set(list(kwargs)).intersection(GKEY._fields)
         result = self.seeds[:]


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-07-16  0:50 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-07-16  0:50 UTC (permalink / raw
  To: gentoo-commits

commit:     e71301cf58574242e1e54e48ce5bf6060e995192
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 13 08:02:18 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jul 13 08:02:18 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=e71301cf

Move actions logic out to their own class.

---
 gkeys/actions.py | 282 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gkeys/cli.py     | 224 ++-----------------------------------------
 2 files changed, 291 insertions(+), 215 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
new file mode 100644
index 0000000..497ec38
--- /dev/null
+++ b/gkeys/actions.py
@@ -0,0 +1,282 @@
+#
+#-*- coding:utf-8 -*-
+
+"""
+    Gentoo-keys - actions.py
+
+    Primary api interface module
+
+    @copyright: 2012 by Brian Dolbec <dol-sen@gentoo.org>
+    @license: GNU GPL2, see COPYING for details.
+"""
+
+
+from gkeys.config import GKEY
+from gkeys.lib import GkeysGPG
+from gkeys.seed import Seeds
+
+
+
+
+
+class Actions(object):
+    '''Primary api actions'''
+
+    def __init__(self, config, output, logger=None):
+        self.config = config
+        self.output = output
+        self.logger = logger
+        self.seeds = None
+
+
+    @staticmethod
+    def build_gkeydict(args):
+        keyinfo = {}
+        for x in GKEY._fields:
+            try:
+                value = getattr(args, x)
+                if value:
+                    keyinfo[x] = value
+            except AttributeError:
+                pass
+        return keyinfo
+
+
+    @staticmethod
+    def build_gkeylist(args):
+        keyinfo = []
+        for x in GKEY._fields:
+            try:
+                keyinfo.append(getattr(args, x))
+            except AttributeError:
+                keyinfo.append(None)
+        return keyinfo
+
+
+    def load_seeds(self, filename):
+        if not filename:
+            self.logger.debug("ACTIONS: load_seeds; no filename to load: "
+            "%s" % filename)
+            return None
+        filepath = self.config.get_key(filename + "-seedfile")
+        self.logger.debug("ACTIONS: load_seeds; seeds filepath to load: "
+            "%s" % filepath)
+        seeds = Seeds()
+        seeds.load(filepath)
+        return seeds
+
+
+    def listseed(self, args):
+        '''Action listseed method'''
+        kwargs = self.build_gkeydict(args)
+        self.logger.debug("ACTIONS: listseed; kwargs: %s" % str(kwargs))
+        if not self.seeds:
+            self.seeds = self.load_seeds(args.seeds)
+        if self.seeds:
+            results = self.seeds.list(**kwargs)
+            return results
+        return None
+
+
+    def addseed(self, args):
+        '''Action addseed method'''
+        parts = self.build_gkeylist(args)
+        gkey = GKEY._make(parts)
+        self.logger.debug("ACTIONS: addseed; new gkey: %s" % str(gkey))
+        gkeys = self.listseed(args)
+        if len(gkeys) == 0:
+            self.logger.debug("ACTIONS: addkey; now adding gkey: %s" % str(gkey))
+            success = self.seeds.add(gkey)
+            if success:
+                success = self.seeds.save()
+                return ["Successfully Added new seed: %s" % str(success), gkey]
+        else:
+            messages = ["Matching seeds found in seeds file",
+                "Aborting... \nMatching seeds:"]
+            messages.extend(gkeys)
+            return messages
+
+
+    def removeseed(self, args):
+        '''Action removeseed method'''
+        parts = self.build_gkeylist(args)
+        searchkey = GKEY._make(parts)
+        self.logger.debug("ACTIONS: removeseed; gkey: %s" % str(searchkey))
+        gkeys = self.listseed(args)
+        if len(gkeys) == 1:
+            self.logger.debug("ACTIONS: removeseed; now deleting gkey: %s" % str(gkeys[0]))
+            success = self.seeds.delete(gkeys[0])
+            if success:
+                success = self.seeds.save()
+            return ["Successfully Removed seed: %s" % str(success),
+                gkeys[0]]
+        elif len(gkeys):
+            messages = ["Too many seeds found to remove"]
+            messages.extend(gkeys)
+            return messages
+        return ["Failed to Remove seed:", searchkey,
+            "No matching seed found"]
+
+
+    def moveseed(self, args):
+        '''Action moveseed method'''
+        parts = self.build_gkeylist(args)
+        searchkey = GKEY._make(parts)
+        self.logger.debug("ACTIONS: moveseed; gkey: %s" % str(searchkey))
+        if not self.seeds:
+            self.seeds = self.load_seeds(args.seeds)
+        kwargs = self.build_gkeydict(args)
+        sourcekeys = self.seeds.list(**kwargs)
+        dest = self.load_seeds(args.destination)
+        destkeys = dest.list(**kwargs)
+        messages = []
+        if len(sourcekeys) == 1 and destkeys == []:
+            self.logger.debug("ACTIONS: moveseed; now adding destination gkey: %s"
+                % str(sourcekeys[0]))
+            success = dest.add(sourcekeys[0])
+            self.logger.debug("ACTIONS: moveseed; success: %s" %str(success))
+            self.logger.debug("ACTIONS: moveseed; now deleting sourcekey: %s" % str(sourcekeys[0]))
+            success = self.seeds.delete(sourcekeys[0])
+            if success:
+                success = dest.save()
+                self.logger.debug("ACTIONS: moveseed; destination saved... %s" %str(success))
+                success = self.seeds.save()
+            messages.extend(["Successfully Moved %s seed: %s"
+                % (args.seeds, str(success)), sourcekeys[0]])
+            return messages
+        elif len(sourcekeys):
+            messages = ["Too many seeds found to move"]
+            messages.extend(sourcekeys)
+            return messages
+        messages.append("Failed to Move seed:")
+        messages.append(searchkey)
+        messages.append('\n')
+        messages.append("Source seeds found...")
+        messages.extend(sourcekeys or ["None\n"])
+        messages.append("Destination seeds found...")
+        messages.extend(destkeys or ["None\n"])
+        return messages
+
+
+    def listkey(self, args):
+        '''Action listskey method'''
+        self.seeds = self.load_seeds(args.seeds)
+        if self.seeds:
+            kwargs = self.build_gkeydict(args)
+            # get the desired seed
+            keyresults = self.seeds.list(**kwargs)
+            if keyresults and not args.nick == '*':
+                self.output(keyresults, "\n Found GKEY seeds:")
+            elif keyresults:
+                self.output(['all'], "\n Installed seeds:")
+            else:
+                self.logger.info("ACTIONS: listkey; "
+                    "Matching seed entry not found")
+                if args.nick:
+                    return {"Search failed for: %s" % args.nick: False}
+                elif args.name:
+                    return {"Search failed for: %s" % args.name: False}
+                else:
+                    return {"Search failed for search term": False}
+            # get confirmation
+            # fill in code here
+            keydir = self.config.get_key(args.seeds + "-keydir")
+            self.logger.debug("ACTIONS: addkey; keysdir = %s" % keydir)
+            self.gpg = GkeysGPG(self.config, keydir)
+            results = {}
+            #failed = []
+            for key in keyresults:
+                if not key.keyring and not args.nick == '*':
+                    self.logger.debug("ACTIONS: listkey; NO keyring... Ignoring")
+                    return {"Failed: No keyid's found for %s" % key.name : ''}
+                self.logger.debug("ACTIONS: listkey; listing keyring:")
+                self.logger.debug("ACTIONS: " + str(key.keyring))
+                results[key.name] = self.gpg.list_keys(key.keyring)
+                for result in results[key.name]:
+                    self.logger.debug("ACTIONS: listkey; result.failed = " +
+                        str(result.failed))
+                if self.config.options['print_results']:
+                    for result in results[key.name]:
+                        print("key desired:", key.name, ", keyring listed:",
+                            result.username, ", keyid:", result.keyid,
+                            ", fingerprint:", result.fingerprint)
+                        self.logger.debug("stderr_out: " + str(result.stderr_out))
+        return {"No keyrings to list": False}
+
+
+    def addkey(self, args):
+        '''Action addkey method'''
+        kwargs = self.build_gkeydict(args)
+        self.logger.debug("ACTIONS: listseed; kwargs: %s" % str(kwargs))
+        self.seeds = self.load_seeds(args.seeds)
+        if self.seeds:
+            # get the desired seed
+            keyresults = self.seeds.list(**kwargs)
+            if keyresults and not args.nick == '*':
+                self.output(keyresults, "\n Found GKEY seeds:")
+            elif keyresults:
+                self.output(['all'], "\n Installing seeds:")
+            else:
+                self.logger.info("ACTIONS: addkey; "
+                    "Matching seed entry not found")
+                if args.nick:
+                    return {"Search failed for: %s" % args.nick: False}
+                elif args.name:
+                    return {"Search failed for: %s" % args.name: False}
+                else:
+                    return {"Search failed for search term": False}
+            # get confirmation
+            # fill in code here
+            keydir = self.config.get_key(args.seeds + "-keydir")
+            self.logger.debug("ACTIONS: addkey; keysdir = %s" % keydir)
+            self.gpg = GkeysGPG(self.config, keydir)
+            results = {}
+            failed = []
+            for key in keyresults:
+                if not key.keyid and not key.longkeyid and not args.nick == '*':
+                    self.logger.debug("ACTIONS: addkey; NO key id's to add... Ignoring")
+                    return {"Failed: No keyid's found for %s" % key.name : ''}
+                elif not key.keyid and not key.longkeyid:
+                    print("No keyid's found for:", key.nick, key.name, "Skipping...")
+                    failed.append(key)
+                    continue
+                self.logger.debug("ACTIONS: addkey; adding key:")
+                self.logger.debug("ACTIONS: " + str(key))
+                results[key.name] = self.gpg.add_key(key)
+                for result in results[key.name]:
+                    self.logger.debug("ACTIONS: addkey; result.failed = " +
+                        str(result.failed))
+                if self.config.options['print_results']:
+                    for result in results[key.name]:
+                        print("key desired:", key.name, ", key added:",
+                            result.username, ", succeeded:",
+                            not result.failed, ", keyid:", result.keyid,
+                            ", fingerprint:", result.fingerprint)
+                        self.logger.debug("stderr_out: " + str(result.stderr_out))
+                        if result.failed:
+                            failed.append(key)
+            if failed:
+                self.output(failed, "\n Failed to install:")
+            return {'Completed'}
+        return {"No seeds to search or install": False}
+
+
+    def removekey(self, args):
+        '''Action removekey method'''
+        pass
+
+
+    def movekey(self, args):
+        '''Action movekey method'''
+        pass
+
+
+    def user_confirm(self, message):
+        '''Get input from the user to confirm to proceed
+        with the desired action
+
+        @param message: string, user promt message to display
+        @return boolean: confirmation to proceed or abort
+        '''
+        pass
+

diff --git a/gkeys/cli.py b/gkeys/cli.py
index 2522531..36592d5 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -23,10 +23,8 @@ from gkeys import config
 from gkeys import seed
 from gkeys import lib
 
-from gkeys.config import GKeysConfig, GKEY
-from gkeys.seed import Seeds
-from gkeys.lib import GkeysGPG
-
+from gkeys.config import GKeysConfig
+from gkeys.actions import Actions
 
 
 
@@ -41,9 +39,10 @@ class Main(object):
         """
         self.root = root or "/"
         self.config = config or GKeysConfig(root=root)
-        self.print_results = print_results
+        self.config.options['print_results'] = print_results
         self.args = None
         self.seeds = None
+        self.actions = None
 
 
     def __call__(self, args=None):
@@ -130,15 +129,18 @@ class Main(object):
             logger.debug("Main: run; Found alternate config request: %s"
                 % args.config)
 
+        # establish our actions instance
+        self.actions = Actions(self.config, self.output_results, logger)
+
         # run the action
-        func = getattr(self, '_action_%s' % args.action)
+        func = getattr(self.actions, '%s' % args.action)
         logger.debug('Main: run; Found action: %s' % args.action)
         results = func(args)
         if not results:
             print("No results found.  Check your configuration and that the",
                 "seed file exists.")
             return
-        if self.print_results and 'done' not in list(results):
+        if self.config.options['print_results'] and 'done' not in list(results):
             self.output_results(results, '\n Gkey task results:')
             print()
 
@@ -150,214 +152,6 @@ class Main(object):
         print("\n".join([str(x) for x in results]))
 
 
-    @staticmethod
-    def build_gkeydict(args):
-        keyinfo = {}
-        for x in GKEY._fields:
-            try:
-                value = getattr(args, x)
-                if value:
-                    keyinfo[x] = value
-            except AttributeError:
-                pass
-        return keyinfo
-
-
-    @staticmethod
-    def build_gkeylist(args):
-        keyinfo = []
-        for x in GKEY._fields:
-            try:
-                keyinfo.append(getattr(args, x))
-            except AttributeError:
-                keyinfo.append(None)
-        return keyinfo
-
-
-    def _load_seeds(self, filename):
-        if not filename:
-            return None
-        filepath = self.config.get_key(filename + "-seedfile")
-        logger.debug("MAIN: _load_seeds; seeds filepath to load: "
-            "%s" % filepath)
-        seeds = Seeds()
-        seeds.load(filepath)
-        return seeds
-
-
-    def _action_listseed(self, args):
-        '''Action listseed method'''
-        kwargs = self.build_gkeydict(args)
-        logger.debug("MAIN: _action_listseed; kwargs: %s" % str(kwargs))
-        if not self.seeds:
-            self.seeds = self._load_seeds(args.seeds)
-        if self.seeds:
-            results = self.seeds.list(**kwargs)
-            return results
-        return None
-
-
-    def _action_addseed(self, args):
-        '''Action addseed method'''
-        parts = self.build_gkeylist(args)
-        gkey = GKEY._make(parts)
-        logger.debug("MAIN: _action_addseed; new gkey: %s" % str(gkey))
-        gkeys = self._action_listseed(args)
-        if len(gkeys) == 0:
-            logger.debug("MAIN: _action_addkey; now adding gkey: %s" % str(gkey))
-            success = self.seeds.add(gkey)
-            if success:
-                success = self.seeds.save()
-                return ["Successfully Added new seed: %s" % str(success), gkey]
-        else:
-            messages = ["Matching seeds found in seeds file",
-                "Aborting... \nMatching seeds:"]
-            messages.extend(gkeys)
-            return messages
-
-
-    def _action_removeseed(self, args):
-        '''Action removeseed method'''
-        parts = self.build_gkeylist(args)
-        searchkey = GKEY._make(parts)
-        logger.debug("MAIN: _action_removeseed; gkey: %s" % str(searchkey))
-        gkeys = self._action_listseed(args)
-        if len(gkeys) == 1:
-            logger.debug("MAIN: _action_removeseed; now deleting gkey: %s" % str(gkeys[0]))
-            success = self.seeds.delete(gkeys[0])
-            if success:
-                success = self.seeds.save()
-            return ["Successfully Removed seed: %s" % str(success),
-                gkeys[0]]
-        elif len(gkeys):
-            messages = ["Too many seeds found to remove"]
-            messages.extend(gkeys)
-            return messages
-        return ["Failed to Remove seed:", searchkey,
-            "No matching seed found"]
-
-
-    def _action_moveseed(self, args):
-        '''Action moveseed method'''
-        parts = self.build_gkeylist(args)
-        searchkey = GKEY._make(parts)
-        logger.debug("MAIN: _action_moveseed; gkey: %s" % str(searchkey))
-        if not self.seeds:
-            self.seeds = self._load_seeds(args.seeds)
-        kwargs = self.build_gkeydict(args)
-        sourcekeys = self.seeds.list(**kwargs)
-        dest = self._load_seeds(args.destination)
-        destkeys = dest.list(**kwargs)
-        messages = []
-        if len(sourcekeys) == 1 and destkeys == []:
-            logger.debug("MAIN: _action_moveseed; now adding destination gkey: %s"
-                % str(sourcekeys[0]))
-            success = dest.add(sourcekeys[0])
-            logger.debug("MAIN: _action_moveseed; success: %s" %str(success))
-            logger.debug("MAIN: _action_moveseed; now deleting sourcekey: %s" % str(sourcekeys[0]))
-            success = self.seeds.delete(sourcekeys[0])
-            if success:
-                success = dest.save()
-                logger.debug("MAIN: _action_moveseed; destination saved... %s" %str(success))
-                success = self.seeds.save()
-            messages.extend(["Successfully Moved %s seed: %s"
-                % (args.seeds, str(success)), sourcekeys[0]])
-            return messages
-        elif len(sourcekeys):
-            messages = ["Too many seeds found to move"]
-            messages.extend(sourcekeys)
-            return messages
-        messages.append("Failed to Move seed:")
-        messages.append(searchkey)
-        messages.append('\n')
-        messages.append("Source seeds found...")
-        messages.extend(sourcekeys or ["None\n"])
-        messages.append("Destination seeds found...")
-        messages.extend(destkeys or ["None\n"])
-        return messages
-
-
-    def _action_listkey(self, args):
-        '''Action listskey method'''
-        pass
-
-
-    def _action_addkey(self, args):
-        '''Action addkey method'''
-        kwargs = self.build_gkeydict(args)
-        logger.debug("MAIN: _action_listseed; kwargs: %s" % str(kwargs))
-        self.seeds = self._load_seeds(args.seeds)
-        if self.seeds:
-            # get the desired seed
-            keyresults = self.seeds.list(**kwargs)
-            if keyresults and not args.nick == '*':
-                self.output_results(keyresults, "\n Found GKEY seeds:")
-            elif keyresults:
-                self.output_results(['all'], "\n Installing seeds:")
-            else:
-                logger.info("MAIN: _action_addkey; "
-                    "Matching seed entry not found")
-                if args.nick:
-                    return {"Search failed for: %s" % args.nick: False}
-                elif args.name:
-                    return {"Search failed for: %s" % args.name: False}
-                else:
-                    return {"Search failed for search term": False}
-            # get confirmation
-            # fill in code here
-            keydir = self.config.get_key(args.seeds + "-keydir")
-            logger.debug("MAIN: _action_addkey; keysdir = %s" % keydir)
-            self.gpg = GkeysGPG(self.config, keydir)
-            results = {}
-            failed = []
-            for key in keyresults:
-                if not key.keyid and not key.longkeyid and not args.nick == '*':
-                    logger.debug("MAIN: _action_addkey; NO key id's to add... Ignoring")
-                    return {"Failed: No keyid's found for %s" % key.name : ''}
-                elif not key.keyid and not key.longkeyid:
-                    print("No keyid's found for:", key.nick, key.name, "Skipping...")
-                    failed.append(key)
-                    continue
-                logger.debug("MAIN: _action_addkey; adding key:")
-                logger.debug("MAIN: " + str(key))
-                results[key.name] = self.gpg.add_key(key)
-                for result in results[key.name]:
-                    logger.debug("MAIN: _action_addkey; result.failed = " +
-                        str(result.failed))
-                if self.print_results:
-                    for result in results[key.name]:
-                        print("key desired:", key.name, ", key added:",
-                            result.username, ", succeeded:",
-                            not result.failed, ", keyid:", result.keyid,
-                            ", fingerprint:", result.fingerprint)
-                        logger.debug("stderr_out: " + str(result.stderr_out))
-                        if result.failed:
-                            failed.append(key)
-            if failed:
-                self.output_results(failed, "\n Failed to install:")
-            return {'Completed'}
-        return {"No seeds to search or install": False}
-
-
-    def _action_removekey(self, args):
-        '''Action removekey method'''
-        pass
-
-
-    def _action_movekey(self, args):
-        '''Action movekey method'''
-        pass
-
-
-    def user_confirm(self, message):
-        '''Get input from the user to confirm to proceed
-        with the desired action
-
-        @param message: string, user promt message to display
-        @return boolean: confirmation to proceed or abort
-        '''
-        pass
-
 
     def output_failed(self, failed):
         pass


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-07-16  0:50 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-07-16  0:50 UTC (permalink / raw
  To: gentoo-commits

commit:     04aecf5d8886ce4fd7c61507b97fe5c823bc0bc2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jul  7 14:13:40 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jul  7 14:13:40 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=04aecf5d

Clean out uneeded code

---
 gkeys/config.py | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/gkeys/config.py b/gkeys/config.py
index 50d43c6..5bdf883 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -94,18 +94,6 @@ class GKeysConfig(GPGConfig):
             return self.configparser.get('MAIN', key)
         else:
             return super(GKeysConfig, self)._get_(key, subkey)
-        #elif key in self.options:
-            #logger.debug("Found %s in options... %s"
-                #% (key, str(self.options[key])))
-            #return self.options[key]
-        #elif key in self.defaults:
-            #logger.debug("type(key)= %s" %str(type(self.defaults[key])))
-            #logger.debug("Found %s in defaults... %s"
-                #% (key, str(self.defaults[key])))
-            #logger.debug("type(key)= %s" %str(type(self.defaults[key])))
-            #return self.defaults[key]
-        #logger.error("GKeysConfig: _get_; didn't find :", key)
-        #return None
 
 
 class GKEY(namedtuple('GKEY', ['nick', 'name', 'keyid', 'longkeyid',


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-07-16  0:50 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-07-16  0:50 UTC (permalink / raw
  To: gentoo-commits

commit:     12b79457cb5551fdd8aaa80eeb1e6d8ff5f80e06
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 06:01:47 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jul 14 17:15:10 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=12b79457

More Actions improvements.

---
 gkeys/actions.py | 51 ++++++++++++++++++++++++++++++++-------------------
 gkeys/cli.py     |  6 +++---
 2 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 497ec38..9873362 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -10,19 +10,22 @@
     @license: GNU GPL2, see COPYING for details.
 """
 
+from __future__ import print_function
+
 
 from gkeys.config import GKEY
 from gkeys.lib import GkeysGPG
 from gkeys.seed import Seeds
 
 
-
+Avialable_Actions = ['listseed', 'addseed', 'removeseed', 'moveseed', 'listkey',
+            'addkey', 'removekey', 'movekey', 'installed']
 
 
 class Actions(object):
     '''Primary api actions'''
 
-    def __init__(self, config, output, logger=None):
+    def __init__(self, config, output=None, logger=None):
         self.config = config
         self.output = output
         self.logger = logger
@@ -165,9 +168,9 @@ class Actions(object):
             kwargs = self.build_gkeydict(args)
             # get the desired seed
             keyresults = self.seeds.list(**kwargs)
-            if keyresults and not args.nick == '*':
+            if keyresults and not args.nick == '*' and self.output:
                 self.output(keyresults, "\n Found GKEY seeds:")
-            elif keyresults:
+            elif keyresults and self.output:
                 self.output(['all'], "\n Installed seeds:")
             else:
                 self.logger.info("ACTIONS: listkey; "
@@ -181,27 +184,31 @@ class Actions(object):
             # get confirmation
             # fill in code here
             keydir = self.config.get_key(args.seeds + "-keydir")
-            self.logger.debug("ACTIONS: addkey; keysdir = %s" % keydir)
+            self.logger.debug("ACTIONS: listkey; keysdir = %s" % keydir)
             self.gpg = GkeysGPG(self.config, keydir)
             results = {}
             #failed = []
+            print(" GPG output:")
             for key in keyresults:
                 if not key.keyring and not args.nick == '*':
                     self.logger.debug("ACTIONS: listkey; NO keyring... Ignoring")
                     return {"Failed: No keyid's found for %s" % key.name : ''}
-                self.logger.debug("ACTIONS: listkey; listing keyring:")
-                self.logger.debug("ACTIONS: " + str(key.keyring))
+                self.logger.debug("ACTIONS: listkey; listing keyring:"
+                    + str(key.keyring))
                 results[key.name] = self.gpg.list_keys(key.keyring)
-                for result in results[key.name]:
-                    self.logger.debug("ACTIONS: listkey; result.failed = " +
-                        str(result.failed))
                 if self.config.options['print_results']:
-                    for result in results[key.name]:
-                        print("key desired:", key.name, ", keyring listed:",
-                            result.username, ", keyid:", result.keyid,
-                            ", fingerprint:", result.fingerprint)
-                        self.logger.debug("stderr_out: " + str(result.stderr_out))
-        return {"No keyrings to list": False}
+                    print(results[key.name].output)
+                    self.logger.debug("data output:\n" +
+                        str(results[key.name].output))
+                    #for result in results[key.name].status.data:
+                        #print("key desired:", key.name, ", keyring listed:",
+                            #result)
+                        #self.logger.debug("data record: " + str(result))
+                else:
+                    return results
+            return {'done': True}
+        else:
+            return {"No keyrings to list": False}
 
 
     def addkey(self, args):
@@ -212,9 +219,9 @@ class Actions(object):
         if self.seeds:
             # get the desired seed
             keyresults = self.seeds.list(**kwargs)
-            if keyresults and not args.nick == '*':
+            if keyresults and not args.nick == '*' and self.output:
                 self.output(keyresults, "\n Found GKEY seeds:")
-            elif keyresults:
+            elif keyresults and self.output:
                 self.output(['all'], "\n Installing seeds:")
             else:
                 self.logger.info("ACTIONS: addkey; "
@@ -255,7 +262,7 @@ class Actions(object):
                         self.logger.debug("stderr_out: " + str(result.stderr_out))
                         if result.failed:
                             failed.append(key)
-            if failed:
+            if failed and self.output:
                 self.output(failed, "\n Failed to install:")
             return {'Completed'}
         return {"No seeds to search or install": False}
@@ -271,6 +278,12 @@ class Actions(object):
         pass
 
 
+    def installed(self, args):
+        '''Action installed method.
+        lists the installed key directories'''
+        pass
+
+
     def user_confirm(self, message):
         '''Get input from the user to confirm to proceed
         with the desired action

diff --git a/gkeys/cli.py b/gkeys/cli.py
index 36592d5..d34ed4d 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -24,7 +24,7 @@ from gkeys import seed
 from gkeys import lib
 
 from gkeys.config import GKeysConfig
-from gkeys.actions import Actions
+from gkeys.actions import Actions, Avialable_Actions
 
 
 
@@ -59,8 +59,7 @@ class Main(object):
         @returns argparse.Namespace object
         '''
         #logger.debug('MAIN: parse_args; args: %s' % args)
-        actions = ['listseed', 'addseed', 'removeseed', 'moveseed', 'listkey',
-            'addkey', 'removekey', 'movekey']
+        actions = Avialable_Actions
         parser = argparse.ArgumentParser(
             prog='gkeys',
             description='Gentoo-keys manager program',
@@ -150,6 +149,7 @@ class Main(object):
         # super simple output for the time being
         print(header)
         print("\n".join([str(x) for x in results]))
+        print()
 
 
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-07-16  0:50 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-07-16  0:50 UTC (permalink / raw
  To: gentoo-commits

commit:     c7c2cd9758351b873324b5faaf06e2a34f39b22d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 06:04:26 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jul 14 17:15:22 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=c7c2cd97

Split out common keypath code to it's own function

Add a reset task() to clear/reset additional args.
Code list_keys()

---
 gkeys/lib.py | 58 ++++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 44 insertions(+), 14 deletions(-)

diff --git a/gkeys/lib.py b/gkeys/lib.py
index cae7f07..0f7ae5e 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -36,6 +36,28 @@ class GkeysGPG(GPG):
         GPG.__init__(self, config)
         self.config = config
         self.keydir = keydir
+        self.task = None
+        self.task_value = None
+
+
+    def set_keypath(self, keyring, task=None):
+        logger.debug("keydir: %s, keyring: %s" % (self.keydir, keyring))
+        self.task = task
+        keypath = pjoin(self.keydir, keyring)
+        # --keyring file |  Note that this adds a keyring to the current list.
+        # If the intent is to use the specified keyring alone,
+        # use  --keyring  along with --no-default-keyring.
+        self.task_value = ['--no-default-keyring', '--keyring', keypath]
+        task.extend(self.task_value)
+        return
+
+
+    def reset_task(self):
+        if self.task:
+            for item in self.task_value:
+                self.task.remove(item)
+            self.task = None
+            self.task_value = None
 
 
     def add_key(self, gkey):
@@ -44,14 +66,8 @@ class GkeysGPG(GPG):
         @param gkey: GKEY namedtuple with
             (name, keyid/longkeyid, keyring, fingerprint,)
         '''
-        logger.debug("keydir: %s, keyring: %s" % (self.keydir, gkey.keyring))
-        keypath = pjoin(self.keydir, gkey.keyring)
-        # --keyring file |  Note that this adds a keyring to the current list.
-        # If the intent is to use the specified keyring alone,
-        # use  --keyring  along with --no-default-keyring.
-        self.config['tasks']['recv-keys'] = [
-            '--no-default-keyring', '--keyring', keypath,
-            ]
+        self.set_keypath(gkey.keyring, self.config['tasks']['recv-keys'])
+
         # prefer the longkeyid if available
         #logger.debug("LIB: add_key; keyids %s, %s"
         #    % (str(gkey.longkeyid), str(gkey.keyid)))
@@ -94,13 +110,13 @@ class GkeysGPG(GPG):
 
         @param gkey: GKEY namedtuple with (name, keyid/longkeyid, fingerprint)
         '''
-        pass
+        return []
 
 
     def del_keyring(self, keyring):
         '''Delete the specified key to the specified keyring
         '''
-        pass
+        return []
 
 
     def update_key(self, gkey, keyring):
@@ -109,22 +125,36 @@ class GkeysGPG(GPG):
         @param key: tuple of (name, keyid, fingerprint)
         @param keyring: the keyring to add the key to
         '''
-        pass
+        return []
 
 
-    def list_keys(self, keyring=None):
+    def list_keys(self, keyring):
         '''List all keys in the specified keyring or
         all key in all keyrings if keyring=None
 
         @param keyring: the keyring to add the key to
         '''
-        pass
+        if not keyring:
+            logger.debug("LIB: list_keys(), invalid keyring parameter: %s"
+                % str(keyring))
+            return []
+        if '--with-colons' in self.config['tasks']['list-keys']:
+            self.config['tasks']['list-keys'].remove('--with-colons')
+
+        self.set_keypath(keyring, self.config['tasks']['list-keys'])
+        logger.debug("** Calling runGPG with Running 'gpg %s --list-keys %s'"
+            % (' '.join(self.config['tasks']['list-keys']), keyring)
+            )
+        result = self.runGPG(task='list-keys', inputfile=keyring)
+        logger.info('GPG return code: ' + str(result.returncode))
+        self.reset_task()
+        return result
 
 
     def list_keyrings(self):
         '''List all available keyrings
         '''
-        pass
+        return []
 
 
     def verify_key(self, gkey):


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-07-16  0:50 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-07-16  0:50 UTC (permalink / raw
  To: gentoo-commits

commit:     642aa30bf441dfd978800208d6d931bc56ecb1c6
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 16 00:49:30 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Jul 16 00:49:30 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=642aa30b

Upadte for the new pyGPG pkg name.

---
 gkeys/config.py | 2 +-
 gkeys/lib.py    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gkeys/config.py b/gkeys/config.py
index 5bdf883..043f84f 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -15,7 +15,7 @@ import ConfigParser
 from collections import namedtuple
 
 
-from pygpg.config import GPGConfig
+from pyGPG.config import GPGConfig
 
 from gkeys import log
 from gkeys.utils import path

diff --git a/gkeys/lib.py b/gkeys/lib.py
index 0f7ae5e..0420f7c 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -18,7 +18,7 @@ with gentoo-keys specific convienience functions.
 
 from os.path import join as pjoin
 
-from pygpg.gpg import GPG
+from pyGPG.gpg import GPG
 from gkeys.log import logger
 
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-11-15  9:16 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-11-15  9:16 UTC (permalink / raw
  To: gentoo-commits

commit:     49dbdbcb13f4c399651592fb880397e43f30e4bd
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 15 09:11:09 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Nov 15 09:14:34 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=49dbdbcb

Add some addition defaults to begin coding the fetching and scanning for seed files known to gkeys.

---
 gkeys/config.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gkeys/config.py b/gkeys/config.py
index 20a00b7..5fe3871 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -65,11 +65,18 @@ class GKeysConfig(GPGConfig):
         self.defaults['dev-keydir'] = '%(keysdir)s/devs'
         self.defaults['release-keydir'] = '%(keysdir)s/release'
         self.defaults['overlays-keydir'] = '%(keysdir)s/overlays'
+        # known-keysfile is a repositories.xml like file of gpg seeds
+        # distributed through api.g.o for convenience
         self.defaults['known-keysfile'] = '%(keysdir)s/knownkeys'
         self.defaults['release-seedfile'] = '%(configdir)s/release.seeds'
         self.defaults['dev-seedfile'] = '%(configdir)s/developer.seeds'
+        # local directory to scan for seed files installed via ebuild, layman
+        # or manual install.
+        self.defaults['installable-seeddir'] = '%(configdir)s/installable.seeds'
         self.defaults['keyserver'] = 'pool.sks-keyservers.net'
-
+        self.defaults['dev-seedurl'] = 'http://dev.gentoo.org/~dolsen/gkey-seeds/developer.seeds'
+        self.defaults['release-seedurl'] = 'http://dev.gentoo.org/~dolsen/gkey-seeds/release.seeds'
+        self.defaults['known-seedurl'] = 'http://dev.gentoo.org/~dolsen/gkey-seeds/known.seeds'
 
 
     def read_config(self):


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-11-17  7:39 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-11-17  7:39 UTC (permalink / raw
  To: gentoo-commits

commit:     d12a8cedc1c4da1580b01991344a4a6d6b5f46ba
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 16 20:02:47 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Nov 16 20:29:19 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=d12a8ced

fix python compatibility

---
 gkeys/lib.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gkeys/lib.py b/gkeys/lib.py
index 66e27dc..80dedb6 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -16,6 +16,10 @@ with gentoo-keys specific convienience functions.
 
 '''
 
+# for py 2.6 compatibility
+from __future__ import print_function
+
+
 import os
 from os.path import join as pjoin
 
@@ -93,7 +97,7 @@ class GkeysGPG(GPG):
         self.set_keydir(gkey.keydir, 'recv-keys', reset=True)
         self.set_keyring('pubring.gpg', 'recv-keys', reset=False)
         if not os.path.exists(self.keydir):
-            os.makedirs(self.keydir, mode=0700)
+            os.makedirs(self.keydir, mode=0x0700)
 
         # prefer the longkeyid if available
         #logger.debug("LIB: add_key; keyids %s, %s"
@@ -128,7 +132,7 @@ class GkeysGPG(GPG):
                 message += "\n     gkey..: %s" %(str(gkey.fingerprint))
                 logger.error(message)
             results.append(result)
-            print result.stderr_out
+            print(result.stderr_out)
         return results
 
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-11-17  7:39 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-11-17  7:39 UTC (permalink / raw
  To: gentoo-commits

commit:     e28107578761c7bf719742ce54442ff5d0914b21
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 16 20:00:27 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Nov 16 20:00:27 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=e2810757

fix attribute error for newer pythons

---
 gkeys/utils.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/gkeys/utils.py b/gkeys/utils.py
index 0cbcdea..b1fb69b 100644
--- a/gkeys/utils.py
+++ b/gkeys/utils.py
@@ -22,11 +22,18 @@ Utility functions'''
 
 
 
-import types, re, os
+import types
+import re
+import os
 import sys
 import locale
 import codecs
 
+try:
+    StringTypes = types.StringTypes
+except AttributeError:
+    StringTypes = [str]
+
 
 def encoder(text, _encoding_):
     return codecs.encode(text, _encoding_, 'replace')
@@ -132,7 +139,7 @@ def path(path_elements):
     '''
     pathname = ''
 
-    if type(path_elements) in types.StringTypes:
+    if type(path_elements) in StringTypes:
         path_elements = [path_elements]
 
     # Concatenate elements and seperate with /


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-11-17  7:39 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-11-17  7:39 UTC (permalink / raw
  To: gentoo-commits

commit:     6eb06fe32725b8985c9971c70f00c2c69f1e371b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 16 20:07:11 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Nov 16 20:29:26 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=6eb06fe3

Initial creation of the SeedHandler class.

Move the relavent code from gkeys/actions.py to the the new SeedHandler class.

---
 gkeys/actions.py     |  53 +++++++-------------
 gkeys/seedhandler.py | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 154 insertions(+), 36 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 2c1f76d..13031e5 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -13,7 +13,7 @@
 from __future__ import print_function
 
 
-from gkeys.config import GKEY
+from gkeys.seedhandler import SeedHandler
 from gkeys.lib import GkeysGPG
 from gkeys.seed import Seeds
 
@@ -32,30 +32,6 @@ class Actions(object):
         self.seeds = None
 
 
-    @staticmethod
-    def build_gkeydict(args):
-        keyinfo = {}
-        for x in GKEY._fields:
-            try:
-                value = getattr(args, x)
-                if value:
-                    keyinfo[x] = value
-            except AttributeError:
-                pass
-        return keyinfo
-
-
-    @staticmethod
-    def build_gkeylist(args):
-        keyinfo = []
-        for x in GKEY._fields:
-            try:
-                keyinfo.append(getattr(args, x))
-            except AttributeError:
-                keyinfo.append(None)
-        return keyinfo
-
-
     def load_seeds(self, filename):
         if not filename:
             self.logger.debug("ACTIONS: load_seeds; no filename to load: "
@@ -71,7 +47,8 @@ class Actions(object):
 
     def listseed(self, args):
         '''Action listseed method'''
-        kwargs = self.build_gkeydict(args)
+        handler = SeedHandler(self.logger)
+        kwargs = handler.build_gkeydict(args)
         self.logger.debug("ACTIONS: listseed; kwargs: %s" % str(kwargs))
         if not self.seeds:
             self.seeds = self.load_seeds(args.seeds)
@@ -83,9 +60,8 @@ class Actions(object):
 
     def addseed(self, args):
         '''Action addseed method'''
-        parts = self.build_gkeylist(args)
-        gkey = GKEY._make(parts)
-        self.logger.debug("ACTIONS: addseed; new gkey: %s" % str(gkey))
+        handler = SeedHandler(self.logger)
+        gkey = handler.new(args)
         gkeys = self.listseed(args)
         if len(gkeys) == 0:
             self.logger.debug("ACTIONS: addkey; now adding gkey: %s" % str(gkey))
@@ -102,10 +78,13 @@ class Actions(object):
 
     def removeseed(self, args):
         '''Action removeseed method'''
-        parts = self.build_gkeylist(args)
-        searchkey = GKEY._make(parts)
+        handler = SeedHandler(self.logger)
+        searchkey = handler.new(args, needkeyid=False, checkintegrity=False)
         self.logger.debug("ACTIONS: removeseed; gkey: %s" % str(searchkey))
         gkeys = self.listseed(args)
+        if not gkeys:
+            return ["Failed to Removed seed: No gkeys returned from listseed()",
+                None]
         if len(gkeys) == 1:
             self.logger.debug("ACTIONS: removeseed; now deleting gkey: %s" % str(gkeys[0]))
             success = self.seeds.delete(gkeys[0])
@@ -123,12 +102,12 @@ class Actions(object):
 
     def moveseed(self, args):
         '''Action moveseed method'''
-        parts = self.build_gkeylist(args)
-        searchkey = GKEY._make(parts)
+        handler = SeedHandler(self.logger)
+        searchkey = handler.new(args, needkeyid=False, checkintegrity=False)
         self.logger.debug("ACTIONS: moveseed; gkey: %s" % str(searchkey))
         if not self.seeds:
             self.seeds = self.load_seeds(args.seeds)
-        kwargs = self.build_gkeydict(args)
+        kwargs = handler.build_gkeydict(args)
         sourcekeys = self.seeds.list(**kwargs)
         dest = self.load_seeds(args.destination)
         destkeys = dest.list(**kwargs)
@@ -165,7 +144,8 @@ class Actions(object):
         '''Action listskey method'''
         self.seeds = self.load_seeds(args.seeds)
         if self.seeds:
-            kwargs = self.build_gkeydict(args)
+            handler = SeedHandler(self.logger)
+            kwargs = handler.build_gkeydict(args)
             # get the desired seed
             keyresults = self.seeds.list(**kwargs)
             if keyresults and not args.nick == '*' and self.output:
@@ -213,7 +193,8 @@ class Actions(object):
 
     def addkey(self, args):
         '''Action addkey method'''
-        kwargs = self.build_gkeydict(args)
+        handler = SeedHandler(self.logger)
+        kwargs = handler.build_gkeydict(args)
         self.logger.debug("ACTIONS: listseed; kwargs: %s" % str(kwargs))
         self.seeds = self.load_seeds(args.seeds)
         if self.seeds:

diff --git a/gkeys/seedhandler.py b/gkeys/seedhandler.py
new file mode 100644
index 0000000..af1fbaa
--- /dev/null
+++ b/gkeys/seedhandler.py
@@ -0,0 +1,137 @@
+#
+#-*- coding:utf-8 -*-
+
+"""
+    Gentoo-keys - seedhandler.py
+
+    Seed handling interface module
+
+    @copyright: 2012 by Brian Dolbec <dol-sen@gentoo.org>
+    @license: GNU GPL2, see COPYING for details.
+"""
+
+import re
+
+from gkeys.config import (GKEY, NICK, NAME, KEYID, LONGKEYID, FINGERPRINT,
+    KEY_LEN)
+
+
+class SeedHandler(object):
+
+
+    def __init__(self,logger):
+        self.logger = logger
+        self.fingerprint_re = re.compile('[0-9A-Fa-f]{40}')
+
+
+    def new(self, args, needkeyid=True, checkintegrity=True):
+        parts = self.build_gkeylist(args, needkeyid, checkintegrity)
+        gkey = GKEY._make(parts)
+        self.logger.debug("SeedHandler: new() new gkey: %s" % str(gkey))
+        return gkey
+
+
+    @staticmethod
+    def build_gkeydict(args):
+        keyinfo = {}
+        for x in GKEY._fields:
+            try:
+                value = getattr(args, x)
+                if value:
+                    keyinfo[x] = value
+            except AttributeError:
+                pass
+        return keyinfo
+
+
+    def build_gkeylist(self, args, needkeyid=True, checkintegrity=True):
+        keyinfo = []
+        keyid_found = False
+        # assume it's good until an error is found
+        is_good = True
+        #self.logger.debug("SeedHandler: build_gkeylist; args = %s" % str(args))
+        for x in GKEY._fields:
+            if GKEY.field_types[x] is str:
+                try:
+                    value = getattr(args, x)
+                except AttributeError:
+                    value = None
+            elif GKEY.field_types[x] is list:
+                try:
+                    value = [y for y in getattr(args, x).split()]
+                except AttributeError:
+                    value = None
+            keyinfo.append(value)
+            if x in ["keyid", "longkeyid"] and value:
+                keyid_found = True
+        if not keyid_found and needkeyid:
+            fingerprint = keyinfo[FINGERPRINT]
+            if fingerprint:
+                self.logger.debug('  Generate gpgkey longkeyid, Found '
+                    'fingerprint in args')
+                # assign it to gpgkey to prevent a possible
+                # "gpgkey" undefined error
+                gpgkey = ['0x' + x[-KEY_LEN['longkeyid']:] for x in fingerprint]
+                keyinfo[LONGKEYID] = gpgkey
+                self.logger.debug('  Generate gpgkey longkeyid, NEW '
+                    'keyinfo[LONGKEYID] = %s' % str(keyinfo[LONGKEYID]))
+            else:
+                gpgkey = 'Missing or Bad fingerprint from command line args'
+                is_good = False
+            if not keyinfo[LONGKEYID]:
+                self.logger.error('ERROR in seed creation info for: %s, %s'
+                    %(keyinfo[NICK], keyinfo[NAME]))
+                self.logger.error('  A valid keyid, longkeyid or fingerprint '
+                    'was not found for %s : gpgkey = %s'
+                    %(keyinfo[NAME], gpgkey))
+                is_good = False
+        if is_good:
+            if keyinfo[FINGERPRINT]: # fingerprints exist check
+                is_ok = self._check_fingerprint_integrity(keyinfo)
+                is_match = self._check_id_fingerprint_match(keyinfo)
+                if not is_ok or not is_match:
+                    is_good = False
+        if is_good:
+            return keyinfo
+        return None
+
+
+    def _check_id_fingerprint_match(self, keyinfo):
+        # assume it's good until found an error is found
+        is_good = True
+        for x in [KEYID, LONGKEYID]:
+            # skip blank id field
+            if not keyinfo[x]:
+                continue
+            for y in keyinfo[x]:
+                index = len(y.lstrip('0x'))
+                if y.lstrip('0x').upper() not in \
+                        [x[-index:].upper() for x in keyinfo[FINGERPRINT]]:
+                    self.logger.error('ERROR in ldap info for: %s, %s'
+                        %(keyinfo[NICK], keyinfo[NAME]))
+                    self.logger.error('  ' + str(keyinfo))
+                    self.logger.error('  GPGKey id %s not found in the '
+                        % y.lstrip('0x') + 'listed fingerprint(s)')
+                    is_good = False
+        return is_good
+
+
+    def _check_fingerprint_integrity(self, keyinfo):
+        # assume it's good until an error is found
+        is_good = True
+        for x in keyinfo[FINGERPRINT]:
+            # check fingerprint integrity
+            if len(x) != 40:
+                self.logger.error('ERROR in keyinfo for: %s, %s'
+                    %(keyinfo[NICK], keyinfo[NAME]))
+                self.logger.error('  GPGKey incorrect fingerprint ' +
+                    'length (%s) for fingerprint: %s' %(len(x), x))
+                is_good = False
+                continue
+            if not self.fingerprint_re.match(x):
+                self.logger.error('ERROR in keyinfo info for: %s, %s'
+                    %(keyinfo[NICK], keyinfo[NAME]))
+                self.logger.error('  GPGKey: Non hexadecimal digits in ' +
+                    'fingerprint for fingerprint: ' + x)
+                is_good = False
+        return is_good


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-11-17  7:39 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-11-17  7:39 UTC (permalink / raw
  To: gentoo-commits

commit:     dc079ccd444b04efe2bb5c757e40753dde20954b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 17 07:35:05 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Nov 17 07:35:05 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=dc079ccd

Allow spaced fingerprint entries as well as multiple fingerprints.

Add a check for the total number of id's match the number of fingerprints
Add a re.compile string for the space separated groups of 4 hexdigits fingerprint strings

---
 gkeys/seedhandler.py | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/gkeys/seedhandler.py b/gkeys/seedhandler.py
index af1fbaa..2506277 100644
--- a/gkeys/seedhandler.py
+++ b/gkeys/seedhandler.py
@@ -22,12 +22,18 @@ class SeedHandler(object):
     def __init__(self,logger):
         self.logger = logger
         self.fingerprint_re = re.compile('[0-9A-Fa-f]{40}')
+        self.finerprint_re2 = re.compile('[0-9A-Fa-f]{4}( [0-9A-Fa-f]{4}){9}')
 
 
     def new(self, args, needkeyid=True, checkintegrity=True):
         parts = self.build_gkeylist(args, needkeyid, checkintegrity)
-        gkey = GKEY._make(parts)
-        self.logger.debug("SeedHandler: new() new gkey: %s" % str(gkey))
+        if parts:
+            gkey = GKEY._make(parts)
+            self.logger.debug("SeedHandler: new() new gkey: %s" % str(gkey))
+        else:
+            self.logger.debug("SeedHandler: new() FAILED to et parts from: %s"
+                % str(args))
+            return None
         return gkey
 
 
@@ -58,7 +64,8 @@ class SeedHandler(object):
                     value = None
             elif GKEY.field_types[x] is list:
                 try:
-                    value = [y for y in getattr(args, x).split()]
+                    values = [y for y in getattr(args, x).split(':')]
+                    value = [v.replace(' ', '') for v in values]
                 except AttributeError:
                     value = None
             keyinfo.append(value)
@@ -107,12 +114,25 @@ class SeedHandler(object):
                 index = len(y.lstrip('0x'))
                 if y.lstrip('0x').upper() not in \
                         [x[-index:].upper() for x in keyinfo[FINGERPRINT]]:
-                    self.logger.error('ERROR in ldap info for: %s, %s'
+                    self.logger.error('ERROR in keyinfo for: %s, %s'
                         %(keyinfo[NICK], keyinfo[NAME]))
                     self.logger.error('  ' + str(keyinfo))
                     self.logger.error('  GPGKey id %s not found in the '
                         % y.lstrip('0x') + 'listed fingerprint(s)')
                     is_good = False
+            ids = 0
+            for x in [KEYID, LONGKEYID]:
+                if keyinfo[x]:
+                    ids = ids + len(keyinfo[x])
+            if ids != len(keyinfo[FINGERPRINT]):
+                self.logger.error('ERROR in keyinfo for: %s, %s'
+                    %(keyinfo[NICK], keyinfo[NAME]))
+                self.logger.error('  ' + str(keyinfo))
+                self.logger.error('  GPGKey the number of ids %d DO NOT match '
+                    'the number of listed fingerprint(s), {%s,%s}, %s'
+                    % (ids, keyinfo[KEYID], keyinfo[LONGKEYID], keyinfo[FINGERPRINT]))
+                is_good = False
+
         return is_good
 
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2013-11-17  7:39 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2013-11-17  7:39 UTC (permalink / raw
  To: gentoo-commits

commit:     c854609a0155604950f25ba8bdb613d33b65e957
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 16 20:05:22 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Nov 16 20:29:26 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=c854609a

fix missed dictionary value assignment

---
 gkeys/actions.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 7efcd44..2c1f76d 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -264,7 +264,7 @@ class Actions(object):
                             failed.append(key)
             if failed and self.output:
                 self.output(failed, "\n Failed to install:")
-            return {'Completed'}
+            return {'Completed': True}
         return {"No seeds to search or install": False}
 
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-02-28 20:21 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-02-28 20:21 UTC (permalink / raw
  To: gentoo-commits

commit:     1b40e7a60b1aab57835850b17e1aa4b67a31573a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 14 16:36:50 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Jan 14 16:36:50 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=1b40e7a6

update the seed url's

---
 gkeys/config.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gkeys/config.py b/gkeys/config.py
index 6785c7b..863cc17 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -74,9 +74,8 @@ class GKeysConfig(GPGConfig):
         # or manual install.
         self.defaults['installable-seeddir'] = '%(configdir)s/installable.seeds'
         self.defaults['keyserver'] = 'pool.sks-keyservers.net'
-        self.defaults['dev-seedurl'] = 'http://dev.gentoo.org/~dolsen/gkey-seeds/developer.seeds'
-        self.defaults['release-seedurl'] = 'http://dev.gentoo.org/~dolsen/gkey-seeds/release.seeds'
-        self.defaults['known-seedurl'] = 'http://dev.gentoo.org/~dolsen/gkey-seeds/known.seeds'
+        self.defaults['dev-seedurl'] = 'https://dev.gentoo.org/~dolsen/gkey-seeds/developer.seeds'
+        self.defaults['release-seedurl'] = 'https://dev.gentoo.org/~dolsen/gkey-seeds/release.seeds'
 
 
     def read_config(self):


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-02-28 23:56 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-02-28 23:56 UTC (permalink / raw
  To: gentoo-commits

commit:     f15706835e7eeb0a9b99180dc7a79e95243d6c27
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 28 23:55:15 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Feb 28 23:55:15 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=f1570683

gkeys/actions.py: load_seed(), Upgrade a logger.debug message to logger.error

---
 gkeys/actions.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 13031e5..9dc44ce 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -34,7 +34,7 @@ class Actions(object):
 
     def load_seeds(self, filename):
         if not filename:
-            self.logger.debug("ACTIONS: load_seeds; no filename to load: "
+            self.logger.error("ACTIONS: load_seeds; no filename to load: "
             "%s" % filename)
             return None
         filepath = self.config.get_key(filename + "-seedfile")


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-03-01  0:07 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-03-01  0:07 UTC (permalink / raw
  To: gentoo-commits

commit:     fcd583d2cbf892fd462f89cddfea2780dfe78cd9
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  1 00:07:06 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Mar  1 00:07:06 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=fcd583d2

gkeys/actions.py: load_seeds(), Improve error message.

---
 gkeys/actions.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 9dc44ce..77ac212 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -35,7 +35,8 @@ class Actions(object):
     def load_seeds(self, filename):
         if not filename:
             self.logger.error("ACTIONS: load_seeds; no filename to load: "
-            "%s" % filename)
+            "setting = %s.  Please use the -s option to indicate: which seed "
+            "file to use." % filename)
             return None
         filepath = self.config.get_key(filename + "-seedfile")
         self.logger.debug("ACTIONS: load_seeds; seeds filepath to load: "


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-03-01 17:49 Pavlos Ratis
  0 siblings, 0 replies; 75+ messages in thread
From: Pavlos Ratis @ 2014-03-01 17:49 UTC (permalink / raw
  To: gentoo-commits

commit:     daeb3bc99fc1fb1dc251ecb93c011fd80c16a23a
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  1 14:37:25 2014 +0000
Commit:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
CommitDate: Sat Mar  1 14:37:25 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=daeb3bc9

initialize defaults for logs and seedsdir

---
 gkeys/config.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gkeys/config.py b/gkeys/config.py
index 863cc17..1883703 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -65,9 +65,11 @@ class GKeysConfig(GPGConfig):
         self.defaults['dev-keydir'] = '%(keysdir)s/devs'
         self.defaults['release-keydir'] = '%(keysdir)s/release'
         self.defaults['overlays-keydir'] = '%(keysdir)s/overlays'
+        self.defaults['logdir'] = '%(keysdir)s/logs'
         # known-keysfile is a repositories.xml like file of gpg seeds
         # distributed through api.g.o for convenience
         self.defaults['known-keysfile'] = '%(keysdir)s/knownkeys'
+        self.defaults['seedsdir'] = '%(keysdir)s/seeds'
         self.defaults['release-seedfile'] = '%(configdir)s/release.seeds'
         self.defaults['dev-seedfile'] = '%(configdir)s/developer.seeds'
         # local directory to scan for seed files installed via ebuild, layman


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-03-01 17:50 Pavlos Ratis
  0 siblings, 0 replies; 75+ messages in thread
From: Pavlos Ratis @ 2014-03-01 17:50 UTC (permalink / raw
  To: gentoo-commits

commit:     70f97d275cf7553773d685b16416c82866d3b299
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  1 17:56:15 2014 +0000
Commit:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
CommitDate: Sat Mar  1 17:56:15 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=70f97d27

filter output with seed files only

---
 gkeys/actions.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 8d381db..85c0e0e 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -284,7 +284,10 @@ class Actions(object):
 
 
     def listseedfiles(self, args):
+        seedfile = []
         seedsdir = self.config.get_key('seedsdir')
-        files = os.listdir(seedsdir)
+        for files in os.listdir(seedsdir):
+            if files.endswith('.seeds'):
+                seedfile.append(files)
         return {"Seed files found at path: %s\n   %s"
-            % (seedsdir, "\n   ".join(files)): True}
+            % (seedsdir, "\n   ".join(seedfile)): True}


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-03-01 17:50 Pavlos Ratis
  0 siblings, 0 replies; 75+ messages in thread
From: Pavlos Ratis @ 2014-03-01 17:50 UTC (permalink / raw
  To: gentoo-commits

commit:     c07db99e65867e54fae59eabd64e9281956fe2b6
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  1 14:45:32 2014 +0000
Commit:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
CommitDate: Sat Mar  1 14:45:32 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=c07db99e

rename filename var since it is removed from func args

---
 gkeys/actions.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 25013b3..8d381db 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -39,10 +39,10 @@ class Actions(object):
         if not seeds and not seedfile:
             self.logger.error("ACTIONS: load_seeds; no filename to load: "
             "setting = %s.  Please use the -s option to indicate: which seed "
-            "file to use." % filename)
+            "file to use." % seedfile)
             return None
         if seeds:
-            filepath = self.config.get_key(filename + "-seedfile")
+            filepath = self.config.get_key(seeds + "-seedfile")
         elif seedfile:
             filepath = os.path.join(self.config.get_key('seedsdir'),
                                     '%s.seeds' % seedfile)


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-05-17 18:13 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-05-17 18:13 UTC (permalink / raw
  To: gentoo-commits

commit:     7653611d61b22c8c9e55805fe33be37664368b4d
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sat May 17 17:49:10 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat May 17 17:49:10 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=7653611d

fix missed quotes

---
 gkeys/config.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gkeys/config.py b/gkeys/config.py
index 4e309b0..3edc463 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -73,8 +73,8 @@ class GKeysConfig(GPGConfig):
         self.defaults['dev-seedfile'] = '%(seedsdir)s/developer.seeds'
         self.defaults['keyserver'] = 'pool.sks-keyservers.net'
         self.defaults['seedurls'] = {
-            'release.seeds': https://dev.gentoo.org/~dolsen/gkey-seeds/release.seeds,
-            'developers.seeds': https://dev.gentoo.org/~dolsen/gkey-seeds/developer.seeds,
+            'release.seeds': 'https://dev.gentoo.org/~dolsen/gkey-seeds/release.seeds',
+            'developers.seeds': 'https://dev.gentoo.org/~dolsen/gkey-seeds/developer.seeds',
         }
 
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-05-27 20:56 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-05-27 20:56 UTC (permalink / raw
  To: gentoo-commits

commit:     af0263e4288fab2e888aaff428a87e80a04e0466
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Thu May 15 17:51:14 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue May 20 12:27:15 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=af0263e4

fix packed string when it gets NoneType values

---
 gkeys/config.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gkeys/config.py b/gkeys/config.py
index 3edc463..1ff5a18 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -146,7 +146,7 @@ class GKEY(namedtuple('GKEY', ['nick', 'name', 'keyid', 'longkeyid',
     @property
     def packed_string(self):
         '''Returns a separator joined string of the field values'''
-        return self.field_separator.join([x for x in self._packed_values()])
+        return self.field_separator.join([str(x) for x in self._packed_values()])
 
     def _unpack_string(self, packed_data):
         '''Returns a list of the separator joined string of the field values'''


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-05-27 20:56 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-05-27 20:56 UTC (permalink / raw
  To: gentoo-commits

commit:     750ec49ff4858d2ad168c91c9c8d465bff30d3b6
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Thu May 22 16:21:17 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat May 24 17:38:48 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=750ec49f

create namedtuple with default mapping

---
 gkeys/config.py | 14 --------------
 gkeys/seed.py   |  4 +---
 2 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/gkeys/config.py b/gkeys/config.py
index 818f5b1..b20d5cd 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -184,20 +184,6 @@ class GKEY(namedtuple('GKEY', ['nick', 'name', 'keyid', 'longkeyid',
                 result = data.split(self.list_separator)
         return result
 
-    def _unpack_dict(self, data):
-        values = []
-        for attr in self._fields:
-            values.append(data[attr])
-        return values
-
-    def make_packed_dict(self, packed_dict):
-        '''Creates a new instance of Gkey from a dictionary
-
-        @param packed_dict: data inside a dictionary
-        @return new GKEY instance containing the data
-        '''
-        return GKEY._make(self._unpack_dict(packed_dict))
-
     def make_packed(self, packed_string):
         '''Creates a new instance of Gkey from the packed
         value string

diff --git a/gkeys/seed.py b/gkeys/seed.py
index aebf63d..ecbbf83 100644
--- a/gkeys/seed.py
+++ b/gkeys/seed.py
@@ -52,11 +52,9 @@ class Seeds(object):
             logger.debug("Seed: load; IOError occurred while loading file")
             self._error(err)
             return False
-        # initialize a dummy instance, so it can make new ones
-        gkey = GKEY._make([None,None,None,None,None,None])
         for seed in seedlines.items():
             #try:
-            self.seeds.append(gkey.make_packed_dict(seed[1]))
+            self.seeds.append(GKEY(**seed[1]))
             #except Exception as err:
                 #logger.debug("Seed: load; Error splitting seed: %s" % seed)
                 #logger.debug("Seed: load; ...............parts: %s" % str(parts))


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-05-27 20:56 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-05-27 20:56 UTC (permalink / raw
  To: gentoo-commits

commit:     a315e31d59331d331c254c1bd2271b2f52503779
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Wed May 21 17:38:50 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed May 21 17:38:50 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=a315e31d

remove unused import

---
 gkeys/cli.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gkeys/cli.py b/gkeys/cli.py
index f688756..200ca87 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -16,7 +16,6 @@ from __future__ import print_function
 import argparse
 import sys
 
-from gkeys import log
 from gkeys.log import log_levels, set_logger
 
 from gkeys import config


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-05-27 20:56 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-05-27 20:56 UTC (permalink / raw
  To: gentoo-commits

commit:     4141af80341062e6b6db0b636a05988fa09e1f9f
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sat May 24 17:26:19 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat May 24 17:38:48 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=4141af80

subclass __new__ to make both gkeys and gkeyldap work properly

---
 gkeys/config.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gkeys/config.py b/gkeys/config.py
index b20d5cd..9d629b7 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -130,6 +130,13 @@ class GKEY(namedtuple('GKEY', ['nick', 'name', 'keyid', 'longkeyid',
     'keydir', 'fingerprint'])):
     '''Class to hold the relavent info about a key'''
 
+    # subclass __new__ to make both gkeys and gkeyldap work properly
+    # delete it when keyid and longkeyid are removed from LDAP
+    def __new__(cls, nick=None, name=None, keydir=None, fingerprint=None,
+                keyid=None, longkeyid=None):
+        return super(GKEY, cls).__new__(cls, nick, name, keydir, fingerprint,
+                                        keyid, longkeyid)
+
     field_types = {'nick': str, 'name': str, 'keyid': list,
         'longkeyid': list, 'keydir': str, 'fingerprint': list}
     field_separator = "|"


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-05-27 20:56 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-05-27 20:56 UTC (permalink / raw
  To: gentoo-commits

commit:     288ed8404e12e68f86594a1f5a099e0ccd59c747
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Wed May 21 17:39:13 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed May 21 17:39:13 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=288ed840

fix missed var renaming

---
 gkeys/seedhandler.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gkeys/seedhandler.py b/gkeys/seedhandler.py
index 7f73857..be68990 100644
--- a/gkeys/seedhandler.py
+++ b/gkeys/seedhandler.py
@@ -145,7 +145,7 @@ class SeedHandler(object):
                 self.logger.error('ERROR in keyinfo for: %s, %s'
                     %(keyinfo[NICK], keyinfo[NAME]))
                 self.logger.error('  GPGKey incorrect fingerprint ' +
-                    'length (%s) for fingerprint: %s' %(len(x), x))
+                    'length (%s) for fingerprint: %s' %(len(fingerprint), fingerprint))
                 is_good = False
                 continue
             if not self.fingerprint_re.match(fingerprint):


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-05-27 20:56 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-05-27 20:56 UTC (permalink / raw
  To: gentoo-commits

commit:     cf516e162f2cef8d1b2c4d2367104d298372983f
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sat May 24 17:56:56 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat May 24 17:56:56 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=cf516e16

remove unused constants

---
 gkeys/config.py | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/gkeys/config.py b/gkeys/config.py
index 9d629b7..b1a0447 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -110,15 +110,6 @@ class GKeysConfig(GPGConfig):
             return super(GKeysConfig, self)._get_(key, subkey)
 
 
-# some constants used in gkeyldap/actions.py
-# they map the index values of the GKEY input data fields
-NICK = 0
-NAME = 1
-KEYID = 2
-LONGKEYID = 3
-KEYDIR = 4
-FINGERPRINT = 5
-
 # set some defaults
 KEYLEN_MAP = {
     'keyid': 8,


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-05-27 20:56 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-05-27 20:56 UTC (permalink / raw
  To: gentoo-commits

commit:     8e56c1e4fb4d7d2e6bae2f12f64aed86617aed68
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sat May 24 17:56:39 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat May 24 17:56:39 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=8e56c1e4

refine seed handling

---
 gkeys/actions.py     |  12 ++--
 gkeys/seedhandler.py | 153 ++++++++++++++-------------------------------------
 2 files changed, 48 insertions(+), 117 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 79690fc..79c42ee 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -69,11 +69,11 @@ class Actions(object):
     def addseed(self, args):
         '''Action addseed method'''
         handler = SeedHandler(self.logger)
-        gkey = handler.new(args)
+        gkey = handler.new(args, checkgkey=True)
         gkeys = self.listseed(args)
         if len(gkeys) == 0:
             self.logger.debug("ACTIONS: addkey; now adding gkey: %s" % str(gkey))
-            success = self.seeds.add(gkey)
+            success = self.seeds.add(getattr(gkey, 'nick')[0], gkey)
             if success:
                 success = self.seeds.save()
                 return ["Successfully added new seed: %s" % str(success), gkey]
@@ -87,19 +87,19 @@ class Actions(object):
     def removeseed(self, args):
         '''Action removeseed method'''
         handler = SeedHandler(self.logger)
-        searchkey = handler.new(args, needkeyid=False, checkintegrity=False)
+        searchkey = handler.new(args)
         self.logger.debug("ACTIONS: removeseed; gkey: %s" % str(searchkey))
         gkeys = self.listseed(args)
         if not gkeys:
             return ["Failed to remove seed: No gkeys returned from listseed()",
                 None]
         if len(gkeys) == 1:
-            self.logger.debug("ACTIONS: removeseed; now deleting gkey: %s" % str(gkeys[0]))
-            success = self.seeds.delete(gkeys[0])
+            self.logger.debug("ACTIONS: removeseed; now deleting gkey: %s" % str(gkeys))
+            success = self.seeds.delete(gkeys)
             if success:
                 success = self.seeds.save()
             return ["Successfully removed seed: %s" % str(success),
-                gkeys[0]]
+                gkeys]
         elif len(gkeys):
             messages = ["Too many seeds found to remove"]
             messages.extend(gkeys)

diff --git a/gkeys/seedhandler.py b/gkeys/seedhandler.py
index be68990..8aac6a8 100644
--- a/gkeys/seedhandler.py
+++ b/gkeys/seedhandler.py
@@ -12,29 +12,29 @@
 
 import re
 
-from gkeys.config import (GKEY, NICK, NAME, KEYID, LONGKEYID, FINGERPRINT,
-    KEYLEN_MAP)
+from gkeys.config import GKEY
 
 
 class SeedHandler(object):
 
-
     def __init__(self,logger):
         self.logger = logger
         self.fingerprint_re = re.compile('[0-9A-Fa-f]{40}')
         self.finerprint_re2 = re.compile('[0-9A-Fa-f]{4}( [0-9A-Fa-f]{4}){9}')
 
 
-    def new(self, args, needkeyid=True, checkintegrity=True):
-        parts = self.build_gkeylist(args, needkeyid, checkintegrity)
-        if parts:
-            gkey = GKEY._make(parts)
-            self.logger.debug("SeedHandler: new() new gkey: %s" % str(gkey))
+    def new(self, args, checkgkey=False):
+        newgkey = self.build_gkeydict(args)
+        if checkgkey:
+            newgkey = self.check_gkey(newgkey)
+        if newgkey:
+            newgkey = GKEY(**newgkey)
+            self.logger.debug("SeedHandler: new() new gkey: %s" % str(newgkey))
         else:
             self.logger.debug("SeedHandler: new() FAILED to et parts from: %s"
                 % str(args))
             return None
-        return gkey
+        return newgkey
 
 
     @staticmethod
@@ -49,109 +49,40 @@ class SeedHandler(object):
                 pass
         return keyinfo
 
-
-    def build_gkeylist(self, args, needkeyid=True, checkintegrity=True):
-        keyinfo = []
-        keyid_found = False
-        # assume it's good until an error is found
-        is_good = True
-        #self.logger.debug("SeedHandler: build_gkeylist; args = %s" % str(args))
-        for attr in GKEY._fields:
-            if GKEY.field_types[attr] is str:
-                try:
-                    value = getattr(args, attr)
-                except AttributeError:
-                    value = None
-            elif GKEY.field_types[attr] is list:
-                try:
-                    values = [y for y in getattr(args, attr).split(':')]
-                    value = [v.replace(' ', '') for v in values]
-                except AttributeError:
-                    value = None
-            keyinfo.append(value)
-            if attr in ["keyid", "longkeyid"] and value:
-                keyid_found = True
-        if not keyid_found and needkeyid:
-            fingerprint = keyinfo[FINGERPRINT]
-            if fingerprint:
-                self.logger.debug('  Generate gpgkey longkeyid, Found '
-                    'fingerprint in args')
-                # assign it to gpgkey to prevent a possible
-                # "gpgkey" undefined error
-                gpgkey = ['0x' + x[-KEYLEN_MAP['longkeyid']:] for x in fingerprint]
-                keyinfo[LONGKEYID] = gpgkey
-                self.logger.debug('  Generate gpgkey longkeyid, NEW '
-                    'keyinfo[LONGKEYID] = %s' % str(keyinfo[LONGKEYID]))
-            else:
-                gpgkey = 'Missing or Bad fingerprint from command line args'
+    def check_gkey(self, args):
+      # assume it's good until an error is found
+      is_good = True
+      try:
+          if args['fingerprint']:
+              # create a longkeyid based on fingerprint
+              is_ok = self._check_fingerprint_integrity(args)
+              args['keydir'] = args.get('keydir', args['nick'])
+              if not is_ok:
                 is_good = False
-            if not keyinfo[LONGKEYID]:
-                self.logger.error('ERROR in seed creation info for: %s, %s'
-                    %(keyinfo[NICK], keyinfo[NAME]))
-                self.logger.error('  A valid keyid, longkeyid or fingerprint '
-                    'was not found for %s : gpgkey = %s'
-                    %(keyinfo[NAME], gpgkey))
-                is_good = False
-        if is_good:
-            if keyinfo[FINGERPRINT]: # fingerprints exist check
-                is_ok = self._check_fingerprint_integrity(keyinfo)
-                is_match = self._check_id_fingerprint_match(keyinfo)
-                if not is_ok or not is_match:
-                    is_good = False
-        if is_good:
-            return keyinfo
-        return None
-
-
-    def _check_id_fingerprint_match(self, keyinfo):
-        # assume it's good until found an error is found
+                self.logger.error('Bad fingerprint from command line args.')
+      except KeyError:
+          self.logger.error('GPG fingerprint not found.')
+          is_good = False
+      # need to add values to a list
+      for key,value in args.items():
+          args[key] = value.split()
+      if is_good:
+          return args
+      else:
+          self.logger.error('A valid fingerprint '
+                  'was not found for %s' % args['name'])
+      return args
+
+    def _check_fingerprint_integrity(self, gkey):
+        # assume it's good unti an error is found
         is_good = True
-        for x in [KEYID, LONGKEYID]:
-            # skip blank id field
-            if not keyinfo[x]:
-                continue
-            for y in keyinfo[x]:
-                index = len(y.lstrip('0x'))
-                if y.lstrip('0x').upper() not in \
-                        [x[-index:].upper() for x in keyinfo[FINGERPRINT]]:
-                    self.logger.error('ERROR in keyinfo for: %s, %s'
-                        %(keyinfo[NICK], keyinfo[NAME]))
-                    self.logger.error('  ' + str(keyinfo))
-                    self.logger.error('  GPGKey id %s not found in the '
-                        % y.lstrip('0x') + 'listed fingerprint(s)')
-                    is_good = False
-            ids = 0
-            for x in [KEYID, LONGKEYID]:
-                if keyinfo[x]:
-                    ids = ids + len(keyinfo[x])
-            if ids != len(keyinfo[FINGERPRINT]):
-                self.logger.error('ERROR in keyinfo for: %s, %s'
-                    %(keyinfo[NICK], keyinfo[NAME]))
-                self.logger.error('  ' + str(keyinfo))
-                self.logger.error('  GPGKey the number of ids %d DO NOT match '
-                    'the number of listed fingerprint(s), {%s,%s}, %s'
-                    % (ids, keyinfo[KEYID], keyinfo[LONGKEYID], keyinfo[FINGERPRINT]))
-                is_good = False
-
-        return is_good
-
-
-    def _check_fingerprint_integrity(self, keyinfo):
-        # assume it's good until an error is found
-        is_good = True
-        for fingerprint in keyinfo[FINGERPRINT]:
-            # check fingerprint integrity
-            if len(fingerprint) != 40:
-                self.logger.error('ERROR in keyinfo for: %s, %s'
-                    %(keyinfo[NICK], keyinfo[NAME]))
-                self.logger.error('  GPGKey incorrect fingerprint ' +
+        fingerprint = gkey['fingerprint']
+        # check fingerprint integrity
+        if len(fingerprint) != 40:
+            self.logger.error('  GPGKey incorrect fingerprint ' +
                     'length (%s) for fingerprint: %s' %(len(fingerprint), fingerprint))
-                is_good = False
-                continue
-            if not self.fingerprint_re.match(fingerprint):
-                self.logger.error('ERROR in keyinfo info for: %s, %s'
-                    %(keyinfo[NICK], keyinfo[NAME]))
-                self.logger.error('  GPGKey: Non hexadecimal digits in ' +
-                    'fingerprint for fingerprint: ' + fingerprint)
-                is_good = False
+            is_good = False
+        if not self.fingerprint_re.match(fingerprint):
+            self.logger.error('  GPGKey: Non hexadecimal digits in ' + 'fingerprint for fingerprint: ' + fingerprint)
+            is_good = False
         return is_good


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-05-28  2:21 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-05-28  2:21 UTC (permalink / raw
  To: gentoo-commits

commit:     95c14136bdb36bc8a23f68b2a4a118302b02919b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed May 28 02:20:12 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed May 28 02:20:12 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=95c14136

gkeys/config.py: Add keyid property to GKEY

Remove no longer tracked keyid and longkeyid from field_types

---
 gkeys/config.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gkeys/config.py b/gkeys/config.py
index efb9be7..6941368 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -115,6 +115,11 @@ class GKeysConfig(GPGConfig):
 class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
     '''Class to hold the relavent info about a key'''
 
-    field_types = {'nick': str, 'name': str, 'keyid': list,
-                   'longkeyid': list, 'keydir': str, 'fingerprint': list}
+    field_types = {'nick': str, 'name': str, 'keydir': str, 'fingerprint': list}
     __slots__ = ()
+
+
+    @property
+    def keyid(self):
+        '''Keyid is a substring value of the fingerprint'''
+        return ['0x' + x[-16:] for x in self.fingerprint]


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-05-28  2:21 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-05-28  2:21 UTC (permalink / raw
  To: gentoo-commits

commit:     3594b203fea016db234010f318d94cd60af04643
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed May 28 02:01:32 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed May 28 02:01:32 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=3594b203

gkeys/config.py: Add missing _add_gkey_defaults call

---
 gkeys/config.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gkeys/config.py b/gkeys/config.py
index 14756e7..efb9be7 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -56,6 +56,7 @@ class GKeysConfig(GPGConfig):
             self.defaults['configdir'] = path([self.root, EPREFIX, '/etc/gentoo-keys'])
             self.defaults['config'] = '%(configdir)s/gkeys.conf'
         self.configparser = None
+        self._add_gkey_defaults()
         if read_configfile:
             self.read_config()
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-06-01 15:25 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-06-01 15:25 UTC (permalink / raw
  To: gentoo-commits

commit:     2427bfa1c92a2c5d8450b7a7c08120fa9aee73be
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Fri May 30 19:25:59 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri May 30 19:25:59 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=2427bfa1

implement fetchseed action and use sslfetch to download seeds

---
 gkeys/actions.py | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 gkeys/config.py  |  3 +++
 2 files changed, 72 insertions(+), 4 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 1ecf4d3..5c4d934 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -13,14 +13,15 @@
 from __future__ import print_function
 
 import os
+import re
 
-
-from gkeys.seedhandler import SeedHandler
+from gkeys.config import SEED_TYPES
 from gkeys.lib import GkeysGPG
 from gkeys.seed import Seeds
+from gkeys.seedhandler import SeedHandler
+from sslfetch.connections import Connector
 
-
-Available_Actions = ['listseed', 'addseed', 'removeseed', 'moveseed',
+Available_Actions = ['listseed', 'addseed', 'removeseed', 'moveseed', 'fetchseed',
             'listseedfiles', 'listkey', 'addkey', 'removekey', 'movekey',
             'installed']
 
@@ -53,6 +54,62 @@ class Actions(object):
         return seeds
 
 
+    def fetch_seeds(self, seeds):
+        # setup the ssl-fetch ouptut map
+        connector_output = {
+            'info': self.logger.info,
+            'error': self.logger.error,
+            'kwargs-info': {},
+            'kwargs-error': {},
+        }
+        urls = []
+        messages = []
+        urls.append(self.config.get_key('developers.seeds'))
+        urls.append(self.config.get_key('release.seeds'))
+        if not re.search('^(http|https)://', urls[0]) and not re.search('^(http|https)://', urls[1]):
+            urls = []
+            urls.append(self.config['seedurls']['developers.seeds'])
+            urls.append(self.config['seedurls']['release.seeds'])
+        fetcher = Connector(connector_output, None, "Gentoo Keys")
+        for url in zip(urls, SEED_TYPES):
+            timestamp_path = self.config['%s-timestamp' % url[1]]
+            success, seeds, timestamp = fetcher.fetch_content(url[0], timestamp_path)
+            if not timestamp:
+                messages += ["%s seed file is already up to date." % url[1]]
+            else:
+                with open(timestamp_path, 'w+') as timestampfile:
+                    timestampfile.write(str(timestamp))
+                    timestampfile.write("\n")
+                if success and timestamp:
+                    self.logger.debug("MAIN: _action_fetchseed; got results.")
+                    filename = self.config['%s-seedfile' % url[1]] + '.new'
+                    with open(filename, 'w') as seedfile:
+                        seedfile.write(seeds)
+                    filename = self.config['%s-seedfile' % url[1]]
+                    old = filename + '.old'
+                    try:
+                        self.logger.info("Backing up existing file...")
+                        if os.path.exists(old):
+                            self.logger.debug(
+                                "MAIN: _action_fetch_seeds; Removing 'old' seed file: %s"
+                                % old)
+                            os.unlink(old)
+                        if os.path.exists(filename):
+                            self.logger.debug(
+                                "MAIN: _action_fetch_seeds; Renaming current seed file to: "
+                                "%s" % old)
+                            os.rename(filename, old)
+                        self.logger.debug("MAIN: _action_fetch_seeds; Renaming '.new' seed file to %s"
+                                          % filename)
+                        os.rename(filename + '.new', filename)
+                        messages += ["Successfully fetched %s seed files." % url[1]]
+                    except IOError:
+                        raise
+                else:
+                    messages += ["Failed to fetch %s seed file." % url[1]]
+        return messages
+
+
     def listseed(self, args):
         '''Action listseed method'''
         handler = SeedHandler(self.logger)
@@ -69,6 +126,14 @@ class Actions(object):
         return None
 
 
+    def fetchseed(self, args):
+        '''Action fetchseed method'''
+        handler = SeedHandler(self.logger)
+        messages = self.fetch_seeds(args.seeds)
+        self.logger.debug("ACTIONS: fetchseed; args: %s" % str(args))
+        return messages
+
+
     def addseed(self, args):
         '''Action addseed method'''
         handler = SeedHandler(self.logger)

diff --git a/gkeys/config.py b/gkeys/config.py
index 6941368..161315e 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -38,6 +38,7 @@ EPREFIX = "@GENTOO_PORTAGE_EPREFIX@"
 if "GENTOO_PORTAGE_EPREFIX" in EPREFIX:
     EPREFIX = ''
 
+SEED_TYPES = ['dev', 'release']
 
 
 class GKeysConfig(GPGConfig):
@@ -72,6 +73,8 @@ class GKeysConfig(GPGConfig):
         self.defaults['seedsdir'] = '%(keysdir)s/seeds'
         self.defaults['release-seedfile'] = '%(seedsdir)s/release.seeds'
         self.defaults['dev-seedfile'] = '%(seedsdir)s/developer.seeds'
+        self.defaults['dev-timestamp'] = '%(keysdir)s/.developer_seeds_timestamp'
+        self.defaults['release-timestamp'] = '%(keysdir)s/.release_seeds_timestamp'
         self.defaults['keyserver'] = 'pool.sks-keyservers.net'
         self.defaults['seedurls'] = {
             'release.seeds': 'https://dev.gentoo.org/~dolsen/gkey-seeds/release.seeds',


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-06-01 15:25 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-06-01 15:25 UTC (permalink / raw
  To: gentoo-commits

commit:     18e4734f2181d8152e37cfbb1f2903ba6ce52f91
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  1 15:15:35 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jun  1 15:21:36 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=18e4734f

GKEY: New pretty_print property

Update cli.output_results to use the new property.

---
 gkeys/cli.py    |  2 +-
 gkeys/config.py | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/gkeys/cli.py b/gkeys/cli.py
index 200ca87..dd1b45a 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -147,7 +147,7 @@ class Main(object):
     def output_results(results, header):
         # super simple output for the time being
         print(header)
-        print("\n".join([str(x) for x in results]))
+        print("\n".join([x.pretty_print for x in results]))
         print()
 
 

diff --git a/gkeys/config.py b/gkeys/config.py
index 161315e..e9537b0 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -40,6 +40,15 @@ if "GENTOO_PORTAGE_EPREFIX" in EPREFIX:
 
 SEED_TYPES = ['dev', 'release']
 
+GKEY_STRING = '''    ----------
+    Name.........: %(name)s
+    Nick.........: %(nick)s
+    Keydir.......: %(keydir)s
+'''
+GKEY_FINGERPRINTS = \
+'''    Keyid........: %(keyid)s
+      Fingerprint: %(fingerprint)s
+'''
 
 class GKeysConfig(GPGConfig):
     """ Configuration superclass which holds our gentoo-keys
@@ -126,3 +135,15 @@ class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
     def keyid(self):
         '''Keyid is a substring value of the fingerprint'''
         return ['0x' + x[-16:] for x in self.fingerprint]
+
+
+    @property
+    def pretty_print(self):
+        '''Pretty printing a GKEY'''
+        gkey = {'name': ', '.join(self.name), 'nick': ', '.join(self.nick)
+            , 'keydir': ', '.join(self.keydir)}
+        output = GKEY_STRING % gkey
+        for f in self.fingerprint:
+            fingerprint = {'fingerprint': f, 'keyid': '0x' + f[-16:]}
+            output += GKEY_FINGERPRINTS % fingerprint
+        return output


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-06-01 15:25 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-06-01 15:25 UTC (permalink / raw
  To: gentoo-commits

commit:     8bc4b7b17fb38055579aabbf677da48188687fa6
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Fri May 30 15:41:32 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri May 30 18:27:41 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=8bc4b7b1

err message when no seed files available

---
 gkeys/actions.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 79c42ee..1ecf4d3 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -59,7 +59,10 @@ class Actions(object):
         kwargs = handler.build_gkeydict(args)
         self.logger.debug("ACTIONS: listseed; kwargs: %s" % str(kwargs))
         if not self.seeds:
-            self.seeds = self.load_seeds(args.seeds, args.seedfile)
+            try:
+                self.seeds = self.load_seeds(args.seeds, args.seedfile)
+            except ValueError:
+                return ["Failed to load seed file. Consider fetching seedfiles."]
         if self.seeds:
             results = self.seeds.list(**kwargs)
             return results


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-08-20  3:55 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-08-20  3:55 UTC (permalink / raw
  To: gentoo-commits

commit:     98bfad8cbe753e799ea2ebe9219b32126a06dda5
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 21 22:47:33 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Jul 21 22:47:33 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=98bfad8c

removekey action: Remove installed keys

---
 gkeys/actions.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 gkeys/cli.py     |  1 -
 gkeys/lib.py     | 17 ++++++++---------
 gkeys/seed.py    |  7 +++++--
 4 files changed, 66 insertions(+), 15 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index f5ea252..caa0d7f 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -14,8 +14,12 @@ from __future__ import print_function
 
 import os
 
+from json import load
+from shutil import rmtree
+
 from gkeys.lib import GkeysGPG
 from gkeys.seedhandler import SeedHandler
+from gkeys.config import GKEY
 
 Available_Actions = ['listseed', 'addseed', 'removeseed', 'moveseed', 'fetchseed',
             'listseedfiles', 'listkey', 'addkey', 'removekey', 'movekey',
@@ -222,7 +226,7 @@ class Actions(object):
                     for result in results[key.name]:
                         print("key desired:", key.name, ", key added:",
                             result.username, ", succeeded:",
-                            not result.failed,", fingerprint:", result.fingerprint)
+                            not result.failed, ", fingerprint:", result.fingerprint)
                         self.logger.debug("stderr_out: " + str(result.stderr_out))
                         if result.failed:
                             failed.append(key)
@@ -234,7 +238,35 @@ class Actions(object):
 
     def removekey(self, args):
         '''Remove an installed key'''
-        pass
+        if not args.nick:
+            return ["Please provide a nickname or -n *"]
+        handler = SeedHandler(self.logger, self.config)
+        kwargs = handler.build_gkeydict(args)
+        self.logger.debug("ACTIONS: addkey; kwargs: %s" % str(kwargs))
+        installed_keys = self.installed(args)[1]
+        for gkey in installed_keys:
+            if kwargs['nick'] not in gkey.nick:
+                messages = ["%s does not seem to be a valid key." % kwargs['nick']]
+            else:
+                self.output(['', [gkey]], '\n Found GKEY seed:')
+                ans = raw_input("Do you really want to remove %s?[y/n]: "
+                                % kwargs['nick']).lower()
+                while ans not in ["yes", "y", "no", "n"]:
+                    ans = raw_input("Do you really want to remove %s?[y/n]: "
+                                    % kwargs['nick']).lower()
+                if ans in ["no", "n"]:
+                    messages = ["Key removal aborted... Nothing to be done."]
+                else:
+                    keydir = self.config.get_key(args.seeds + "-keydir")
+                    rm_candidate = os.path.join(keydir, gkey.nick)
+                    self.logger.debug("ACTIONS: removekey; keysdir = %s" % keydir)
+                    if args.seeds:
+                        try:
+                            rmtree(rm_candidate)
+                            messages = ["Done removing %s key." % kwargs['nick']]
+                        except OSError:
+                            messages = ["%s directory does not exist." % rm_candidate]
+        return messages
 
 
     def movekey(self, args):
@@ -244,7 +276,25 @@ class Actions(object):
 
     def installed(self, args):
         '''Lists the installed key directories'''
-        pass
+        if args.seeds:
+            keydir = self.config.get_key(args.seeds + "-keydir")
+        else:
+            return ["Please specify a seed file."]
+        self.logger.debug("ACTIONS: installed; keysdir = %s" % keydir)
+        installed_keys = []
+        try:
+            for key in os.listdir(keydir):
+                seed_path = os.path.join(keydir, key)
+                gkey_path = os.path.join(seed_path, 'gkey.seeds')
+                try:
+                    with open(gkey_path, 'r') as fileseed:
+                        seed = load(fileseed)
+                except IOError:
+                    return ["No seed file found in %s." % gkey_path, ""]
+                installed_keys.append(GKEY(**seed.values()[0]))
+        except OSError:
+            return ["%s keydir does not exist." % keydir, ""]
+        return ['Found Key/s:', installed_keys]
 
 
     def user_confirm(self, message):

diff --git a/gkeys/cli.py b/gkeys/cli.py
index 7335ec4..3df3435 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -155,6 +155,5 @@ class Main(object):
         print()
 
 
-
     def output_failed(self, failed):
         pass

diff --git a/gkeys/lib.py b/gkeys/lib.py
index c80cff6..3861012 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -96,17 +96,10 @@ class GkeysGPG(GPG):
         self.set_keyserver()
         self.set_keydir(gkey.keydir, 'recv-keys', reset=True)
         self.set_keyring('pubring.gpg', 'recv-keys', reset=False)
-        # Save the gkey seed to the installed db
-        self.set_keyseedfile()
-        self.seedfile.update(gkey)
-        if not self.seedfile.save():
-            logger.error("GkeysGPG.add_key(); failed to save seed" + gkey.nick)
-            return []
         logger.debug("LIB: add_key; ensure dirs: " + self.keydir)
         ensure_dirs(str(self.keydir))
-        fingerprints = gkey.fingerprint
         results = []
-        for fingerprint in fingerprints:
+        for fingerprint in gkey.fingerprint:
             logger.debug("LIB: add_key; adding fingerprint" + fingerprint)
             logger.debug("** Calling runGPG with Running 'gpg %s --recv-keys %s' for: %s"
                 % (' '.join(self.config.get_key('tasks', 'recv-keys')),
@@ -127,6 +120,12 @@ class GkeysGPG(GPG):
                 message += "\n result: %s" % (result.fingerprint)
                 message += "\n gkey..: %s" % (str(gkey.fingerprint))
                 logger.error(message)
+            # Save the gkey seed to the installed db
+            self.set_keyseedfile()
+            self.seedfile.update(gkey)
+            if not self.seedfile.save():
+                logger.error("GkeysGPG.add_key(); failed to save seed: " + gkey.nick)
+                return []
             results.append(result)
             print("lib.add_key(), result =")
             print(result.stderr_out)
@@ -203,6 +202,6 @@ class GkeysGPG(GPG):
         '''
         pass
 
+
     def set_keyseedfile(self):
         self.seedfile = Seeds(pjoin(self.keydir, 'gkey.seeds'))
-        self.seedfile.load()

diff --git a/gkeys/seed.py b/gkeys/seed.py
index cfb2b98..008fe38 100644
--- a/gkeys/seed.py
+++ b/gkeys/seed.py
@@ -45,7 +45,7 @@ class Seeds(object):
         seedlines = None
         self.seeds = {}
         try:
-            with open(self.filename) as seedfile:
+            with open(self.filename, "r+") as seedfile:
                 seedlines = json.load(seedfile)
         except IOError as err:
             logger.debug("Seed: load; IOError occurred while loading file")
@@ -122,6 +122,7 @@ class Seeds(object):
         '''Search for the keys matching the regular expression pattern'''
         pass
 
+
     def nick_search(self, nick):
         '''Searches the seeds for a matching nick
 
@@ -133,6 +134,7 @@ class Seeds(object):
         except KeyError:
             return None
 
+
     def _error(self, err):
         '''Class error logging function'''
         logger.error("Seed: Error processing seed file %s" % self.filename)
@@ -148,12 +150,13 @@ class Seeds(object):
                 seeds[dev] = dict(value._asdict())
         return json.dumps(seeds, sort_keys=True, indent=4)
 
+
     def update(self, gkey):
         '''Looks for existance of a matching nick already in the seedfile
         if it exists. Then either adds or replaces the gkey
         @param gkey: GKEY instance
         '''
-        oldkey = self.nick_search(gkey.nick[0])
+        oldkey = self.nick_search(gkey.nick)
         if oldkey:
             self.delete(oldkey)
         self.add(gkey.nick, gkey)


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-08-20  3:55 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-08-20  3:55 UTC (permalink / raw
  To: gentoo-commits

commit:     85a89cd662ddf8880679badb0626a32114b3d0f4
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 27 22:37:49 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Jun 27 22:37:49 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=85a89cd6

use snakeoil in add_key action; minor improvements

---
 gkeys/actions.py | 55 +++++++++++++++++++++++--------------------------------
 gkeys/fileops.py | 30 ++++++++++++++++++++++++++++++
 gkeys/lib.py     |  9 ++++-----
 3 files changed, 57 insertions(+), 37 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index b7ef9de..f5ea252 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -169,42 +169,41 @@ class Actions(object):
         for key in keyresults:
             if not key.keydir and not args.nick == '*':
                 self.logger.debug("ACTIONS: listkey; NO keydir... Ignoring")
-                messages = ["Failed: No keyid's found for %s" % key.name[0]]
+                messages = ["Failed: No keyid's found for %s" % key.name]
             else:
                 self.logger.debug("ACTIONS: listkey; listing keydir:" + str(key.keydir))
-                results[key.name[0]] = self.gpg.list_keys(key.keydir[0])
+                results[key.name] = self.gpg.list_keys(key.keydir)
                 if self.config.options['print_results']:
-                    print(results[key.name[0]].output)
-                    self.logger.debug("data output:\n" + str(results[key.name[0]].output))
+                    print(results[key.name].output)
+                    self.logger.debug("data output:\n" + str(results[key.name].output))
                     messages = ["Done."]
                 else:
                     return results
         return messages
 
+
     def addkey(self, args):
         '''Install a key from the seed(s)'''
-        handler = SeedHandler(self.logger)
+        if not args.nick:
+            return ["Please provide a nickname or -n *"]
+        handler = SeedHandler(self.logger, self.config)
         kwargs = handler.build_gkeydict(args)
         self.logger.debug("ACTIONS: addkey; kwargs: %s" % str(kwargs))
-        if not args.nick:
-            return {'Please provide a nickname or -n *': False}
-        gkey = self.listseed(args)
+        gkey = self.listseed(args)[1]
         if gkey:
-            # get the desired seed
-            keyresults = self.seeds.list(**kwargs)
-            if keyresults and not args.nick == '*' and self.output:
-                self.output(['', keyresults], "\n Found GKEY seeds:")
-            elif keyresults and self.output:
+            if gkey and not args.nick == '*' and self.output:
+                self.output(['', gkey], "\n Found GKEY seeds:")
+            elif gkey and self.output:
                 self.output(['all'], "\n Installing seeds:")
             else:
                 self.logger.info("ACTIONS: addkey; "
                     "Matching seed entry not found")
                 if args.nick:
-                    return {"Search failed for: %s" % args.nick: False}
+                    return ["Search failed for: %s" % args.nick]
                 elif args.name:
-                    return {"Search failed for: %s" % args.name: False}
+                    return ["Search failed for: %s" % args.name]
                 else:
-                    return {"Search failed for search term": False}
+                    return ["Search failed for search term"]
             # get confirmation
             # fill in code here
             keydir = self.config.get_key(args.seeds + "-keydir")
@@ -212,33 +211,25 @@ class Actions(object):
             self.gpg = GkeysGPG(self.config, keydir)
             results = {}
             failed = []
-            for key in keyresults:
-                if not key.keyid and not key.longkeyid and not args.nick == '*':
-                    self.logger.debug("ACTIONS: addkey; NO key id's to add... Ignoring")
-                    return {"Failed: No keyid's found for %s" % key.name: ''}
-                elif not key.keyid and not key.longkeyid:
-                    print("No keyid's found for:", key.nick, key.name, "Skipping...")
-                    failed.append(key)
-                    continue
+            for key in gkey:
                 self.logger.debug("ACTIONS: addkey; adding key:")
                 self.logger.debug("ACTIONS: " + str(key))
-                results[key.name[0]] = self.gpg.add_key(key)
-                for result in results[key.name[0]]:
+                results[key.name] = self.gpg.add_key(key)
+                for result in results[key.name]:
                     self.logger.debug("ACTIONS: addkey; result.failed = " +
-                        str(result.failed))
+                                      str(result.failed))
                 if self.config.options['print_results']:
-                    for result in results[key.name[0]]:
+                    for result in results[key.name]:
                         print("key desired:", key.name, ", key added:",
                             result.username, ", succeeded:",
-                            not result.failed, ", keyid:", result.keyid,
-                            ", fingerprint:", result.fingerprint)
+                            not result.failed,", fingerprint:", result.fingerprint)
                         self.logger.debug("stderr_out: " + str(result.stderr_out))
                         if result.failed:
                             failed.append(key)
             if failed and self.output:
                 self.output(failed, "\n Failed to install:")
-            return {'Completed': True}
-        return {"No seeds to search or install": False}
+            return ["Completed"]
+        return ["No seeds to search or install"]
 
 
     def removekey(self, args):

diff --git a/gkeys/fileops.py b/gkeys/fileops.py
index 03014d9..da56f2e 100644
--- a/gkeys/fileops.py
+++ b/gkeys/fileops.py
@@ -1,4 +1,34 @@
 import os
+from snakeoil.osutils import (ensure_dirs as snakeoil_ensure_dirs)
+
+
+def ensure_dirs(path, gid=-1, uid=-1, mode=0700, minimal=True, failback=None, fatal=False):
+    '''Wrapper to snakeoil.osutil's ensure_dirs()
+    This additionally allows for failures to run
+    cleanup or other code and/or raise fatal errors.
+
+    @param path: directory to ensure exists on disk
+    @param gid: a valid GID to set any created directories to
+    @param uid: a valid UID to set any created directories to
+    @param mode: permissions to set any created directories to
+    @param minimal: boolean controlling whether or not the specified mode
+        must be enforced, or is the minimal permissions necessary.  For example,
+        if mode=0755, minimal=True, and a directory exists with mode 0707,
+        this will restore the missing group perms resulting in 757.
+    @param failback: function to run in the event of a failed attemp
+        to create the directory.
+    @return: True if the directory could be created/ensured to have those
+        permissions, False if not.
+    '''
+    succeeded = snakeoil_ensure_dirs(path, gid=-1, uid=-1, mode=0700, minimal=True)
+    if not succeeded:
+        if failback:
+            failback()
+        if fatal:
+            raise IOError(
+                "Failed to create directory: %s" % path)
+    return succeeded
+
 
 def updatefiles(config, logger):
         filename = config['dev-seedfile']

diff --git a/gkeys/lib.py b/gkeys/lib.py
index c10f9ce..b888367 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -20,13 +20,12 @@ with gentoo-keys specific convienience functions.
 from __future__ import print_function
 
 
-import os
 from os.path import join as pjoin
 
 from pyGPG.gpg import GPG
+from gkeys.fileops import ensure_dirs
 from gkeys.log import logger
 
-
 class GkeysGPG(GPG):
     '''Gentoo-keys primary gpg class'''
 
@@ -77,7 +76,7 @@ class GkeysGPG(GPG):
 
     def set_keydir(self, keydir, task, reset=True):
         logger.debug("basedir: %s, keydir: %s" % (self.basedir, keydir))
-        self.keydir = pjoin(self.basedir, keydir[0])
+        self.keydir = pjoin(self.basedir, keydir)
         self.task = task
         if reset:
             self.config.options['tasks'][task] = self.config.defaults['tasks'][task][:]
@@ -96,8 +95,8 @@ class GkeysGPG(GPG):
         self.set_keyserver()
         self.set_keydir(gkey.keydir, 'recv-keys', reset=True)
         self.set_keyring('pubring.gpg', 'recv-keys', reset=False)
-        if not os.path.exists(self.keydir):
-            os.makedirs(self.keydir, mode=0x0700)
+        logger.debug("LIB: add_key; ensure dirs: " + self.keydir)
+        ensure_dirs(str(self.keydir))
         keyids = gkey.keyid
         results = []
         for keyid in keyids:


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-08-20  3:55 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-08-20  3:55 UTC (permalink / raw
  To: gentoo-commits

commit:     58d9bbc078e6714e4a9ae1975576428bc355bdc0
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 30 17:41:08 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Jun 30 17:41:08 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=58d9bbc0

add seed file installed db

---
 gkeys/lib.py  | 41 ++++++++++++++++++++++++++---------------
 gkeys/seed.py | 34 +++++++++++++++++++---------------
 2 files changed, 45 insertions(+), 30 deletions(-)

diff --git a/gkeys/lib.py b/gkeys/lib.py
index b888367..c80cff6 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -25,6 +25,7 @@ from os.path import join as pjoin
 from pyGPG.gpg import GPG
 from gkeys.fileops import ensure_dirs
 from gkeys.log import logger
+from gkeys.seed import Seeds
 
 class GkeysGPG(GPG):
     '''Gentoo-keys primary gpg class'''
@@ -90,38 +91,44 @@ class GkeysGPG(GPG):
         '''Add the specified key to the specified keydir
 
         @param gkey: GKEY namedtuple with
-            (name, keyid/longkeyid, keydir, fingerprint,)
+            (name, nick, keydir, fingerprint)
         '''
         self.set_keyserver()
         self.set_keydir(gkey.keydir, 'recv-keys', reset=True)
         self.set_keyring('pubring.gpg', 'recv-keys', reset=False)
+        # Save the gkey seed to the installed db
+        self.set_keyseedfile()
+        self.seedfile.update(gkey)
+        if not self.seedfile.save():
+            logger.error("GkeysGPG.add_key(); failed to save seed" + gkey.nick)
+            return []
         logger.debug("LIB: add_key; ensure dirs: " + self.keydir)
         ensure_dirs(str(self.keydir))
-        keyids = gkey.keyid
+        fingerprints = gkey.fingerprint
         results = []
-        for keyid in keyids:
-            logger.debug("LIB: add_key; final keyids" + keyid)
+        for fingerprint in fingerprints:
+            logger.debug("LIB: add_key; adding fingerprint" + fingerprint)
             logger.debug("** Calling runGPG with Running 'gpg %s --recv-keys %s' for: %s"
                 % (' '.join(self.config.get_key('tasks', 'recv-keys')),
-                    keyid, gkey.name)
-                )
-            result = self.runGPG(task='recv-keys', inputfile=keyid)
+                    fingerprint, gkey.name))
+            result = self.runGPG(task='recv-keys', inputfile=fingerprint)
             logger.info('GPG return code: ' + str(result.returncode))
             if result.fingerprint in gkey.fingerprint:
                 result.failed = False
                 message = "Fingerprints match... Import successful: "
-                message += "key: %s" %keyid
-                message += "\n    result len: %s, %s" %(len(result.fingerprint), result.fingerprint)
-                message += "\n    gkey len: %s, %s" %(len(gkey.fingerprint[0]), gkey.fingerprint[0])
+                message += "fingerprint: %s" % fingerprint
+                message += "\n result len: %s, %s" % (len(result.fingerprint), result.fingerprint)
+                message += "\n gkey len: %s, %s" % (len(gkey.fingerprint[0]), gkey.fingerprint[0])
                 logger.info(message)
             else:
                 result.failed = True
                 message = "Fingerprints do not match... Import failed for "
-                message += "key: %s" %keyid
-                message += "\n     result:   %s" %(result.fingerprint)
-                message += "\n     gkey..: %s" %(str(gkey.fingerprint))
+                message += "fingerprint: %s" % fingerprint
+                message += "\n result: %s" % (result.fingerprint)
+                message += "\n gkey..: %s" % (str(gkey.fingerprint))
                 logger.error(message)
             results.append(result)
+            print("lib.add_key(), result =")
             print(result.stderr_out)
         return results
 
@@ -129,7 +136,7 @@ class GkeysGPG(GPG):
     def del_key(self, gkey, keydir):
         '''Delete the specified key in the specified keydir
 
-        @param gkey: GKEY namedtuple with (name, keyid/longkeyid, fingerprint)
+        @param gkey: GKEY namedtuple with (name, nick, keydir, fingerprint)
         '''
         return []
 
@@ -143,7 +150,7 @@ class GkeysGPG(GPG):
     def update_key(self, gkey, keydir):
         '''Update the specified key in the specified keydir
 
-        @param key: tuple of (name, keyid, fingerprint)
+        @param key: tuple of (name, nick, keydir, fingerprint)
         @param keydir: the keydir to add the key to
         '''
         return []
@@ -195,3 +202,7 @@ class GkeysGPG(GPG):
         '''Verify the file specified at filepath
         '''
         pass
+
+    def set_keyseedfile(self):
+        self.seedfile = Seeds(pjoin(self.keydir, 'gkey.seeds'))
+        self.seedfile.load()

diff --git a/gkeys/seed.py b/gkeys/seed.py
index 9dfa955..cfb2b98 100644
--- a/gkeys/seed.py
+++ b/gkeys/seed.py
@@ -88,20 +88,17 @@ class Seeds(object):
         return False
 
 
-    def delete(self, gkey=None, index=None):
+    def delete(self, gkey=None):
         '''Delete the key from the seeds in memory
 
         @param gkey: GKEY, the matching GKEY to delete
-        @param index: int, '''
+        '''
         if gkey:
             try:
-                self.seeds.pop(getattr(gkey[0], 'nick'), None)
+                self.seeds.pop(gkey.nick, None)
             except ValueError:
                 return False
             return True
-        elif index:
-            self.seeds.pop(index)
-            return True
 
 
     def list(self, **kwargs):
@@ -125,19 +122,16 @@ class Seeds(object):
         '''Search for the keys matching the regular expression pattern'''
         pass
 
+    def nick_search(self, nick):
+        '''Searches the seeds for a matching nick
 
-    def index(self, gkey):
-        '''The index of the gkey in the seeds list
-
-        @param gkey: GKEY, the matching GKEY to delete
-        @return int
+        @param nick: string
+        @returns GKEY instance or None
         '''
         try:
-            index = self.seeds.index(gkey)
-        except ValueError:
+            return self.seeds[nick]
+        except KeyError:
             return None
-        return index
-
 
     def _error(self, err):
         '''Class error logging function'''
@@ -153,3 +147,13 @@ class Seeds(object):
             if is_gkey:
                 seeds[dev] = dict(value._asdict())
         return json.dumps(seeds, sort_keys=True, indent=4)
+
+    def update(self, gkey):
+        '''Looks for existance of a matching nick already in the seedfile
+        if it exists. Then either adds or replaces the gkey
+        @param gkey: GKEY instance
+        '''
+        oldkey = self.nick_search(gkey.nick[0])
+        if oldkey:
+            self.delete(oldkey)
+        self.add(gkey.nick, gkey)


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-08-20  3:55 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-08-20  3:55 UTC (permalink / raw
  To: gentoo-commits

commit:     4bec13f6418b180d08daa0f59580c237676d0b05
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 16 23:56:41 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug 17 00:06:01 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=4bec13f6

make list-keys more flexible

---
 gkeys/actions.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index a3c28c8..b80f203 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -145,8 +145,6 @@ class Actions(object):
 
     def listkey(self, args):
         '''Pretty-print the selected seed file or nick'''
-        if not args.nick:
-            return ["Too many seeds found. Consider using -n <nick> option."]
         # get the desired seed
         keyresults = self.listseed(args)[1]
         if not keyresults:


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-08-20  3:55 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-08-20  3:55 UTC (permalink / raw
  To: gentoo-commits

commit:     f968a0f31db4acd8bad157cf57f2ad0206a5fafa
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 16 23:42:42 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug 17 00:06:01 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=f968a0f3

create GKEY_CHECKS, a namedtuple used in gkey checks

---
 gkeys/config.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gkeys/config.py b/gkeys/config.py
index 6b9888e..d353cbb 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -145,3 +145,7 @@ class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
             fingerprint = {'fingerprint': f, 'keyid': '0x' + f[-16:]}
             output += GKEY_FINGERPRINTS % fingerprint
         return output
+
+class GKEY_CHECK(namedtuple('GKEY_CHECK', ['keyid', 'revoked', 'expired', 'invalid', 'sign'])):
+
+    __slots__ = ()


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-08-20  3:55 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-08-20  3:55 UTC (permalink / raw
  To: gentoo-commits

commit:     adcf14d0464bf339541542338f32425f3b0dabae
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 00:18:14 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug 17 00:20:35 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=adcf14d0

add support for gkey checks

Features:
    * Enable colons listing
    * Checks for expired, invalid and revoked keys
    * Checks for keys capabilities

---
 gkeys/actions.py | 38 +++++++++++++++++++++++++++++++++++++-
 gkeys/lib.py     | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 88 insertions(+), 4 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index b80f203..030424f 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -14,6 +14,7 @@ from __future__ import print_function
 
 import os
 
+from collections import defaultdict
 from json import load
 from shutil import rmtree
 from sslfetch.connections import Connector
@@ -24,7 +25,7 @@ from gkeys.config import GKEY
 
 Available_Actions = ['listseed', 'addseed', 'removeseed', 'moveseed', 'fetchseed',
             'listseedfiles', 'listkey', 'installkey', 'removekey', 'movekey',
-            'installed', 'importkey', 'verify']
+            'installed', 'importkey', 'verify', 'checkkey']
 
 
 class Actions(object):
@@ -232,6 +233,41 @@ class Actions(object):
             return ["Completed"]
         return ["No seeds to search or install"]
 
+    def checkkey(self, args):
+        '''Check keys actions'''
+        if not args.seeds:
+            return ["Please specify seeds type (-s)."]
+        self.logger.debug("ACTIONS: checkkey; args: %s" % str(args))
+        installed_keys = self.installed(args)[1]
+        keydir = self.config.get_key(args.seeds + "-keydir")
+        self.logger.debug("ACTIONS: checkkey; keysdir = %s" % keydir)
+        self.gpg = GkeysGPG(self.config, keydir)
+        results = {}
+        failed = defaultdict(list)
+        self.output('', '\n Checking keys...')
+        for gkey in installed_keys:
+            self.logger.debug("ACTIONS: checkkey; gkey = %s" % gkey)
+            for key in gkey.keyid:
+                results[gkey.name] = self.gpg.check_keys(gkey.keydir, key)
+                if results[gkey.name].expired:
+                    failed['expired'].append("%s(%s): %s" % (gkey.name, gkey.nick, key))
+                if results[gkey.name].revoked:
+                    failed['revoked'].append("%s(%s): %s" % (gkey.name, gkey.nick, key))
+                if results[gkey.name].invalid:
+                    failed['invalid'].append("%s(%s): %s" % (gkey.name, gkey.nick, key))
+                if not results[gkey.name].sign:
+                    failed['sign'].append("%s(%s): %s " % (gkey.name, gkey.nick, key))
+        if failed['expired']:
+            self.output([failed['expired']], '\nExpired keys:\n')
+        if failed['revoked']:
+            self.output([failed['revoked']], '\nRevoked keys:\n')
+        if failed['invalid']:
+            self.output([failed['invalid']], '\nInvalid keys:\n')
+        if failed['sign']:
+            self.output([failed['sign']], '\nNo signing capabilities keys:\n')
+        return ['\nFound:\n-------', 'Expired: %d\nRevoked: %d\nInvalid: %d\nNo signing capabilities: %d'
+                % (len(failed['expired']), len(failed['revoked']),
+                    len(failed['invalid']), len(failed['sign']))]
 
     def removekey(self, args):
         '''Remove an installed key'''

diff --git a/gkeys/lib.py b/gkeys/lib.py
index 0a23d2b..a8af408 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -24,6 +24,7 @@ from os.path import abspath, pardir
 from os.path import join as pjoin
 
 from pyGPG.gpg import GPG
+from gkeys.config import GKEY_CHECK
 from gkeys.fileops import ensure_dirs
 from gkeys.log import logger
 from gkeys.seed import Seeds
@@ -184,27 +185,74 @@ class GkeysGPG(GPG):
         return []
 
 
-    def list_keys(self, keydir):
+    def list_keys(self, keydir, colons=False):
         '''List all keys in the specified keydir or
         all keys in all keydir if keydir=None
 
         @param keydir: the keydir to list the keys for
+        @param colons: bool to enable colon listing
         '''
         if not keydir:
             logger.debug("LIB: list_keys(), invalid keydir parameter: %s"
                 % str(keydir))
             return []
         self.set_keydir(keydir, 'list-keys')
-        if '--with-colons' in self.config['tasks']['list-keys']:
-            self.config['tasks']['list-keys'].remove('--with-colons')
         logger.debug("** Calling runGPG with Running 'gpg %s --list-keys %s'"
             % (' '.join(self.config['tasks']['list-keys']), keydir)
             )
+        if colons:
+            task_value = ['--with-colons']
+            self.config.options['tasks']['list-keys'].extend(task_value)
         result = self.runGPG(task='list-keys', inputfile=keydir)
         logger.info('GPG return code: ' + str(result.returncode))
         return result
 
 
+    def check_keys(self, keydir, keyid):
+        '''Check specified or all keys based on the seed type
+
+        @param keydir: the keydir to list the keys for
+        @param keyid: the keyid to check
+        '''
+        result = self.list_keys(keydir, colons=True)
+        revoked = expired = invalid = False
+        sign = True
+        for data in result.status.data:
+            if data.name ==  "PUB":
+                if data.long_keyid == keyid[2:]:
+                    # check if revoked
+                    if 'r' in data.validity:
+                        revoked = True
+                        logger.debug("ERROR in key %s : revoked" % data.long_keyid)
+                        break
+                    # if primary key expired, all subkeys expire
+                    if 'e' in data.validity:
+                        expired = True
+                        logger.debug("ERROR in key %s : expired" % data.long_keyid)
+                        break
+                    # check if invalid
+                    if 'i' in data.validity:
+                        invalid = True
+                        logger.debug("ERROR in key %s : invalid" % data.long_keyid)
+                        break
+            if data.name == "SUB":
+                if data.long_keyid == keyid[2:]:
+                    # check if subkey has signing capabilities
+                    if 's' not in data.key_capabilities:
+                        sign = False
+                        logger.debug("ERROR in subkey %s : No signing capabilities" % data.long_keyid)
+                    # check if expired
+                    if 'e' in data.validity:
+                        logger.debug("WARNING in subkey %s : expired" % data.long_keyid)
+                     # check if revoked
+                    if 'r' in data.validity:
+                        logger.debug("WARNING in subkey %s : revoked" % data.long_keyid)
+                    # check if invalid
+                    if 'i' in data.validity:
+                        logger.debug("WARNING in subkey %s : invalid" % data.long_keyid)
+        return GKEY_CHECK(keyid, revoked, expired, invalid, sign)
+
+
     def list_keydirs(self):
         '''List all available keydirs
         '''


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-08-20  3:55 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-08-20  3:55 UTC (permalink / raw
  To: gentoo-commits

commit:     2b7d8753f01c72d88a243a1e0600b8d9726057ed
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 11 10:17:35 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Aug 11 10:17:35 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=2b7d8753

add file verification support

File verification support allows users to verify files by either URLs or local files.
These files are verified against their signature and the installed release keys.

---
 gkeys/actions.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 gkeys/cli.py     |  5 +++++
 gkeys/lib.py     | 32 +++++++++++++++++++++------
 3 files changed, 96 insertions(+), 7 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 5d65552..115007c 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -16,6 +16,7 @@ import os
 
 from json import load
 from shutil import rmtree
+from sslfetch.connections import Connector
 
 from gkeys.lib import GkeysGPG
 from gkeys.seedhandler import SeedHandler
@@ -23,7 +24,7 @@ from gkeys.config import GKEY
 
 Available_Actions = ['listseed', 'addseed', 'removeseed', 'moveseed', 'fetchseed',
             'listseedfiles', 'listkey', 'installkey', 'removekey', 'movekey',
-            'installed', 'importkey']
+            'installed', 'importkey', 'verify']
 
 
 class Actions(object):
@@ -340,6 +341,69 @@ class Actions(object):
         '''
         pass
 
+    def verify(self, args):
+        '''File verification action'''
+        connector_output = {
+             'info': self.logger.debug,
+             'error': self.logger.error,
+             'kwargs-info': {},
+             'kwargs-error': {},
+        }
+        if not args.filename:
+            return ['Please provide a signed file.']
+        if not args.seeds:
+            return ['Please specifiy type of seed file.']
+        keys = self.installed(args)[1]
+        if not keys:
+            return ['No installed keys, try installkey action.']
+        keydir = self.config.get_key(args.seeds + "-keydir")
+        self.logger.debug("ACTIONS: verify; keysdir = %s" % keydir)
+        self.gpg = GkeysGPG(self.config, keydir)
+        filepath, signature  = args.filename, args.signature
+        isurl = success = False
+        if filepath.startswith('http'):
+            isurl = True
+            fetcher = Connector(connector_output, None, "Gentoo Keys")
+            self.logger.debug("ACTIONS: verify; fetching %s signed file " % filepath)
+            success, signedfile, timestamp = fetcher.fetch_file(filepath)
+        else:
+            filepath = os.path.abspath(filepath)
+            self.logger.debug("ACTIONS: verify; local file %s" % filepath)
+            success = os.path.isfile(filepath)
+        if not success:
+            messages = ["File %s cannot be retrieved." % filepath]
+        else:
+            if not signature:
+                EXTENSIONS = ['.asc','.sig','.gpgsig']
+                success_fetch = False
+                for ext in EXTENSIONS:
+                    signature = filepath + ext
+                    if isurl:
+                        self.logger.debug("ACTIONS: verify; fetching %s signature " % signature)
+                        success_fetch, sig, timestamp = fetcher.fetch_file(signature)
+                    else:
+                        signature = os.path.abspath(signature)
+                        self.logger.debug("ACTIONS: verify; checking %s signature " % signature)
+                        success_fetch = os.path.isfile(signature)
+                    if success_fetch:
+                        break
+            messages = []
+            #TODO: use file:// uri in the future
+            if isurl:
+                splitfile = filepath.split('/')[-1]
+                splitsig = signature.split('/')[-1]
+                filepath = os.path.abspath(splitfile)
+                signature = os.path.abspath(splitsig)
+            self.logger.info("Verifying file...")
+            for key in keys:
+                results = self.gpg.verify_file(key, signature, filepath)
+                keyid = key.keyid[0]
+                if results.verified[0]:
+                    messages = ["File %s has been successfully verified | %s (%s)." % (filepath, str(key.name), str(keyid))]
+                else:
+                    messages = ["File verification of %s failed | %s (%s)." % (filepath, str(key.name), str(keyid))]
+        return messages
+
 
     def listseedfiles(self, args):
         '''List seed files found in the configured seed directory'''

diff --git a/gkeys/cli.py b/gkeys/cli.py
index c8d5be7..dffda5c 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -84,6 +84,11 @@ class Main(object):
             help='The seeds file to use or update')
         parser.add_argument('-S', '--seedfile', dest='seedfile', default=None,
             help='The seedfile path to use')
+        parser.add_argument('-F', '--file', dest='filename', default=None,
+               help='The path/URL to use for the signed file')
+        parser.add_argument('-z','--signature', dest='signature', default=None,
+           help='The path/URL to use for the signature')
+
 
         subparsers = parser.add_subparsers(help='actions')
         for name in Available_Actions:

diff --git a/gkeys/lib.py b/gkeys/lib.py
index 4d150bb..0a23d2b 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -194,10 +194,9 @@ class GkeysGPG(GPG):
             logger.debug("LIB: list_keys(), invalid keydir parameter: %s"
                 % str(keydir))
             return []
+        self.set_keydir(keydir, 'list-keys')
         if '--with-colons' in self.config['tasks']['list-keys']:
             self.config['tasks']['list-keys'].remove('--with-colons')
-
-        self.set_keydir(keydir, 'list-keys')
         logger.debug("** Calling runGPG with Running 'gpg %s --list-keys %s'"
             % (' '.join(self.config['tasks']['list-keys']), keydir)
             )
@@ -213,7 +212,7 @@ class GkeysGPG(GPG):
 
 
     def verify_key(self, gkey):
-        '''verify the specified key from the specified keydir
+        '''Verify the specified key from the specified keydir
 
         @param gkey: GKEY namedtuple with (name, keyid/longkeyid, fingerprint)
         '''
@@ -226,10 +225,31 @@ class GkeysGPG(GPG):
         pass
 
 
-    def verify_file(self, filepath):
-        '''Verify the file specified at filepath
+    def verify_file(self, gkey, signature, filepath):
+        '''Verify the file specified at filepath or url
+
+        @param signature: string with the signature file
+        @param filepath: string with the path or url of the signed file
         '''
-        pass
+        if signature:
+            self.set_keydir(gkey.keydir, 'verify', reset=True)
+            logger.debug("** Calling runGPG with Running 'gpg %s --verify %s and %s'"
+                    % (' '.join(self.config['tasks']['verify']), signature, filepath))
+            results = self.runGPG(task='verify', inputfile=[signature,filepath])
+        else:
+            self.set_keydir(gkey.keydir, 'decrypt', reset=True)
+            logger.debug("** Calling runGPG with Running 'gpg %s --decrypt %s and %s'"
+                    % (' '.join(self.config['tasks']['decrypt']), filepath))
+            results = self.runGPG(task='decrypt', inputfile=filepath)
+        keyid = gkey.keyid[0]
+        if results.verified[0]:
+            logger.info("GPG verification succeeded. Name: %s / Key: %s" % (str(gkey.name), str(keyid)))
+            logger.info("\tSignature result:" + str(results.verified))
+        else:
+            logger.debug("GPG verification failed. Name: %s / Key: %s" % (str(gkey.name), str(keyid)))
+            logger.debug("\t Signature result:"+ str(results.verified))
+            logger.debug("LIB: verify; stderr_out:" + str(results.stderr_out))
+        return results
 
 
     def set_keyseedfile(self):


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-08-20  3:55 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-08-20  3:55 UTC (permalink / raw
  To: gentoo-commits

commit:     e0450438bf63d93d385e4c95013c5c603568702b
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 18:23:34 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug 17 22:07:11 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=e0450438

minor format fix

---
 gkeys/actions.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 030424f..03b5ce9 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -246,7 +246,7 @@ class Actions(object):
         failed = defaultdict(list)
         self.output('', '\n Checking keys...')
         for gkey in installed_keys:
-            self.logger.debug("ACTIONS: checkkey; gkey = %s" % gkey)
+            self.logger.debug("ACTIONS: checkkey; gkey = %s" % str(gkey))
             for key in gkey.keyid:
                 results[gkey.name] = self.gpg.check_keys(gkey.keydir, key)
                 if results[gkey.name].expired:


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-08-20  3:55 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-08-20  3:55 UTC (permalink / raw
  To: gentoo-commits

commit:     99f22c953e43669b0d12f065452b2015b3da6eda
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 16 23:36:09 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug 17 00:06:01 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=99f22c95

allow installed action to list specific keys

---
 gkeys/actions.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 1732391..a3c28c8 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -317,7 +317,11 @@ class Actions(object):
         self.logger.debug("ACTIONS: installed; keysdir = %s" % keydir)
         installed_keys = []
         try:
-            for key in os.listdir(keydir):
+            if args.nick:
+                keys = [args.nick]
+            else:
+                keys = os.listdir(keydir)
+            for key in keys:
                 seed_path = os.path.join(keydir, key)
                 gkey_path = os.path.join(seed_path, 'gkey.seeds')
                 try:


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-08-20  3:55 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-08-20  3:55 UTC (permalink / raw
  To: gentoo-commits

commit:     ee03a6a0cb087f9c4626d4d0b16cd915788dab07
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 16 23:39:16 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug 17 00:06:01 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=ee03a6a0

expand cli output cases

---
 gkeys/cli.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gkeys/cli.py b/gkeys/cli.py
index dffda5c..ed7ce5e 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -158,7 +158,11 @@ class Main(object):
             if isinstance(msg, str):
                 print(msg)
             else:
-                print("\n".join([x.pretty_print for x in msg]))
+                try:
+                    print("\n".join([x.pretty_print for x in msg]))
+                except AttributeError:
+                    for x in msg:
+                        print(x)
         print()
 
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-08-20  3:55 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-08-20  3:55 UTC (permalink / raw
  To: gentoo-commits

commit:     94da63014b80aa27cd0cdf0fc60a3440e66c2dc5
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 16 23:30:41 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug 17 00:06:01 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=94da6301

make installkey more flexible

---
 gkeys/actions.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 115007c..1732391 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -189,8 +189,6 @@ class Actions(object):
 
     def installkey(self, args):
         '''Install a key from the seed(s)'''
-        if not args.nick:
-            return ["Please provide a nickname or -n *"]
         handler = SeedHandler(self.logger, self.config)
         kwargs = handler.build_gkeydict(args)
         self.logger.debug("ACTIONS: installkey; kwargs: %s" % str(kwargs))


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-08-20  3:55 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-08-20  3:55 UTC (permalink / raw
  To: gentoo-commits

commit:     9eb0f80f177fbba10308aa8e31e328a367bcb451
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 22:03:18 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug 17 22:07:11 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=9eb0f80f

add the ability to pass external results to check_keys

---
 gkeys/lib.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gkeys/lib.py b/gkeys/lib.py
index 5f39cd3..4b4e975 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -208,13 +208,14 @@ class GkeysGPG(GPG):
         return result
 
 
-    def check_keys(self, keydir, keyid):
+    def check_keys(self, keydir, keyid, result=None):
         '''Check specified or all keys based on the seed type
 
         @param keydir: the keydir to list the keys for
         @param keyid: the keyid to check
         '''
-        result = self.list_keys(keydir, colons=True)
+        if not result:
+            result = self.list_keys(keydir, colons=True)
         revoked = expired = invalid = sign = False
         for data in result.status.data:
             if data.name ==  "PUB":


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-08-20  3:55 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-08-20  3:55 UTC (permalink / raw
  To: gentoo-commits

commit:     fcf9bc99b653b580954079ac0ea7461eaf2fc4e1
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 20:59:24 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug 17 22:07:11 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=fcf9bc99

key checking improvements

---
 gkeys/lib.py | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/gkeys/lib.py b/gkeys/lib.py
index a8af408..5f39cd3 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -215,8 +215,7 @@ class GkeysGPG(GPG):
         @param keyid: the keyid to check
         '''
         result = self.list_keys(keydir, colons=True)
-        revoked = expired = invalid = False
-        sign = True
+        revoked = expired = invalid = sign = False
         for data in result.status.data:
             if data.name ==  "PUB":
                 if data.long_keyid == keyid[2:]:
@@ -237,19 +236,22 @@ class GkeysGPG(GPG):
                         break
             if data.name == "SUB":
                 if data.long_keyid == keyid[2:]:
-                    # check if subkey has signing capabilities
-                    if 's' not in data.key_capabilities:
-                        sign = False
-                        logger.debug("ERROR in subkey %s : No signing capabilities" % data.long_keyid)
+                    # check if invalid
+                    if 'i' in data.validity:
+                        logger.debug("WARNING in subkey %s : invalid" % data.long_keyid)
+                        continue
                     # check if expired
                     if 'e' in data.validity:
                         logger.debug("WARNING in subkey %s : expired" % data.long_keyid)
-                     # check if revoked
+                        continue
+                    # check if revoked
                     if 'r' in data.validity:
                         logger.debug("WARNING in subkey %s : revoked" % data.long_keyid)
-                    # check if invalid
-                    if 'i' in data.validity:
-                        logger.debug("WARNING in subkey %s : invalid" % data.long_keyid)
+                        continue
+                    # check if subkey has signing capabilities
+                    if 's' in data.key_capabilities:
+                        sign = True
+                        logger.debug("INFO subkey %s : signing capabilities" % data.long_keyid)
         return GKEY_CHECK(keyid, revoked, expired, invalid, sign)
 
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     7e372d0da863d0b5ca89291801d3ed775a837080
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Wed Dec  3 12:49:45 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Dec  3 12:49:45 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=7e372d0d

support local/global config

---
 gkeys/config.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gkeys/config.py b/gkeys/config.py
index ae6e68c..7cefe92 100644
--- a/gkeys/config.py
+++ b/gkeys/config.py
@@ -65,8 +65,12 @@ class GKeysConfig(GPGConfig):
             self.defaults['config'] = config
             self.defaults['configdir'] = os.path.dirname(config)
         else:
-            self.defaults['configdir'] = path([self.root, EPREFIX, '/etc/gkeys'])
-            self.defaults['config'] = '%(configdir)s/gkeys.conf'
+            homedir = os.path.expanduser('~')
+            self.defaults['configdir'] = homedir
+            self.defaults['config']= os.path.join(homedir, '.gkeys.conf')
+            if not os.path.exists(self.defaults['config']):
+                self.defaults['configdir'] = path([self.root, EPREFIX, '/etc/gkeys'])
+                self.defaults['config'] = '%(configdir)s/gkeys.conf'
         self.configparser = None
         self._add_gkey_defaults()
         if read_configfile:


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     82c33b026e68e4f957ada51b3f51e21b265a5add
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec  1 20:05:50 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 19 21:17:01 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=82c33b02

gkeys/actions.py: Fix indent formatting on checkkeys()

---
 gkeys/actions.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index dc36f7c..91f76a5 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -332,9 +332,10 @@ class Actions(object):
         if failed['sign']:
             self.output([failed['sign']], '\n No signing capable subkeys:\n')
         return (len(failed) <1,
-            ['\nFound:\n-------', 'Expired: %d\nRevoked: %d\nInvalid: %d\nNo signing capable subkeys: %d'
-                % (len(failed['expired']), len(failed['revoked']),
-                    len(failed['invalid']), len(failed['sign']))
+            ['\nFound:\n-------', 'Expired: %d' % len(failed['expired']),
+                'Revoked: %d' % len(failed['revoked']),
+                'Invalid: %d' % len(failed['invalid']),
+                'No signing capable subkeys: %d' % len(failed['sign'])
             ])
 
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     62ee882e544cac60c9aeeeec784265bd2cfe1c35
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 11 00:52:09 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Dec 20 16:46:05 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=62ee882e

gkeys: Add refreshkey action and support code

---
 gkeys/actions.py | 30 ++++++++++++++++++++++++++++++
 gkeys/lib.py     | 18 ++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 4c430e7..5b534cb 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -27,6 +27,7 @@ from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn
 Available_Actions = ['listseed', 'addseed', 'removeseed', 'moveseed', 'fetchseed',
             'listseedfiles', 'listkey', 'installkey', 'removekey', 'movekey',
             'installed', 'importkey', 'verify', 'checkkey', 'sign', 'speccheck']
+            'refreshkey']
 
 Action_Options = {
     'listseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile', 'file'],
@@ -45,6 +46,7 @@ Action_Options = {
     'checkkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
     'sign': ['nick', 'name', 'keydir', 'fingerprint', 'file', 'keyring'],
     'speccheck': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
+    'refreshkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
 }
 
 
@@ -733,3 +735,31 @@ class Actions(object):
                 )
                 success.append(True)
         return (False not in success, ['', msgs])
+
+
+    def refreshkey(self, args):
+        '''Calls gpg with the --refresh-keys option
+        for in place updates of the installed keys'''
+        if not args.category:
+            return (False, ["Please specify seeds type."])
+        self.logger.debug("ACTIONS: refreshkey; args: %s" % str(args))
+        handler = SeedHandler(self.logger, self.config)
+        seeds = handler.load_category(args.category)
+        catdir = self.config.get_key(args.category + "-category")
+        self.logger.debug("ACTIONS: refreshkey; catdir = %s" % catdir)
+        self.gpg = GkeysGPG(self.config, catdir)
+        results = {}
+        kwargs = handler.build_gkeydict(args)
+        keyresults = seeds.list(**kwargs)
+        self.output('', '\n Refreshig keys...')
+        for gkey in sorted(keyresults):
+            self.logger.info("Refreshig key %s, %s" % (gkey.nick, gkey.keyid))
+            self.output('', "  %s: %s" % (gkey.name, ', '.join(gkey.keyid)))
+            #self.output('', "  ===============")
+            self.logger.debug("ACTIONS: refreshkey; gkey = %s" % str(gkey))
+            results[gkey.keydir] = self.gpg.refresh_key(gkey)
+        return (True, ['Completed'])
+
+
+
+

diff --git a/gkeys/lib.py b/gkeys/lib.py
index d2b3119..50ed63e 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -179,6 +179,24 @@ class GkeysGPG(GPG):
         return []
 
 
+    def refresh_key(self, gkey):
+        '''Refresh the specified key in the specified keydir
+
+        @param key: tuple of (name, nick, keydir, fingerprint)
+        @param keydir: the keydir to add the key to
+        '''
+        self.config.defaults['gpg_defaults'].append('--no-permission-warning')
+        self.set_keyserver()
+        self.set_keydir(gkey.keydir, 'refresh-keys', reset=True)
+        self.set_keyring('pubring.gpg', 'refresh-keys', reset=False)
+        logger.debug("LIB: refresh_key, gkey: %s" % str(gkey))
+        logger.debug("** Calling runGPG with Running 'gpg %s --refresh-keys' for: %s"
+            % (' '.join(self.config.get_key('tasks', 'refresh-keys')), str(gkey)))
+        result = self.runGPG(task='refresh-keys', inputfile='')
+        logger.info('GPG return code: ' + str(result.returncode))
+        return result
+
+
     def update_key(self, gkey, keydir):
         '''Update the specified key in the specified keydir
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     8cdb30f524cf77267fc01c8813a98e89116a7406
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 11 16:37:34 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Dec 20 16:46:05 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=8cdb30f5

gkeys/cli.py: Split out a common CliBase class and base.py

---
 gkeys/{cli.py => base.py} |  78 +++++++++--------
 gkeys/cli.py              | 208 ++++------------------------------------------
 2 files changed, 59 insertions(+), 227 deletions(-)

diff --git a/gkeys/cli.py b/gkeys/base.py
similarity index 80%
copy from gkeys/cli.py
copy to gkeys/base.py
index 8adc9ef..48de147 100644
--- a/gkeys/cli.py
+++ b/gkeys/base.py
@@ -2,9 +2,10 @@
 #-*- coding:utf-8 -*-
 
 """
-    Gentoo-keys - cli.py
+    Gentoo-keys - base.py
 
-    Command line interface module
+    Command line interface argsparse options module
+    and common functions
 
     @copyright: 2012 by Brian Dolbec <dol-sen@gentoo.org>
     @license: GNU GPL2, see COPYING for details.
@@ -14,43 +15,31 @@ from __future__ import print_function
 
 
 import argparse
-import sys
 
 from gkeys import config, fileops, seed, lib
-from gkeys.actions import Actions, Available_Actions, Action_Options
-from gkeys.config import GKeysConfig
 from gkeys.log import log_levels, set_logger
 
 
+class CliBase(object):
+    '''Common cli and argsparse options class'''
 
-class Main(object):
-    '''Main command line interface class'''
 
-
-    def __init__(self, root=None, config=None, print_results=True):
-        """ Main class init function.
-
-        @param root: string, root path to use
-        """
-        self.root = root or "/"
-        self.config = config or GKeysConfig(root=root)
-        self.config.options['print_results'] = print_results
+    def __init__(self):
+        self.cli_config = {
+            'Actions': [],
+            'Available_Actions': [],
+            'Action_Options': [],
+            'prog': 'gkeys',
+            'description': 'Gentoo-keys manager program',
+            'epilog': '''Caution: adding untrusted keys to these keyrings can
+                be hazardous to your system!'''
+        }
+        self.config = None
         self.args = None
         self.seeds = None
         self.actions = None
 
 
-    def __call__(self, args=None):
-        if args:
-            return self.run(self.parse_args(args))
-        else:
-            return self.run(self.parse_args(sys.argv[1:]))
-
-
-    def _add_options(self, parser, options):
-        for opt in options:
-            getattr(self, '_option_%s' % opt)(parser)
-
     @staticmethod
     def _option_dest(parser=None):
         parser.add_argument('-d', '--dest', dest='destination', default=None,
@@ -95,6 +84,19 @@ class Main(object):
             help='The key or seed directory category to use or update')
 
     @staticmethod
+    def _option_cleankey(parser=None):
+        parser.add_argument('--clean-key',
+            dest='cleankey', default=False,
+            help='Clean the key from the keyring due to failures')
+
+    @staticmethod
+    def _option_cleanseed(parser=None):
+        parser.add_argument('--clean-seed',
+            dest='cleanseed', default=False,
+            help='Clean the seed from the seedfile due to failures.  '
+                'Used during binary keyring release creation.')
+
+    @staticmethod
     def _option_keydir(parser=None):
         parser.add_argument('-r', '--keydir', dest='keydir', default=None,
             help='The keydir to use, update or search for/in')
@@ -128,12 +130,11 @@ class Main(object):
         @param args: list
         @returns argparse.Namespace object
         '''
-        #logger.debug('MAIN: parse_args; args: %s' % args)
+        #logger.debug('CliBase: parse_args; args: %s' % args)
         parser = argparse.ArgumentParser(
-            prog='gkeys',
-            description='Gentoo-keys manager program',
-            epilog='''Caution: adding untrusted keys to these keyrings can
-                be hazardous to your system!''')
+            prog=self.cli_config['prog'],
+            description=self.cli_config['description'],
+            epilog=self.cli_config['epilog'])
 
         # options
         parser.add_argument('-c', '--config', dest='config', default=None,
@@ -144,8 +145,8 @@ class Main(object):
 
 
         subparsers = parser.add_subparsers(help='actions')
-        for name in Available_Actions:
-            action_method = getattr(Actions, name)
+        for name in self.cli_config['Available_Actions']:
+            action_method = getattr(self.cli_config['Actions'], name)
             actiondoc = action_method.__doc__
             try:
                 text = actiondoc.splitlines()[0]
@@ -157,11 +158,16 @@ class Main(object):
                 description=actiondoc,
                 formatter_class=argparse.RawDescriptionHelpFormatter)
             action_parser.set_defaults(action=name)
-            self._add_options(action_parser, Action_Options[name])
+            self._add_options(action_parser, self.cli_config['Action_Options'][name])
 
         return parser.parse_args(args)
 
 
+    def _add_options(self, parser, options):
+        for opt in options:
+            getattr(self, '_option_%s' % opt)(parser)
+
+
     def run(self, args):
         '''Run the args passed in
 
@@ -196,7 +202,7 @@ class Main(object):
                 % args.config)
 
         # establish our actions instance
-        self.actions = Actions(self.config, self.output_results, logger)
+        self.actions = self.cli_config['Actions'](self.config, self.output_results, logger)
 
         # run the action
         func = getattr(self.actions, '%s' % args.action)

diff --git a/gkeys/cli.py b/gkeys/cli.py
index 8adc9ef..32d2ec4 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -13,17 +13,15 @@
 from __future__ import print_function
 
 
-import argparse
 import sys
 
-from gkeys import config, fileops, seed, lib
+from gkeys.base import CliBase
 from gkeys.actions import Actions, Available_Actions, Action_Options
 from gkeys.config import GKeysConfig
-from gkeys.log import log_levels, set_logger
 
 
 
-class Main(object):
+class Main(CliBase):
     '''Main command line interface class'''
 
 
@@ -32,201 +30,29 @@ class Main(object):
 
         @param root: string, root path to use
         """
+        CliBase.__init__(self)
         self.root = root or "/"
         self.config = config or GKeysConfig(root=root)
         self.config.options['print_results'] = print_results
-        self.args = None
-        self.seeds = None
-        self.actions = None
+        self.cli_config = {
+            'Actions': Actions,
+            'Available_Actions': Available_Actions,
+            'Action_Options': Action_Options,
+            'prog': 'gkeys',
+            'description': 'Gentoo-keys manager program',
+            'epilog': '''Caution: adding untrusted keys to these keyrings can
+                be hazardous to your system!'''
+        }
 
 
     def __call__(self, args=None):
+        """Main class call function
+
+        @param args: Optional list of argumanets to parse and action to run
+                     Defaults to sys.argv[1:]
+        """
         if args:
             return self.run(self.parse_args(args))
         else:
             return self.run(self.parse_args(sys.argv[1:]))
 
-
-    def _add_options(self, parser, options):
-        for opt in options:
-            getattr(self, '_option_%s' % opt)(parser)
-
-    @staticmethod
-    def _option_dest(parser=None):
-        parser.add_argument('-d', '--dest', dest='destination', default=None,
-            help='The destination seed file or keydir for move, copy operations')
-
-    @staticmethod
-    def _option_fingerprint(parser=None):
-        parser.add_argument('-f', '--fingerprint', dest='fingerprint',
-            default=None, nargs='+',
-            help='The fingerprint of the the key')
-
-    @staticmethod
-    def _option_gpgsearch(parser=None):
-        parser.add_argument('-g', '--gpgsearch', dest='gpgsearch', default=None,
-            help='Do a gpg search operations, rather than a gkey search')
-
-    @staticmethod
-    def _option_keyid(parser=None):
-        parser.add_argument('-i', '--keyid', dest='keyid', default=None,
-            nargs='+',
-            help='The long keyid of the gpg key to search for')
-
-    @staticmethod
-    def _option_keyring(parser=None):
-        parser.add_argument('-k', '--keyring', dest='keyring', default='trusted_keyring',
-            help='The name of the keyring to use')
-
-    @staticmethod
-    def _option_nick(parser=None):
-        parser.add_argument('-n', '--nick', dest='nick', default=None,
-            help='The nick associated with the the key')
-
-    @staticmethod
-    def _option_name(parser=None):
-        parser.add_argument('-N', '--name', dest='name', nargs='*',
-            default=None, help='The name of the the key')
-
-    @staticmethod
-    def _option_category(parser=None):
-        parser.add_argument('-C', '--category',
-            choices=['rel', 'dev', 'overlays', 'sign'], dest='category', default=None,
-            help='The key or seed directory category to use or update')
-
-    @staticmethod
-    def _option_keydir(parser=None):
-        parser.add_argument('-r', '--keydir', dest='keydir', default=None,
-            help='The keydir to use, update or search for/in')
-
-    @staticmethod
-    def _option_seedfile(parser=None):
-        parser.add_argument('-S', '--seedfile', dest='seedfile', default=None,
-            help='The seedfile to use from the gkeys.conf file')
-
-    @staticmethod
-    def _option_file(parser=None):
-        parser.add_argument('-F', '--file', dest='filename', default=None,
-            nargs='+',
-            help='The path/URL to use for the (signed) file')
-
-    @staticmethod
-    def _option_signature(parser=None):
-        parser.add_argument('-s','--signature', dest='signature', default=None,
-           help='The path/URL to use for the signature')
-
-    @staticmethod
-    def _option_timestamp(parser=None):
-        parser.add_argument('-t', '--timestamp', dest='timestamp', type=bool,
-            default=False,
-            help='Turn on timestamp use')
-
-
-    def parse_args(self, args):
-        '''Parse a list of aruments
-
-        @param args: list
-        @returns argparse.Namespace object
-        '''
-        #logger.debug('MAIN: parse_args; args: %s' % args)
-        parser = argparse.ArgumentParser(
-            prog='gkeys',
-            description='Gentoo-keys manager program',
-            epilog='''Caution: adding untrusted keys to these keyrings can
-                be hazardous to your system!''')
-
-        # options
-        parser.add_argument('-c', '--config', dest='config', default=None,
-            help='The path to an alternate config file')
-        parser.add_argument('-D', '--debug', default='DEBUG',
-            choices=list(log_levels),
-            help='The logging level to set for the logfile')
-
-
-        subparsers = parser.add_subparsers(help='actions')
-        for name in Available_Actions:
-            action_method = getattr(Actions, name)
-            actiondoc = action_method.__doc__
-            try:
-                text = actiondoc.splitlines()[0]
-            except AttributeError:
-                text = ""
-            action_parser = subparsers.add_parser(
-                name,
-                help=text,
-                description=actiondoc,
-                formatter_class=argparse.RawDescriptionHelpFormatter)
-            action_parser.set_defaults(action=name)
-            self._add_options(action_parser, Action_Options[name])
-
-        return parser.parse_args(args)
-
-
-    def run(self, args):
-        '''Run the args passed in
-
-        @param args: list or argparse.Namespace object
-        '''
-        global logger
-        message = None
-        if not args:
-            message = "Main: run; invalid args argument passed in"
-        if isinstance(args, list):
-            args = self.parse_args(args)
-        if args.config:
-            self.config.defaults['config'] = args.config
-        # now make it load the config file
-        self.config.read_config()
-
-        # establish our logger and update it in the imported files
-        logger = set_logger('gkeys', self.config['logdir'], args.debug,
-            dirmode=int(self.config.get_key('permissions', 'directories'),0),
-            filemask=int(self.config.get_key('permissions', 'files'),0))
-        config.logger = logger
-        fileops.logger = logger
-        seed.logger = logger
-        lib.logger = logger
-
-        if message:
-            logger.error(message)
-
-        # now that we have a logger, record the alternate config setting
-        if args.config:
-            logger.debug("Main: run; Found alternate config request: %s"
-                % args.config)
-
-        # establish our actions instance
-        self.actions = Actions(self.config, self.output_results, logger)
-
-        # run the action
-        func = getattr(self.actions, '%s' % args.action)
-        logger.debug('Main: run; Found action: %s' % args.action)
-        success, results = func(args)
-        if not results:
-            print("No results found.  Check your configuration and that the",
-                "seed file exists.")
-            return success
-        if self.config.options['print_results'] and 'done' not in list(results):
-            self.output_results(results, '\n Gkey task results:')
-        return success
-
-
-    @staticmethod
-    def output_results(results, header):
-        # super simple output for the time being
-        if header:
-            print(header)
-        for msg in results:
-            if isinstance(msg, str):
-                print('    ', msg)
-            else:
-                try:
-                    print("\n".join([x.pretty_print for x in msg]))
-                except AttributeError:
-                    for x in msg:
-                        print('    ', x)
-        print()
-
-
-    def output_failed(self, failed):
-        pass


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     b2539fdf0cd2d1b7a7b8c554e079d8fba35fa5a5
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 28 21:12:02 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Dec 20 16:45:47 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=b2539fdf

gkeys/checks.py: Add GLEP spec checks

GlepCheck: Add pretty_print()
Use pretty_print()
Fix bug in expiry check
Move mapping constants to pyGPG/mappings.py
Add combinations of e,a, s to capbilities check.
Improve days handling for subkeys.
When an infinite expiredate is found in subkeys, reset the dispay days to the primary key days.
Improve capabilities checks, fix key_passed logic.
In some cases, it reported pass for glep requirements while also reporting the key not having a signing subkey.
Fix more tracking logic errors in the final glep pass/fail code.
Show 'e' type keys with '----' value for algorithm and bits.
Add caps, id reasons to pretty_print output.
Make the output formatting consistent using ljust().
Fix pretty_print primary key/subkey final grade text
Remove 'a' restriction on checks
Not checking authentication subkeys was causing wrong data to be displayed.
Even though these subkeys are ignored for the final spec pass/fail.
Change a logging.debug from ERROR to WARNING.
This delta_t change is not an error.
Create speccheck action.
Add 'Notice only' to No Encryption capable header.
Fix expire tracking for spec pass/fail.
Add nick to validation and spec check header.
Ignore ['a', 'e'] capabilities for algo, bits failures in the summary

---
 gkeys/actions.py | 135 ++++++++++++++++++++-
 gkeys/checks.py  | 353 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 gkeys/lib.py     |  20 +++-
 3 files changed, 494 insertions(+), 14 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 6ba63b7..762d305 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -22,10 +22,11 @@ from sslfetch.connections import Connector
 from gkeys.lib import GkeysGPG
 from gkeys.seedhandler import SeedHandler
 from gkeys.config import GKEY
+from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn
 
 Available_Actions = ['listseed', 'addseed', 'removeseed', 'moveseed', 'fetchseed',
             'listseedfiles', 'listkey', 'installkey', 'removekey', 'movekey',
-            'installed', 'importkey', 'verify', 'checkkey', 'sign']
+            'installed', 'importkey', 'verify', 'checkkey', 'sign', 'speccheck']
 
 Action_Options = {
     'listseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile', 'file'],
@@ -43,6 +44,7 @@ Action_Options = {
     'verify': ['dest', 'nick', 'name', 'keydir', 'fingerprint', 'category', 'file', 'signature', 'keyring', 'timestamp'],
     'checkkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
     'sign': ['nick', 'name', 'keydir', 'fingerprint', 'file', 'keyring'],
+    'speccheck': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
 }
 
 
@@ -311,7 +313,9 @@ class Actions(object):
         self.output('', '\n Checking keys...')
         for gkey in sorted(keyresults):
             self.logger.info("Checking key %s, %s" % (gkey.nick, gkey.keyid))
-            self.output('', "     %s: %s" % (gkey.name, ', '.join(gkey.keyid)))
+            self.output('',
+                "\n  %s, %s: %s" % (gkey.nick, gkey.name, ', '.join(gkey.keyid)) +
+                "\n  ==============================================")
             self.logger.debug("ACTIONS: checkkey; gkey = %s" % str(gkey))
             for key in gkey.keyid:
                 results[gkey.name] = self.gpg.check_keys(gkey.keydir, key)
@@ -339,6 +343,133 @@ class Actions(object):
             ])
 
 
+    def speccheck(self, args):
+        '''Check keys actions'''
+        if not args.category:
+            return (False, ["Please specify seeds type."])
+        self.logger.debug("ACTIONS: speccheck; args: %s" % str(args))
+        handler = SeedHandler(self.logger, self.config)
+        seeds = handler.load_category(args.category)
+        catdir = self.config.get_key(args.category + "-category")
+        self.logger.debug("ACTIONS: speccheck; catdir = %s" % catdir)
+        self.gpg = GkeysGPG(self.config, catdir)
+        results = {}
+        failed = defaultdict(list)
+        kwargs = handler.build_gkeydict(args)
+        keyresults = seeds.list(**kwargs)
+        self.output('', '\n Checking keys...')
+        for gkey in sorted(keyresults):
+            self.logger.info("Checking key %s, %s" % (gkey.nick, gkey.keyid))
+            self.output('',
+                "\n  %s, %s: %s" % (gkey.nick, gkey.name, ', '.join(gkey.keyid)) +
+                "\n  ==============================================")
+            self.logger.debug("ACTIONS: speccheck; gkey = %s" % str(gkey))
+            for key in gkey.keyid:
+                results = self.gpg.speccheck(gkey.keydir, key)
+                for g in results:
+                    pub_pass = {}
+                    for key in results[g]:
+                        self.output('', key.pretty_print())
+
+                        if key.key is "PUB":
+                            pub_pass = {
+                                'key': key,
+                                'pub': key.passed_spec,
+                                'sign': False,
+                                'encrypt': False,
+                                'auth': False,
+                                'signs': [],
+                                'encrypts': [],
+                                'authens': [],
+                                'final': False,
+                            }
+                        if key.key is "SUB":
+                            if key.sign_capable and key.passed_spec:
+                                pub_pass['signs'].append(key.passed_spec)
+                                pub_pass['sign'] = True
+                            if key.encrypt_capable:
+                                pub_pass['encrypts'].append(key.passed_spec)
+                                pub_pass['encrypt'] = True
+                            if key.capabilities == 'a':
+                                pub_pass['authens'].append(key.passed_spec)
+                                if key.passed_spec:
+                                    pub_pass['auth'] = True
+                        validity = key.validity.split(',')[0]
+                        if not key.expire and not 'r' in validity:
+                            failed['expired'].append("%s <%s>: %s" % (gkey.name, gkey.nick, key.fingerprint))
+                        if 'r' in validity:
+                            failed['revoked'].append("%s <%s>: %s" % (gkey.name, gkey.nick, key.fingerprint))
+                        if 'i' in validity:
+                            failed['invalid'].append("%s <%s>: %s" % (gkey.name, gkey.nick, key.fingerprint))
+                        if key.capabilities not in ['a', 'e']:
+                            if not key.algo:
+                                failed['algo'].append("%s <%s>: %s" % (gkey.name, gkey.nick, key.fingerprint))
+                            if not key.bits:
+                                failed['bits'].append("%s <%s>: %s" % (gkey.name, gkey.nick, key.fingerprint))
+                        if "Warning" in key.expire_reason:
+                            failed['warn'].append("%s <%s>: %s " % (gkey.name, gkey.nick, key.fingerprint))
+                    if True in pub_pass['signs']:
+                        pub_pass['sign'] = True
+                    if True in pub_pass['encrypts']:
+                        pub_pass['encrypt'] = True
+                    if not pub_pass['sign']:
+                        failed['sign'].append("%s <%s>: %s" % (gkey.name, gkey.nick, pub_pass['key'].fingerprint))
+                    if not pub_pass['encrypt']:
+                        failed['encrypt'].append("%s <%s>: %s" % (gkey.name, gkey.nick, pub_pass['key'].fingerprint))
+                    spec = "%s <%s>: %s" % (gkey.name, gkey.nick, pub_pass['key'].fingerprint)
+                    for k in ['pub', 'sign']:
+                        if pub_pass[k]:
+                            pub_pass['final'] = True
+                        else:
+                            pub_pass['final'] = False
+                            break
+                    if pub_pass['final']:
+                        if spec not in failed['spec-approved']:
+                            failed['spec-approved'].append(spec)
+                    else:
+                        if spec not in failed['spec']:
+                            failed['spec'].append(spec)
+                    sdata = convert_pf(pub_pass, ['pub', 'sign', 'final'])
+                    sdata = convert_yn(sdata, ['auth', 'encrypt'])
+                    self.output('', SPECCHECK_SUMMARY % sdata)
+
+        if failed['revoked']:
+            self.output([sorted(set(failed['revoked']))], '\n Revoked keys:')
+        if failed['invalid']:
+            self.output([sorted(set(failed['invalid']))], '\n Invalid keys:')
+        if failed['sign']:
+            self.output([sorted(set(failed['sign']))], '\n No signing capable subkey:')
+        if failed['encrypt']:
+            self.output([sorted(set(failed['encrypt']))], '\n No Encryption capable subkey (Notice only):')
+        if failed['algo']:
+            self.output([sorted(set(failed['algo']))], '\n Incorrect Algorithm:')
+        if failed['bits']:
+            self.output([sorted(set(failed['bits']))], '\n Incorrect bit length:')
+        if failed['expired']:
+            self.output([sorted(set(failed['expired']))], '\n Expiry keys:')
+        if failed['warn']:
+            self.output([sorted(set(failed['warn']))], '\n Expiry Warnings:')
+        if failed['spec']:
+            self.output([sorted(set(failed['spec']))], '\n Failed to pass SPEC requirements:')
+        if failed['spec-approved']:
+            self.output([sorted(set(failed['spec-approved']))], '\n SPEC Approved:')
+
+        return (len(failed) <1,
+            ['\nFound Failures:\n-------',
+                'Revoked................: %d' % len(set(failed['revoked'])),
+                'Invalid................: %d' % len(set(failed['invalid'])),
+                'No Signing subkey......: %d' % len(set(failed['sign'])),
+                'No Encryption subkey...: %d' % len(set(failed['encrypt'])),
+                'Algorithm..............: %d' % len(set(failed['algo'])),
+                'Bit length.............: %d' % len(set(failed['bits'])),
+                'Expiry.................: %d' % len(set(failed['expired'])),
+                'Expiry Warnings........: %d' % len(set(failed['warn'])),
+                'SPEC requirements......: %d' % len(set(failed['spec'])),
+                '=============================',
+                'SPEC Approved..........: %d' % len(set(failed['spec-approved'])),
+            ])
+
+
     def removekey(self, args):
         '''Remove an installed key'''
         if not args.nick:

diff --git a/gkeys/checks.py b/gkeys/checks.py
index 2d4be4c..db3d59f 100644
--- a/gkeys/checks.py
+++ b/gkeys/checks.py
@@ -9,42 +9,172 @@
     @license: GNU GPL2, see COPYING for details
 """
 
+import time
+from collections import namedtuple, OrderedDict
 
 from gkeys.config import GKEY_CHECK
 
+from pyGPG.mappings import (ALGORITHM_CODES, CAPABILITY_MAP,
+    KEY_VERSION_FPR_LEN, VALIDITY_MAP, INVALID_LIST,
+    VALID_LIST)
+
+
+SPEC_INDEX = {
+    'key': 0,
+    'capabilities': 1,
+    'fingerprint': 2,
+    'bits': 3,
+    'created': 4,
+    'expire': 5,
+    'encrypt_capable': 6,
+    'sign_capable': 7,
+    'algo': 8,
+    'version': 9,
+    'id': 10,
+    'days': 11,
+    'validity': 12,
+    'expire_reason': 13,
+    'long_caps': 14,  # long version of the capbilities
+    'caps': 15,
+    'caps_reason': 16,
+    'id_reason': 17,
+    'is_valid': 18,
+    'passed_spec': 19,
+}
+
+SPEC_INDEX = OrderedDict(sorted(SPEC_INDEX.items(), key=lambda t: t[1]))
+
+SPEC_STAT = ['', '','', False, False, False, False, False, False, False, False,
+    0, '', '', '', True, '', '', False, False]
 
 # Default glep 63 minimum gpg key specification
+# and approved options, limits
 TEST_SPEC = {
     'bits': {
         'DSA': 2048,
         'RSA': 2048,
         },
-    'expire': 36,      # in months
+    'expire': 3 * 365,      # in days
     'subkeys': {        # warning/error mode
-        'encryption': {
+        'encrypt': {
             'mode': 'notice',
-            'expire': -1,  # -1 is the primary key expirery
+            'expire': 3 * 365,
             },
         'sign': {
             'mode': 'error',
-            'expire': 12,
+            'expire': 365,
             },
         },
-    'type': ['DSA', 'RSA'],
-    'version': 4,
+    'algorithms': ['DSA', 'RSA', '1', '2', '3', '17'],
+    'versions': ['4'],
+    'qualified_id': '@gentoo.org',
 }
 
+# Final pass/fail fields and the pass value required
+TEST_REQUIREMENTS = {
+    'bits': True,
+    'created': True,
+    'expire': True,
+    'sign_capable': True,
+    'algo': True,
+    'version': True,
+    'id': True,
+    'is_valid': True,
+    'caps': True,
+}
+
+SECONDS_PER_DAY = 86400
+
+
+SPECCHECK_STRING = '''    ----------
+    Fingerprint......: %(fingerprint)s
+    Key type ........: %(key)s    Capabilities.: %(capabilities)s  %(long_caps)s
+    Algorithm........: %(algo)s   Bit Length...: %(bits)s
+    Create Date......: %(created)s   Expire Date..: %(expire)s
+    Key Version......: %(version)s   Validity.....: %(validity)s
+    Days till expiry.: %(days)s %(expire_reason)s
+    Capability.......: %(caps)s %(caps_reason)s
+    Qualified ID.....: %(id)s %(id_reason)s
+    This %(pub_sub)s.: %(passed_spec)s'''
+
+SPECCHECK_SUMMARY = '''    Key summary
+    primary..........: %(pub)s         signing subkey: %(sign)s
+    encryption subkey: %(encrypt)s  authentication subkey: %(auth)s
+    SPEC requirements: %(final)s
+'''
+
+def convert_pf(data, fields):
+    '''Converts dictionary items from True/False to Pass/Fail strings
+
+    @param data: dict
+    @param fields: list
+    @returns: dict
+    '''
+    for f in fields:
+        if data[f]:
+            data[f] = 'Pass'
+        else:
+            data[f] = 'Fail'
+    return data
+
+def convert_yn(data, fields):
+    '''Converts dictionary items from True/False to Yes/No strings
+
+    @param data: dict
+    @param fields: list
+    @returns: dict
+    '''
+    for f in fields:
+        if data[f]:
+            data[f] = 'Yes '
+        else:
+            data[f] = 'No  '
+    return data
+
+
+class SpecCheck(namedtuple("SpecKey", list(SPEC_INDEX))):
+
+    __slots__ = ()
+
+    def pretty_print(self):
+        data = self.convert_data()
+        output = SPECCHECK_STRING % (data)
+        return output
+
+
+    def convert_data(self):
+        data = dict(self._asdict())
+        data = convert_pf(data, ['algo', 'bits', 'caps', 'created', 'expire', 'id',
+            'passed_spec', 'version'])
+        for f in ['caps', 'id']:
+            data[f] = data[f].ljust(10)
+        data['validity'] += ', %s' % (VALIDITY_MAP[data['validity']])
+        days = data['days']
+        if days == float("inf"):
+            data['days'] = "infinite".ljust(10)
+        else:
+            data['days'] = str(int(data['days'])).ljust(10)
+        if data['capabilities'] == 'e':
+            data['algo'] = '----'
+            data['bits'] = '----'
+        if data['key'] =='PUB':
+            data['pub_sub'] = 'primary key'
+        else:
+            data['pub_sub'] = 'subkey.....'
+        return data
+
 
 class KeyChecks(object):
-    '''Primary gpg key validation and glep spec checks class'''
+    '''Primary gpg key validation and specifications checks class'''
 
-    def __init__(self, logger, spec=TEST_SPEC):
+    def __init__(self, logger, spec=TEST_SPEC, qualified_id_check=True):
         '''@param spec: optional gpg specification to test against
                         Defaults to TEST_SPEC
 
         '''
         self.logger = logger
         self.spec = spec
+        self.check_id = qualified_id_check
 
 
     def validity_checks(self, keydir, keyid, result):
@@ -97,8 +227,211 @@ class KeyChecks(object):
         return GKEY_CHECK(keyid, revoked, expired, invalid, sign)
 
 
-    def glep_check(self, keydir, keyid, result):
+    def spec_check(self, keydir, keyid, result):
         '''Performs the minimum specifications checks on the key'''
-        pass
+        self.logger.debug("SPEC_CHECK() : CHECKING: %s" % keyid)
+        results = {}
+        pub = None
+        stats = None
+        pub_days = 0
+        for data in result.status.data:
+            if data.name ==  "PUB":
+                if stats:
+                    stats = self._test_final(data, stats)
+                    results[pub.long_keyid].append(SpecCheck._make(stats))
+                pub = data
+                found_id = False
+                found_id_reason = ''
+                results[data.long_keyid] = []
+                stats = SPEC_STAT[:]
+                stats[SPEC_INDEX['key']] = data.name
+                stats[SPEC_INDEX['capabilities']] = data.key_capabilities
+                stats[SPEC_INDEX['validity']] = data.validity
+                stats = self._test_created(data, stats)
+                stats = self._test_algo(data, stats)
+                stats = self._test_bits(data, stats)
+                stats = self._test_expire(data, stats, pub_days)
+                pub_days = stats[SPEC_INDEX['days']]
+                stats = self._test_caps(data, stats)
+                stats = self._test_validity(data, stats)
+            elif data.name ==  "FPR":
+                pub = pub._replace(**{'fingerprint': data.fingerprint})
+                stats[SPEC_INDEX['fingerprint']] = data.fingerprint
+                stats = self._test_version(data, stats)
+            elif data.name ==  "UID":
+                stats = self._test_uid(data, stats)
+                if stats[SPEC_INDEX['id']] in [True, '-----']:
+                    found_id = stats[SPEC_INDEX['id']]
+                    found_id_reason = ''
+                    stats[SPEC_INDEX['id_reason']] = ''
+                else:
+                    found_id_reason = stats[SPEC_INDEX['id_reason']]
+            elif data.name == "SUB":
+                if stats:
+                    stats = self._test_final(data, stats)
+                    results[pub.long_keyid].append(SpecCheck._make(stats))
+                stats = SPEC_STAT[:]
+                stats[SPEC_INDEX['key']] = data.name
+                stats[SPEC_INDEX['capabilities']] = data.key_capabilities
+                stats[SPEC_INDEX['fingerprint']] = '%s' \
+                    % (data.long_keyid)
+                stats[SPEC_INDEX['id']] = found_id
+                stats[SPEC_INDEX['id_reason']] = found_id_reason
+                stats[SPEC_INDEX['validity']] = data.validity
+                stats = self._test_validity(data, stats)
+                stats = self._test_created(data, stats)
+                stats = self._test_algo(data, stats)
+                stats = self._test_bits(data, stats)
+                stats = self._test_expire(data, stats, pub_days)
+                stats = self._test_caps(data, stats)
+        if stats:
+            stats = self._test_final(data, stats)
+            results[pub.long_keyid].append(SpecCheck._make(stats))
+            stats = None
+        self.logger.debug("SPEC_CHECK() : COMPLETED: %s" % keyid)
+        return results
+
+
+    def _test_algo(self, data, stats):
+        algo = data.pubkey_algo
+        if algo in TEST_SPEC['algorithms']:
+            stats[SPEC_INDEX['algo']] = True
+        else:
+            self.logger.debug("ERROR in key %s : invalid Type: %s"
+                % (data.long_keyid, ALGORITHM_CODES[algo]))
+        return stats
+
+
+    def _test_bits(self, data, stats):
+        bits = int(data.keylength)
+        if data.pubkey_algo in TEST_SPEC['algorithms']:
+            if bits >= TEST_SPEC['bits'][ALGORITHM_CODES[data.pubkey_algo]]:
+                stats[SPEC_INDEX['bits']] = True
+            else:
+                self.logger.debug("ERROR in key %s : invalid Bit length: %d"
+                    % (data.long_keyid, bits))
+        return stats
+
+
+    def _test_version(self, data, stats):
+        fpr_l = len(data.fingerprint)
+        if KEY_VERSION_FPR_LEN[fpr_l] in TEST_SPEC['versions']:
+            stats[SPEC_INDEX['version']] = True
+        else:
+            self.logger.debug("ERROR in key %s : invalid gpg key version: %s"
+                % (data.long_keyid, KEY_VERSION_FPR_LEN[fpr_l]))
+        return stats
+
+
+    def _test_created(self, data, stats):
+        try:
+            created = float(data.creation_date)
+        except ValueError:
+            created = 0
+        if created <= time.time() :
+            stats[SPEC_INDEX['created']] = True
+        else:
+            self.logger.debug("ERROR in key %s : invalid gpg key creation date: %s"
+                % (data.long_keyid, data.creation_date))
+        return stats
+
+
+    def _test_expire(self, data, stats, pub_days):
+        if data.name in ["PUB"]:
+            delta_t = TEST_SPEC['expire']
+            stats = self._expire_check(data, stats, delta_t, pub_days)
+            return stats
+        else:
+            for cap in data.key_capabilities:
+                try:
+                    delta_t = TEST_SPEC['subkeys'][CAPABILITY_MAP[cap]]['expire']
+                except KeyError:
+                    self.logger.debug(
+                        "WARNING in capability key %s : setting delta_t to main expiry: %d"
+                        % (cap, TEST_SPEC['expire']))
+                    delta_t = TEST_SPEC['expire']
+                stats = self._expire_check(data, stats, delta_t, pub_days)
+                return stats
+
+
+    def _expire_check(self, data, stats, delta_t, pub_days):
+        today = time.time()
+        try:
+            expires = float(data.expiredate)
+        except ValueError:
+            expires = float("inf")
+        if data.name == 'SUB' and expires == float("inf"):
+            days = stats[SPEC_INDEX['days']] = pub_days
+        elif expires == float("inf"):
+            days = stats[SPEC_INDEX['days']] = expires
+        else:
+            days = stats[SPEC_INDEX['days']] = max(0, int((expires - today)/SECONDS_PER_DAY))
+        if days <= delta_t:
+            stats[SPEC_INDEX['expire']] = True
+        elif days > delta_t and not ('i' in data.validity or 'r' in data.validity):
+            stats[SPEC_INDEX['expire_reason']] = '<== Exceeds specification'
+        else:
+            self.logger.debug("ERROR in key %s : invalid gpg key expire date: %s"
+                % (data.long_keyid, data.expiredate))
+        if 0 < days < 30 and not ('i' in data.validity or 'r' in data.validity):
+            stats[SPEC_INDEX['expire_reason']] = '<== WARNING < 30 days'
+
+        return stats
+
+
+    def _test_caps(self, data, stats):
+        if 'e' in data.key_capabilities:
+            if 's' in data.key_capabilities or 'a' in data.key_capabilities:
+                stats[SPEC_INDEX['caps']] = False
+                stats[SPEC_INDEX['caps_reason']] = "<== Mixing of 'e' with 's' and/or 'a'"
+        if not stats[SPEC_INDEX['is_valid']]:
+            return stats
+        kcaps = []
+        for cap in data.key_capabilities:
+            if CAPABILITY_MAP[cap] and stats[SPEC_INDEX['caps']]:
+                kcaps.append(CAPABILITY_MAP[cap])
+                if cap in ["s"] and not data.name == "PUB":
+                    stats[SPEC_INDEX['sign_capable']] = True
+                elif cap in ["e"]:
+                    stats[SPEC_INDEX['encrypt_capable']] = True
+                elif cap not in CAPABILITY_MAP:
+                    stats[SPEC_INDEX['caps']] = False
+                    self.logger.debug("ERROR in key %s : unknown gpg key capability: %s"
+                        % (data.long_keyid, cap))
+        stats[SPEC_INDEX['long_caps']] = ', '.join(kcaps)
+        return stats
+
+
+    def _test_uid(self, data, stats):
+        if not self.check_id:
+            stats[SPEC_INDEX['id']] = '-----'
+            stats[SPEC_INDEX['id_reason']] = ''
+            return stats
+        if TEST_SPEC['qualified_id'] in data.user_ID :
+            stats[SPEC_INDEX['id']] = True
+            stats[SPEC_INDEX['id_reason']] = ''
+        else:
+            stats[SPEC_INDEX['id_reason']] = "<== '%s' user id not found" % TEST_SPEC['qualified_id']
+            self.logger.debug("Warning: No qualified ID found in key %s"
+                % (data.user_ID))
+        return stats
+
+
+    def _test_validity(self, data, stats):
+        if data.validity in VALID_LIST:
+            stats[SPEC_INDEX['is_valid']] = True
+        return stats
 
 
+    def _test_final(self, data, stats):
+        for test, result in TEST_REQUIREMENTS.items():
+            if ((stats[SPEC_INDEX['key']] == 'PUB' and test == 'sign_capable') or
+                (stats[SPEC_INDEX['capabilities']] == 'e' and test in ['algo', 'bits', 'sign_capable'])
+                or (stats[SPEC_INDEX['capabilities']] == 'a' and test in ['sign_capable'])):
+                continue
+            if stats[SPEC_INDEX[test]] == result:
+                stats[SPEC_INDEX['passed_spec']] = True
+            else:
+                stats[SPEC_INDEX['passed_spec']] = False
+                break
+        return stats

diff --git a/gkeys/lib.py b/gkeys/lib.py
index c27f85d..d2b3119 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -206,7 +206,7 @@ class GkeysGPG(GPG):
             task = 'list-keys'
             target = keydir
         self.set_keydir(keydir, task, fingerprint=True)
-        self.config.options['tasks'][task].extend(['--keyid-format', 'long'])
+        self.config.options['tasks'][task].extend(['--keyid-format', 'long', '--with-fingerprint'])
         if colons:
             task_value = ['--with-colons']
             self.config.options['tasks'][task].extend(task_value)
@@ -228,10 +228,26 @@ class GkeysGPG(GPG):
         '''
         if not result:
             result = self.list_keys(keydir, fingerprint=keyid, colons=True)
-        checker = KeyChecks(logger)
+        checker = KeyChecks(logger, qualified_id_check=True)
         return checker.validity_checks(keydir, keyid, result)
 
 
+    def speccheck(self, keydir, keyid, result=None):
+        '''Check specified or all keys based on the seed type
+        specifications are met.
+
+        @param keydir: the keydir to list the keys for
+        @param keyid: the keyid to check
+        @param result: optional pyGPG.output.GPGResult object
+        @returns: SpecCheck instance
+        '''
+        if not result:
+            result = self.list_keys(keydir, fingerprint=keyid, colons=True)
+        checker = KeyChecks(logger, qualified_id_check=True)
+        specchecks = checker.spec_check(keydir, keyid, result)
+        return specchecks
+
+
     def list_keydirs(self):
         '''List all available keydirs
         '''


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     cd4e3490d0dcf0d3242ba87b3c63f35e642380f9
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 13 16:36:24 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Dec 20 16:46:05 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=cd4e3490

gkeys/actions.py: Fix verify() traceback due to args.filename being a list

Create _option_1file() for single filename acceptance
The signature option takes only one sig.

---
 gkeys/actions.py | 6 +++---
 gkeys/base.py    | 5 +++++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 5b534cb..266db0f 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -30,19 +30,19 @@ Available_Actions = ['listseed', 'addseed', 'removeseed', 'moveseed', 'fetchseed
             'refreshkey']
 
 Action_Options = {
-    'listseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile', 'file'],
+    'listseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile', '1file'],
     'addseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile'],
     'removeseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile'],
     'moveseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile', 'dest'],
     'fetchseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile'],
     'listseedfiles': [],
     'listkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'gpgsearch', 'keyid'],
-    'installkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'seedfile', 'file'],
+    'installkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'seedfile', '1file'],
     'removekey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
     'movekey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'dest'],
     'installed': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
     'importkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
-    'verify': ['dest', 'nick', 'name', 'keydir', 'fingerprint', 'category', 'file', 'signature', 'keyring', 'timestamp'],
+    'verify': ['dest', 'nick', 'name', 'keydir', 'fingerprint', 'category', '1file', 'signature', 'keyring', 'timestamp'],
     'checkkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
     'sign': ['nick', 'name', 'keydir', 'fingerprint', 'file', 'keyring'],
     'speccheck': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],

diff --git a/gkeys/base.py b/gkeys/base.py
index d3f8227..0ec8a03 100644
--- a/gkeys/base.py
+++ b/gkeys/base.py
@@ -113,6 +113,11 @@ class CliBase(object):
             help='The path/URL to use for the (signed) file')
 
     @staticmethod
+    def _option_1file(parser=None):
+        parser.add_argument('-F', '--file', dest='filename', default=None,
+            help='The path/URL to use for the (signed) file')
+
+    @staticmethod
     def _option_signature(parser=None):
         parser.add_argument('-s','--signature', dest='signature', default=None,
            help='The path/URL to use for the signature')


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     1f9c0314396136e3e4c8a47c344d7d18f497c644
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 13 18:31:11 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Dec 20 16:46:05 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=1f9c0314

gkeys.base.py: Fix a unicode handling error in print_results()

---
 gkeys/base.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gkeys/base.py b/gkeys/base.py
index 0ec8a03..95142f9 100644
--- a/gkeys/base.py
+++ b/gkeys/base.py
@@ -238,7 +238,7 @@ class CliBase(object):
         if header:
             print(header)
         for msg in results:
-            if isinstance(msg, str):
+            if isinstance(msg, str) or isinstance(msg, unicode):
                 print('    ', msg)
             else:
                 try:


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     fbba703b0bc43527e575165debc7cc26a2ad645b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec  1 20:09:50 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 19 21:17:01 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=fbba703b

gkeys/lib.py: Add missed parameter docstring

---
 gkeys/lib.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gkeys/lib.py b/gkeys/lib.py
index 31afbce..6010e65 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -255,6 +255,7 @@ class GkeysGPG(GPG):
     def verify_file(self, gkey, signature, filepath):
         '''Verify the file specified at filepath or url
 
+        @param gkey: GKEY instance of the gpg key used to verify it
         @param signature: string with the signature file
         @param filepath: string with the path or url of the signed file
         '''


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     f44ff883cb5cc34b820415fda71d918c7800d4fd
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 10 01:41:46 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 19 21:17:01 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=f44ff883

gkeys/actions.py: Fix handler.fetch_seeds call for args.category to args.seedfile change

---
 gkeys/actions.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 91f76a5..6ba63b7 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -77,7 +77,7 @@ class Actions(object):
         '''Download the selected seed file(s)'''
         self.logger.debug("ACTIONS: fetchseed; args: %s" % str(args))
         handler = SeedHandler(self.logger, self.config)
-        success, messages = handler.fetch_seeds(args.category, args, self.verify)
+        success, messages = handler.fetch_seeds(args.seedfile, args, self.verify)
 
         messages.append("")
         messages.append("Fetch operation completed")


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     e63d6aa45def08338e8430c52ad9f9454f29f5dd
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec  8 03:45:12 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 19 21:17:01 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=e63d6aa4

gkeys/lib.py: Fix the fingerprint or keyid not being passed to lisy_keys()

---
 gkeys/lib.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gkeys/lib.py b/gkeys/lib.py
index 6010e65..c27f85d 100644
--- a/gkeys/lib.py
+++ b/gkeys/lib.py
@@ -227,7 +227,7 @@ class GkeysGPG(GPG):
         @returns: GKEY_CHECK instance
         '''
         if not result:
-            result = self.list_keys(keydir, colons=True)
+            result = self.list_keys(keydir, fingerprint=keyid, colons=True)
         checker = KeyChecks(logger)
         return checker.validity_checks(keydir, keyid, result)
 


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     2e3323ca17dc71abd93f6db7d388dfe869cedea4
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec  9 18:37:28 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 19 21:17:01 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=2e3323ca

seedhandler: fix missed filename rename to filepath

---
 gkeys/seedhandler.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gkeys/seedhandler.py b/gkeys/seedhandler.py
index 8e06fab..724af65 100644
--- a/gkeys/seedhandler.py
+++ b/gkeys/seedhandler.py
@@ -64,7 +64,7 @@ class SeedHandler(object):
         @param seedfile: string filepath of the file to load
         @return Seeds class instance of the file loaded
         '''
-        if not seedfile and not filename:
+        if not seedfile and not filepath:
             self.logger.error("SeedHandler: load_seeds; no filename to load: "
             "setting = %s.  Please use the -S or -F option to indicate: which seed "
             "file to use." % seedfile)


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     2c47e25e7ce807f274668bc562778a48b70cfbbc
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 10 19:42:11 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Dec 20 16:46:04 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=2c47e25e

gkeys/actions.py: Add missing file option

installkey did not work as it was expecting a possible filename arg.

---
 gkeys/actions.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 762d305..4c430e7 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -36,7 +36,7 @@ Action_Options = {
     'fetchseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile'],
     'listseedfiles': [],
     'listkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'gpgsearch', 'keyid'],
-    'installkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'seedfile'],
+    'installkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'seedfile', 'file'],
     'removekey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
     'movekey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'dest'],
     'installed': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     108fed19fe58011f349df5ef29053c84f41687ff
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 11 06:05:02 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Dec 20 16:46:05 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=108fed19

gkeys/cli.py: Add an end of block print() for data separation

---
 gkeys/cli.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gkeys/cli.py b/gkeys/cli.py
index 4c1e946..8adc9ef 100644
--- a/gkeys/cli.py
+++ b/gkeys/cli.py
@@ -225,6 +225,7 @@ class Main(object):
                 except AttributeError:
                     for x in msg:
                         print('    ', x)
+        print()
 
 
     def output_failed(self, failed):


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-22 23:11 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-22 23:11 UTC (permalink / raw
  To: gentoo-commits

commit:     a19faedec319a3c334f99956919a42a3727d99b3
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 13 18:30:30 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Dec 20 16:46:05 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=a19faede

gkeys/actions.py: Fix error due to sig_path not beining assigned

---
 gkeys/actions.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gkeys/actions.py b/gkeys/actions.py
index 266db0f..a224372 100644
--- a/gkeys/actions.py
+++ b/gkeys/actions.py
@@ -659,6 +659,8 @@ class Actions(object):
                         success_fetch = os.path.isfile(signature)
                     if success_fetch:
                         break
+            else:
+                sig_path = signature
             messages = []
             self.logger.info("Verifying file...")
             verified = False


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-24 19:59 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-24 19:59 UTC (permalink / raw
  To: gentoo-commits

commit:     8cb7883522dbbf3ba588376b7a5746644fe84309
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 24 19:57:45 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Dec 24 19:57:45 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=8cb78835

gkeys/setup.py: Fix gkeys.conf path, comment out gkeys.conf

---
 gkeys/setup.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gkeys/setup.py b/gkeys/setup.py
index 20b346e..52b75fa 100755
--- a/gkeys/setup.py
+++ b/gkeys/setup.py
@@ -31,8 +31,8 @@ setup(
     packages=['gkeys'],
     scripts=['bin/gkeys'],
     data_files=(
-        (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc'), ['etc/gkeys.conf']),
-        (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc'), ['etc/gkeys.conf.sample']),
+        #(os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc'), ['etc/gkeys/gkeys.conf']),
+        (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc'), ['etc/gkeys/gkeys.conf.sample']),
         ),
     license=__license__,
     long_description=open('README.md').read(),


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2014-12-24 20:05 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2014-12-24 20:05 UTC (permalink / raw
  To: gentoo-commits

commit:     1c062cfb335aa8606bc06b23ab541dd788446257
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 24 20:04:29 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Dec 24 20:04:29 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=1c062cfb

gkeys/setup.py:  Fix previous commit path correctly

---
 gkeys/setup.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gkeys/setup.py b/gkeys/setup.py
index 52b75fa..4beae57 100755
--- a/gkeys/setup.py
+++ b/gkeys/setup.py
@@ -31,8 +31,8 @@ setup(
     packages=['gkeys'],
     scripts=['bin/gkeys'],
     data_files=(
-        #(os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc'), ['etc/gkeys/gkeys.conf']),
-        (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc'), ['etc/gkeys/gkeys.conf.sample']),
+        #(os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc/gkeys/'), ['etc/gkeys.conf']),
+        (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc/gkeys/'), ['etc/gkeys.conf.sample']),
         ),
     license=__license__,
     long_description=open('README.md').read(),


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2015-08-09  3:44 Robin H. Johnson
  0 siblings, 0 replies; 75+ messages in thread
From: Robin H. Johnson @ 2015-08-09  3:44 UTC (permalink / raw
  To: gentoo-commits

commit:     e7a58972b32d87edcc5c6c30ab4340dcf923bb19
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Sun Aug  9 03:44:12 2015 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Sun Aug  9 03:44:12 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=e7a58972

Fix setup.py for gkeys-gpg tool.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 gkeys/setup.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gkeys/setup.py b/gkeys/setup.py
index 12a3632..7563230 100755
--- a/gkeys/setup.py
+++ b/gkeys/setup.py
@@ -83,8 +83,8 @@ setup(
     maintainer_email='gkeys@gentoo.org',
     url="https://wiki.gentoo.org/wiki/Project:Gentoo-keys",
     download_url='',
-    packages=['gkeys'],
-    scripts=['bin/gkeys'],
+    packages=['gkeys', 'gkeysgpg'],
+    scripts=['bin/gkeys', 'bin/gkeys-gpg'],
     data_files=[
         (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc/gkeys/'), ['etc/gkeys.conf']),
         (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc/gkeys/'), ['etc/gkeys.conf.sample']),


^ permalink raw reply related	[flat|nested] 75+ messages in thread

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/
@ 2016-06-01 15:16 Brian Dolbec
  0 siblings, 0 replies; 75+ messages in thread
From: Brian Dolbec @ 2016-06-01 15:16 UTC (permalink / raw
  To: gentoo-commits

commit:     0cb7bf0d8e0d4649f48631956eb3e8026b01639f
Author:     aeroniero33 <justthisthing <AT> gmail <DOT> com>
AuthorDate: Wed May 25 17:51:00 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Jun  1 15:14:14 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=0cb7bf0d

Added a requirements file

Changed the file format.

 gkeys/gkeys-requirements.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gkeys/gkeys-requirements.txt b/gkeys/gkeys-requirements.txt
new file mode 100644
index 0000000..6265d9b
--- /dev/null
+++ b/gkeys/gkeys-requirements.txt
@@ -0,0 +1,4 @@
+pygpgme
+gnupg
+http://dev.gentoo.org/~dolsen/releases/ssl-fetch/ssl-fetch-0.4.tar.gz/#egg=ssl-fetch
+snakeoil >= 0.6.5


^ permalink raw reply related	[flat|nested] 75+ messages in thread

end of thread, other threads:[~2016-06-01 15:16 UTC | newest]

Thread overview: 75+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-17  7:39 [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/ Brian Dolbec
  -- strict thread matches above, loose matches on Subject: below --
2016-06-01 15:16 Brian Dolbec
2015-08-09  3:44 Robin H. Johnson
2014-12-24 20:05 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-08-20  3:55 Brian Dolbec
2014-08-20  3:55 Brian Dolbec
2014-08-20  3:55 Brian Dolbec
2014-08-20  3:55 Brian Dolbec
2014-08-20  3:55 Brian Dolbec
2014-08-20  3:55 Brian Dolbec
2014-08-20  3:55 Brian Dolbec
2014-08-20  3:55 Brian Dolbec
2014-08-20  3:55 Brian Dolbec
2014-08-20  3:55 Brian Dolbec
2014-08-20  3:55 Brian Dolbec
2014-08-20  3:55 Brian Dolbec
2014-08-20  3:55 Brian Dolbec
2014-06-01 15:25 Brian Dolbec
2014-06-01 15:25 Brian Dolbec
2014-06-01 15:25 Brian Dolbec
2014-05-28  2:21 Brian Dolbec
2014-05-28  2:21 Brian Dolbec
2014-05-27 20:56 Brian Dolbec
2014-05-27 20:56 Brian Dolbec
2014-05-27 20:56 Brian Dolbec
2014-05-27 20:56 Brian Dolbec
2014-05-27 20:56 Brian Dolbec
2014-05-27 20:56 Brian Dolbec
2014-05-27 20:56 Brian Dolbec
2014-05-17 18:13 Brian Dolbec
2014-03-01 17:50 Pavlos Ratis
2014-03-01 17:50 Pavlos Ratis
2014-03-01 17:49 Pavlos Ratis
2014-03-01  0:07 Brian Dolbec
2014-02-28 23:56 Brian Dolbec
2014-02-28 20:21 Brian Dolbec
2013-11-17  7:39 Brian Dolbec
2013-11-17  7:39 Brian Dolbec
2013-11-17  7:39 Brian Dolbec
2013-11-17  7:39 Brian Dolbec
2013-11-15  9:16 Brian Dolbec
2013-07-16  0:50 Brian Dolbec
2013-07-16  0:50 Brian Dolbec
2013-07-16  0:50 Brian Dolbec
2013-07-16  0:50 Brian Dolbec
2013-07-16  0:50 Brian Dolbec
2013-07-06 19:02 Brian Dolbec
2013-07-06 19:02 Brian Dolbec
2013-06-23  7:13 Brian Dolbec
2013-06-23  7:13 Brian Dolbec
2013-06-23  7:13 Brian Dolbec
2013-06-23  7:13 Brian Dolbec
2013-06-23  7:13 Brian Dolbec
2013-06-23  7:13 Brian Dolbec
2012-12-10  4:56 Brian Dolbec
2012-12-10  4:56 Brian Dolbec
2012-12-10  3:26 Brian Dolbec
2012-12-10  3:26 Brian Dolbec
2012-12-10  3:26 Brian Dolbec
2012-12-10  3:26 Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox