public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeyldap/
@ 2013-06-23  7:13 Brian Dolbec
  0 siblings, 0 replies; 23+ messages in thread
From: Brian Dolbec @ 2013-06-23  7:13 UTC (permalink / raw
  To: gentoo-commits

commit:     fe6a6ccb65b0ef8b1df87d651357f478c99bf78c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 22 16:07:16 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 22 23:00:58 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=fe6a6ccb

filter results for 'active' devs only

---
 gkeyldap/cli.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index f3c2ced..c702bd2 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -148,6 +148,8 @@ class Main(object):
         filename = self.config['dev-seedfile'] + '.new'
         self.seeds = Seeds(filename)
         for dev in devs:
+            if devs[dev]['gentooStatus'][0] not in ['active']:
+                continue
             logger.debug("create_seedfile, dev = %s, %s" % (str(dev), str(devs[dev])))
             new_gkey = GKEY._make(self.build_gkeylist(devs[dev]))
             self.seeds.add(new_gkey)


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

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

commit:     4fb65a94659e77a4d5ca721bfe571d30d017bf45
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 22 18:11:19 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 22 23:00:58 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=4fb65a94

Add error output for missing data, comment out a debug statement

Error for 'undefined' in values obtained from ldap

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

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index 15e410e..d4971d0 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -194,7 +194,7 @@ class Main(object):
     @staticmethod
     def build_gkeylist(info):
         keyinfo = []
-        logger.debug("build_gkeylist, info = %s" % str(info))
+        #logger.debug("build_gkeylist, info = %s" % str(info))
         for x in GKEY._fields:
             field = gkey2ldap_map[x]
             if not field:
@@ -206,6 +206,9 @@ class Main(object):
                     value = values[0]
                 else:
                     value = values
+                if 'undefined' in values:
+                    logger.error('%s = "undefined" for %s, %s'
+                        %(field, info['uid'][0], info['cn'][0]))
                 keyinfo.append(value)
             except KeyError:
                 logger.error("Missing %s for %s, %s"


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

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

commit:     aa008669a4adc1a16f0c52626ddf5bcd414dec3b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 22 17:20:54 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 22 23:00:58 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=aa008669

Add seed count and error for missing data

---
 gkeyldap/cli.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index c702bd2..9bb1add 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -147,13 +147,16 @@ class Main(object):
         logger.debug("create_seedfile, arrived")
         filename = self.config['dev-seedfile'] + '.new'
         self.seeds = Seeds(filename)
+        count = 0
         for dev in devs:
             if devs[dev]['gentooStatus'][0] not in ['active']:
                 continue
-            logger.debug("create_seedfile, dev = %s, %s" % (str(dev), str(devs[dev])))
+            #logger.debug("create_seedfile, dev = %s, %s" % (str(dev), str(devs[dev])))
             new_gkey = GKEY._make(self.build_gkeylist(devs[dev]))
             self.seeds.add(new_gkey)
-        logger.debug("create_seedfile, seeds created...saving file: %s" % filename)
+            count += 1
+        print("Total number of seeds created:", count)
+        logger.debug("MAIN: create_seedfile; seeds created...saving file: %s" % filename)
         return self.seeds.save()
 
 
@@ -177,7 +180,7 @@ class Main(object):
                 continue
             try:
                 values = info[field]
-                if values and values in ['uid' ]:
+                if values and values in ['uid', 'cn' ]:
                     value = values[0]
                 else:
                     value = values
@@ -199,12 +202,14 @@ class Main(object):
                 continue
             try:
                 values = info[field]
-                if values and field in ['uid', 'name' ]:
+                if values and field in ['uid', 'cn' ]:
                     value = values[0]
                 else:
                     value = values
                 keyinfo.append(value)
             except KeyError:
+                logger.error("Missing %s for %s, %s"
+                    %(field, info['uid'][0], info['cn'][0]))
                 keyinfo.append(None)
         return keyinfo
 


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

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

commit:     0536a049a7c03c82d528590308e39cc9926cd58d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 22 22:11:01 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 22 23:00:58 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=0536a049

Some pyflakes cleanup and fix logger messages

---
 gkeyldap/cli.py    | 11 +++++------
 gkeyldap/search.py |  1 -
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index d4971d0..ccc9159 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -2,7 +2,7 @@
 
 from __future__ import print_function
 
-import ldap
+
 import sys
 import os
 import argparse
@@ -10,8 +10,7 @@ import argparse
 from gkeys.log import logger
 from gkeys.config import GKeysConfig, GKEY
 from gkeys.seed import Seeds
-from gkeyldap.search import (LdapSearch, UID, CN, STATUS, GPGKEY,
-    MAIL, GPGFINGERPRINT, gkey2ldap_map, gkey2SEARCH)
+from gkeyldap.search import (LdapSearch, UID, gkey2ldap_map, gkey2SEARCH)
 
 
 # set debug level to max
@@ -35,7 +34,6 @@ class Main(object):
 
 
     def __call__(self, args=None):
-        logger.debug("Main:__call__()")
         if args:
             self.run(self.parse_args(args))
         else:
@@ -97,6 +95,7 @@ class Main(object):
         func = getattr(self, '_action_%s' % args.action)
         logger.debug('Found action: %s' % args.action)
         results = func(args)
+        return results
 
 
     def _action_ldapsearch(self, args):
@@ -111,7 +110,7 @@ class Main(object):
         for dev in sorted(devs):
             print(dev, devs[dev])
         print("============================================")
-        print "Total number of devs in results:", len(devs)
+        print("Total number of devs in results:", len(devs))
         return True
 
 
@@ -134,7 +133,7 @@ class Main(object):
             if os.path.exists(self.config['dev-seedfile']):
                 logger.debug("Renaming current seed file to: %s" % old)
                 os.rename(self.config['dev-seedfile'], old)
-            logger.debug("Renaming 'new' seed file to: %s" % self.config['dev-seedfile'])
+            logger.debug("Renaming 'new' seed file to: %s" % self.config['dev-seedfile']))
             os.rename(self.config['dev-seedfile'] + '.new',
                 self.config['dev-seedfile'])
         except IOError:

diff --git a/gkeyldap/search.py b/gkeyldap/search.py
index f432dcf..66721f1 100644
--- a/gkeyldap/search.py
+++ b/gkeyldap/search.py
@@ -1,5 +1,4 @@
 import ldap
-import sys
 
 from gkeys.log import logger
 from gkeys.config import GKEY


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

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

commit:     36a16de7b16eada20a909ee7d228a5efccddb957
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 22 17:28:30 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 22 23:00:58 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=36a16de7

Sort the devs on their nick

---
 gkeyldap/cli.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index 9bb1add..15e410e 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -148,7 +148,7 @@ class Main(object):
         filename = self.config['dev-seedfile'] + '.new'
         self.seeds = Seeds(filename)
         count = 0
-        for dev in devs:
+        for dev in sorted(devs):
             if devs[dev]['gentooStatus'][0] not in ['active']:
                 continue
             #logger.debug("create_seedfile, dev = %s, %s" % (str(dev), str(devs[dev])))


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

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

commit:     a66c980cc6d997076968c3e357eef80cd3f7cbb8
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 23 01:19:23 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=a66c980c

strip errant line feeds in ldap values

---
 gkeyldap/cli.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index 06da0f3..0527689 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -245,8 +245,10 @@ class Main(object):
                 continue
             try:
                 values = info[field]
+                # strip errant line feeds
+                values = [x.strip('\n') for x in values]
                 if values and field in ['uid', 'cn' ]:
-                    value = values[0]
+                    value = values[0].strip('\n')
                 # separate out short/long key id's
                 elif values and x in ['keyid', 'longkeyid']:
                     value = get_key_ids(x, values)


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

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

commit:     488a4f389606423451dc36af3920803b2a14de7c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 22 21:01:48 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=488a4f38

Add keyid/longkeyid separation and assignment

---
 gkeyldap/cli.py    | 37 +++++++++++++++++++++++++++++--------
 gkeyldap/search.py |  2 +-
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index b506f64..dae772a 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -20,6 +20,32 @@ from gkeyldap.search import (LdapSearch, UID, gkey2ldap_map, gkey2SEARCH)
 logger.setLevel(0)
 
 
+# set some defaults
+KEY_LEN = {
+    'keyid': 8,
+    'longkeyid': 16,
+}
+
+
+def get_key_ids(key, info):
+    '''Small utility function to return only keyid (short)
+    or longkeyid's
+
+    @param key: string, the key lenght desired
+    @param info: list of keysid's to process
+    @return list of the desired key lengh id's
+    '''
+    result = []
+    for x in info:
+        if x.startswith('0x'):
+            mylen = KEY_LEN[key] + 2
+        else:
+            mylen = KEY_LEN[key]
+        if len(x) == mylen:
+            result.append(x)
+    return result
+
+
 class Main(object):
     '''Main command line interface class'''
 
@@ -188,7 +214,6 @@ class Main(object):
         return (x, target, search_field)
 
 
-
     @staticmethod
     def build_gkeydict(info):
         keyinfo = {}
@@ -222,6 +247,9 @@ class Main(object):
                 values = info[field]
                 if values and field in ['uid', 'cn' ]:
                     value = values[0]
+                # separate out short/long key id's
+                elif values and x in ['keyid', 'longkeyid']:
+                    value = get_key_ids(x, values)
                 else:
                     value = values
                 if 'undefined' in values:
@@ -234,10 +262,3 @@ class Main(object):
                 keyinfo.append(None)
         return keyinfo
 
-
-if __name__ == '__main__':
-
-    Main()
-
-
-

diff --git a/gkeyldap/search.py b/gkeyldap/search.py
index 66721f1..8d323f4 100644
--- a/gkeyldap/search.py
+++ b/gkeyldap/search.py
@@ -19,7 +19,7 @@ gkey2ldap_map = {
     'nick': 'uid',
     'name': 'cn',
     'keyid': 'gpgkey',
-    'longkeyid': '',
+    'longkeyid': 'gpgkey',
     'keyring': '',
     'fingerprint': 'gpgfingerprint'
 }


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

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

commit:     fc80c90d916a97964ce38573b57ccccd74e63283
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 23 01:21:42 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=fc80c90d

set encoding in files

---
 gkeyldap/cli.py    | 3 ++-
 gkeyldap/search.py | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index 0527689..cd813d4 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -1,4 +1,5 @@
-#!/usr/bin/env python
+#
+#-*- coding:utf-8 -*-
 
 from __future__ import print_function
 

diff --git a/gkeyldap/search.py b/gkeyldap/search.py
index 8d323f4..32e326b 100644
--- a/gkeyldap/search.py
+++ b/gkeyldap/search.py
@@ -1,3 +1,7 @@
+#
+#-*- coding:utf-8 -*-
+
+
 import ldap
 
 from gkeys.log import logger


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

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

commit:     279cf8282b3e840bcc2ec5cbd2d6295cccc388f3
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 22 20:13:54 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=279cf828

Add more progress feedback for normal usage.

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

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index 8d9dc85..ba0218b 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -119,6 +119,7 @@ class Main(object):
 
 
     def _action_updateseeds(self, args):
+        print("Beginning ldap search...")
         l = LdapSearch()
         if not l.connect():
             print("Aborting Update...Connection failed")
@@ -132,6 +133,7 @@ class Main(object):
                 "Original seed file is intact & untouched.")
         old = self.config['dev-seedfile'] + '.old'
         try:
+            print("Backing up existing file...")
             if os.path.exists(old):
                 logger.debug(
                     "MAIN: _action_updateseeds; Removing 'old' seed file: %s"
@@ -154,7 +156,7 @@ class Main(object):
 
 
     def create_seedfile(self, devs):
-        logger.debug("create_seedfile, arrived")
+        print("Creating seeds from ldap data...")
         filename = self.config['dev-seedfile'] + '.new'
         self.seeds = Seeds(filename)
         count = 0
@@ -167,8 +169,7 @@ class Main(object):
             self.seeds.add(new_gkey)
             count += 1
         print("Total number of seeds created:", count)
-        logger.debug("MAIN: create_seedfile; seeds created...saving file: %s"
-            % filename)
+        print("Seeds created...saving file: %s" % filename)
         return self.seeds.save()
 
 


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

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

commit:     7e29324216f9ab90790e482c34e189891c2a2cd9
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 23 00:36:31 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=7e293242

Add GKEY field name to error output

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

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index dae772a..06da0f3 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -257,8 +257,8 @@ class Main(object):
                         %(field, info['uid'][0], info['cn'][0]))
                 keyinfo.append(value)
             except KeyError:
-                logger.error("Missing %s for %s, %s"
-                    %(field, info['uid'][0], info['cn'][0]))
+                logger.error("Missing %s (%s) for %s, %s"
+                    %(field, x, info['uid'][0], info['cn'][0]))
                 keyinfo.append(None)
         return keyinfo
 


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

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

commit:     eff0bb6caad5819f8893984c1264b5646f118408
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 23 03:06:53 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jun 23 04:36:59 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=eff0bb6c

Add check for no valid keyid/longkeyid found in ldap data

Account for missing gpgkey key
Prevent a double error message

---
 gkeyldap/cli.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index bf4e00e..03671b5 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -245,6 +245,8 @@ class Main(object):
     @staticmethod
     def build_gkeylist(info):
         keyinfo = []
+        keyid_found = False
+        keyid_missing = False
         #logger.debug("MAIN: build_gkeylist; info = %s" % str(info))
         for x in GKEY._fields:
             field = gkey2ldap_map[x]
@@ -259,6 +261,8 @@ class Main(object):
                 # separate out short/long key id's
                 elif values and x in ['keyid', 'longkeyid']:
                     value = get_key_ids(x, values)
+                    if len(value):
+                        keyid_found = True
                 else:
                     value = values
                 if 'undefined' in values:
@@ -268,6 +272,16 @@ class Main(object):
             except KeyError:
                 logger.error("Missing %s (%s) for %s, %s"
                     %(field, x, info['uid'][0], info['cn'][0]))
+                if x in ['keyid', 'longkeyid']:
+                    keyid_missing = True
                 keyinfo.append(None)
+        if not keyid_found and not keyid_missing:
+            try:
+                gpgkey = info[gkey2ldap_map['longkeyid']]
+            except KeyError:
+                gpgkey = 'Missing from ldap info'
+            logger.error("A valid keyid or longkeyid was not found for")
+            logger.error("developer: %s, %s : gpgkey = %s"
+                %(info['uid'][0], info['cn'][0], gpgkey))
         return keyinfo
 


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

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

commit:     16a88edc991162a2628fd5d7ffd51e7fee863f93
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 23 07:01:27 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jun 23 07:01:27 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=16a88edc

Map dev's GKEY keyring field to ldap's uid.

---
 gkeyldap/search.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gkeyldap/search.py b/gkeyldap/search.py
index 32e326b..169124f 100644
--- a/gkeyldap/search.py
+++ b/gkeyldap/search.py
@@ -24,7 +24,9 @@ gkey2ldap_map = {
     'name': 'cn',
     'keyid': 'gpgkey',
     'longkeyid': 'gpgkey',
-    'keyring': '',
+    # map the uid to keyring, since we want
+    # dev keyrings to be separate from each other
+    'keyring': 'uid',
     'fingerprint': 'gpgfingerprint'
 }
 # Sanity check they are in sync


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

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

commit:     c60985bd8468aeb96cdef93194d107c2ac819212
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 25 23:29:44 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=c60985bd

Remove spaces in fingerprints to match what gpg returns

---
 gkeyldap/cli.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index 03671b5..6a3e4bb 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -263,6 +263,8 @@ class Main(object):
                     value = get_key_ids(x, values)
                     if len(value):
                         keyid_found = True
+                elif values and x in ['fingerprint']:
+                    value = [v.replace(' ', '') for v in values]
                 else:
                     value = values
                 if 'undefined' in values:


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

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

commit:     3d5370b22b4f80e310f23d8a9bd7e409c00ce9c7
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jul  6 16:46:08 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jul  6 18:47:45 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=3d5370b2

fix some typo's

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

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index 171767b..2022ee9 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -32,9 +32,9 @@ def get_key_ids(key, info):
     '''Small utility function to return only keyid (short)
     or longkeyid's
 
-    @param key: string, the key lenght desired
+    @param key: string, the key length desired
     @param info: list of keysid's to process
-    @return list of the desired key lengh id's
+    @return list of the desired key length id's
     '''
     result = []
     for x in info:


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

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

commit:     5540e0888fd1083c71f66e02770879954ab4ab6d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 28 19:40:48 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jul  6 18:47:45 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=5540e088

Add gpgkey, gpgfingerprint check when building the seed info

---
 gkeyldap/cli.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index 32f1f87..171767b 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -303,5 +303,15 @@ class Main(object):
             logger.error("A valid keyid or longkeyid was not found for")
             logger.error("developer: %s, %s : gpgkey = %s"
                 %(info['uid'][0], info['cn'][0], gpgkey))
+        else:
+            for x in [2, 3]:
+                if not keyinfo[x]:
+                    continue
+                for y in keyinfo[x]:
+                    index = len(y.lstrip('0x'))
+                    if y.lstrip('0x') not in [x[-index:] for x in keyinfo[5]]:
+                        logger.error('GPGKey and/or fingerprint error in' +
+                            ' ladap info for: ' + info['uid'][0])
+                        logger.error(str(keyinfo))
         return keyinfo
 


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

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

commit:     04677b673faff452b3373028bbc3877ccfded928
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 16:55:14 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=04677b67

Move the api actions to it's own class.

Fix printing to be configurable (sort of)

---
 gkeyldap/actions.py | 224 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 gkeyldap/cli.py     | 208 +++---------------------------------------------
 2 files changed, 233 insertions(+), 199 deletions(-)

diff --git a/gkeyldap/actions.py b/gkeyldap/actions.py
new file mode 100644
index 0000000..70a2ad1
--- /dev/null
+++ b/gkeyldap/actions.py
@@ -0,0 +1,224 @@
+#
+#-*- coding:utf-8 -*-
+
+"""
+    Gentoo-keys - gkeyldap/actions.py
+
+    Primary api interface module
+
+    @copyright: 2012 by Brian Dolbec <dol-sen@gentoo.org>
+    @license: GNU GPL2, see COPYING for details.
+"""
+
+import os
+
+from gkeys.config import GKEY
+from gkeys.seed import Seeds
+from gkeyldap.search import (LdapSearch, UID, gkey2ldap_map, gkey2SEARCH)
+
+
+# set some defaults
+KEY_LEN = {
+    'keyid': 8,
+    'longkeyid': 16,
+}
+
+
+Avialable_Actions = ['ldapsearch', 'updateseeds']
+
+
+def get_key_ids(key, info):
+    '''Small utility function to return only keyid (short)
+    or longkeyid's
+
+    @param key: string, the key length desired
+    @param info: list of keysid's to process
+    @return list of the desired key length id's
+    '''
+    result = []
+    for x in info:
+        if x.startswith('0x'):
+            mylen = KEY_LEN[key] + 2
+        else:
+            mylen = KEY_LEN[key]
+        if len(x) == mylen:
+            result.append(x)
+    return result
+
+
+class Actions(object):
+
+
+    def __init__(self, config, output=None, logger=None):
+        self.config = config
+        self.output = output
+        self.logger = logger
+        self.seeds = None
+
+
+    def ldapsearch(self, args):
+        l = LdapSearch()
+        self.logger.info("Search...establishing connection")
+        self.output("Search...establishing connection")
+        if not l.connect():
+            self.logger.info("Aborting Search...Connection failed")
+            self.output("Aborting Search...Connection failed")
+            return False
+        self.logger.debug("MAIN: _action_ldapsearch; args = %s" % str(args))
+        x, target, search_field = self.get_args(args)
+        results = l.search(target, search_field)
+        devs = l.result2dict(results, gkey2ldap_map[x])
+        for dev in sorted(devs):
+            self.output(dev, devs[dev])
+        self.output("============================================")
+        self.output("Total number of devs in results:", len(devs))
+        return True
+
+
+    def updateseeds(self, args):
+        self.logger.info("Beginning ldap search...")
+        self.output("Beginning ldap search...")
+        l = LdapSearch()
+        if not l.connect():
+            self.output("Aborting Update...Connection failed")
+            return False
+        results = l.search('*', UID)
+        info = l.result2dict(results, 'uid')
+        self.logger.debug(
+            "MAIN: _action_updateseeds; got results :) converted to info")
+        if not self.create_seedfile(info):
+            self.logger.error("Dev seed file update failure: "
+                "Original seed file is intact & untouched.")
+        old = self.config['dev-seedfile'] + '.old'
+        try:
+            self.output("Backing up existing file...")
+            if os.path.exists(old):
+                self.logger.debug(
+                    "MAIN: _action_updateseeds; Removing 'old' seed file: %s"
+                    % old)
+                os.unlink(old)
+            if os.path.exists(self.config['dev-seedfile']):
+                self.logger.debug(
+                    "MAIN: _action_updateseeds; Renaming current seed file to: "
+                    "%s" % old)
+                os.rename(self.config['dev-seedfile'], old)
+            self.logger.debug(
+                "MAIN: _action_updateseeds; Renaming '.new' seed file to: %s"
+                % self.config['dev-seedfile'])
+            os.rename(self.config['dev-seedfile'] + '.new',
+                self.config['dev-seedfile'])
+        except IOError:
+            raise
+        self.output("Developer Seed file updated")
+        return True
+
+
+    def create_seedfile(self, devs):
+        self.output("Creating seeds from ldap data...")
+        filename = self.config['dev-seedfile'] + '.new'
+        self.seeds = Seeds(filename)
+        count = 0
+        for dev in sorted(devs):
+            if devs[dev]['gentooStatus'][0] not in ['active']:
+                continue
+            #self.logger.debug("create_seedfile, dev = "
+            #   "%s, %s" % (str(dev), str(devs[dev])))
+            new_gkey = GKEY._make(self.build_gkeylist(devs[dev]))
+            self.seeds.add(new_gkey)
+            count += 1
+        self.output("Total number of seeds created:", count)
+        self.output("Seeds created...saving file: %s" % filename)
+        return self.seeds.save()
+
+
+    @staticmethod
+    def get_args(args):
+        for x in ['nick', 'name', 'gpgkey', 'fingerprint', 'status']:
+            if x:
+                target = getattr(args, x)
+                search_field = gkey2SEARCH[x]
+                break
+        return (x, target, search_field)
+
+
+
+    def build_gkeydict(self, info):
+        keyinfo = {}
+        for x in GKEY._fields:
+            field = gkey2ldap_map[x]
+            if not field:
+                continue
+            try:
+                # strip errant line feeds
+                values = [y.strip('\n') for y in info[field]]
+                if values and values in ['uid', 'cn' ]:
+                    value = values[0]
+                # separate out short/long key id's
+                elif values and x in ['keyid', 'longkeyid']:
+                    value = get_key_ids(x, values)
+                else:
+                    value = values
+                if 'undefined' in values:
+                    self.logger.error('%s = "undefined" for %s, %s'
+                        %(field, info['uid'][0], info['cn'][0]))
+                if value:
+                    keyinfo[x] = value
+            except KeyError:
+                pass
+        return keyinfo
+
+
+    def build_gkeylist(self, info):
+        keyinfo = []
+        keyid_found = False
+        keyid_missing = False
+        #self.logger.debug("MAIN: build_gkeylist; info = %s" % str(info))
+        for x in GKEY._fields:
+            field = gkey2ldap_map[x]
+            if not field:
+                keyinfo.append(None)
+                continue
+            try:
+                # strip errant line feeds
+                values = [y.strip('\n') for y in info[field]]
+                if values and field in ['uid', 'cn' ]:
+                    value = values[0]
+                # separate out short/long key id's
+                elif values and x in ['keyid', 'longkeyid']:
+                    value = get_key_ids(x, values)
+                    if len(value):
+                        keyid_found = True
+                elif values and x in ['fingerprint']:
+                    value = [v.replace(' ', '') for v in values]
+                else:
+                    value = values
+                if 'undefined' in values:
+                    self.logger.error('%s = "undefined" for %s, %s'
+                        %(field, info['uid'][0], info['cn'][0]))
+                keyinfo.append(value)
+            except KeyError:
+                self.logger.error("Missing %s (%s) for %s, %s"
+                    %(field, x, info['uid'][0], info['cn'][0]))
+                if x in ['keyid', 'longkeyid']:
+                    keyid_missing = True
+                keyinfo.append(None)
+        if not keyid_found and not keyid_missing:
+            try:
+                gpgkey = info[gkey2ldap_map['longkeyid']]
+            except KeyError:
+                gpgkey = 'Missing from ldap info'
+            self.logger.error("A valid keyid or longkeyid was not found for")
+            self.logger.error("developer: %s, %s : gpgkey = %s"
+                %(info['uid'][0], info['cn'][0], gpgkey))
+        else:
+            for x in [2, 3]:
+                if not keyinfo[x]:
+                    continue
+                for y in keyinfo[x]:
+                    index = len(y.lstrip('0x'))
+                    if y.lstrip('0x') not in [x[-index:] for x in keyinfo[5]]:
+                        self.logger.error('GPGKey and/or fingerprint error in' +
+                            ' ladap info for: ' + info['uid'][0])
+                        self.logger.error(str(keyinfo))
+        return keyinfo
+

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index 2022ee9..097cfc2 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -5,7 +5,6 @@ from __future__ import print_function
 
 
 import sys
-import os
 import argparse
 
 from gkeys import log
@@ -14,38 +13,11 @@ from gkeys.log import log_levels, set_logger
 from gkeys import config
 from gkeys import seed
 
-from gkeys.config import GKeysConfig, GKEY
-from gkeys.seed import Seeds
+from gkeys.config import GKeysConfig
 from gkeyldap import search
-from gkeyldap.search import (LdapSearch, UID, gkey2ldap_map, gkey2SEARCH)
-
+from gkeyldap.actions import Actions, Avialable_Actions
 logger = log.logger
 
-# set some defaults
-KEY_LEN = {
-    'keyid': 8,
-    'longkeyid': 16,
-}
-
-
-def get_key_ids(key, info):
-    '''Small utility function to return only keyid (short)
-    or longkeyid's
-
-    @param key: string, the key length desired
-    @param info: list of keysid's to process
-    @return list of the desired key length id's
-    '''
-    result = []
-    for x in info:
-        if x.startswith('0x'):
-            mylen = KEY_LEN[key] + 2
-        else:
-            mylen = KEY_LEN[key]
-        if len(x) == mylen:
-            result.append(x)
-    return result
-
 
 class Main(object):
     '''Main command line interface class'''
@@ -77,7 +49,7 @@ class Main(object):
         @returns argparse.Namespace object
         '''
         #logger.debug('MAIN: parse_args; args: %s' % args)
-        actions = ['ldapsearch', 'updateseeds']
+        actions = Avialable_Actions
         parser = argparse.ArgumentParser(
             prog='gkeys',
             description='Gentoo-keys manager program',
@@ -140,178 +112,16 @@ class Main(object):
             logger.debug("Main: run; Found alternate config request: %s"
                 % args.config)
 
+        # establish our actions instance
+        self.actions = Actions(self.config, print, logger)
+
         logger.info("Begin running action: %s" % args.action)
 
-        func = getattr(self, '_action_%s' % args.action)
+        # run the action
+        func = getattr(self.actions, '%s' % args.action)
+
         logger.debug('Main: run; Found action: %s' % args.action)
         results = func(args)
         return results
 
 
-    def _action_ldapsearch(self, args):
-        l = LdapSearch()
-        logger.info("Search...establishing connection")
-        print("Search...establishing connection")
-        if not l.connect():
-            logger.info("Aborting Search...Connection failed")
-            print("Aborting Search...Connection failed")
-            return False
-        logger.debug("MAIN: _action_ldapsearch; args = %s" % str(args))
-        x, target, search_field = self.get_args(args)
-        results = l.search(target, search_field)
-        devs = l.result2dict(results, gkey2ldap_map[x])
-        for dev in sorted(devs):
-            print(dev, devs[dev])
-        print("============================================")
-        print("Total number of devs in results:", len(devs))
-        return True
-
-
-    def _action_updateseeds(self, args):
-        logger.info("Beginning ldap search...")
-        print("Beginning ldap search...")
-        l = LdapSearch()
-        if not l.connect():
-            print("Aborting Update...Connection failed")
-            return False
-        results = l.search('*', UID)
-        info = l.result2dict(results, 'uid')
-        logger.debug(
-            "MAIN: _action_updateseeds; got results :) converted to info")
-        if not self.create_seedfile(info):
-            logger.error("Dev seed file update failure: "
-                "Original seed file is intact & untouched.")
-        old = self.config['dev-seedfile'] + '.old'
-        try:
-            print("Backing up existing file...")
-            if os.path.exists(old):
-                logger.debug(
-                    "MAIN: _action_updateseeds; Removing 'old' seed file: %s"
-                    % old)
-                os.unlink(old)
-            if os.path.exists(self.config['dev-seedfile']):
-                logger.debug(
-                    "MAIN: _action_updateseeds; Renaming current seed file to: "
-                    "%s" % old)
-                os.rename(self.config['dev-seedfile'], old)
-            logger.debug(
-                "MAIN: _action_updateseeds; Renaming '.new' seed file to: %s"
-                % self.config['dev-seedfile'])
-            os.rename(self.config['dev-seedfile'] + '.new',
-                self.config['dev-seedfile'])
-        except IOError:
-            raise
-        print("Developer Seed file updated")
-        return True
-
-
-    def create_seedfile(self, devs):
-        print("Creating seeds from ldap data...")
-        filename = self.config['dev-seedfile'] + '.new'
-        self.seeds = Seeds(filename)
-        count = 0
-        for dev in sorted(devs):
-            if devs[dev]['gentooStatus'][0] not in ['active']:
-                continue
-            #logger.debug("create_seedfile, dev = "
-            #   "%s, %s" % (str(dev), str(devs[dev])))
-            new_gkey = GKEY._make(self.build_gkeylist(devs[dev]))
-            self.seeds.add(new_gkey)
-            count += 1
-        print("Total number of seeds created:", count)
-        print("Seeds created...saving file: %s" % filename)
-        return self.seeds.save()
-
-
-    @staticmethod
-    def get_args(args):
-        for x in ['nick', 'name', 'gpgkey', 'fingerprint', 'status']:
-            if x:
-                target = getattr(args, x)
-                search_field = gkey2SEARCH[x]
-                break
-        return (x, target, search_field)
-
-
-    @staticmethod
-    def build_gkeydict(info):
-        keyinfo = {}
-        for x in GKEY._fields:
-            field = gkey2ldap_map[x]
-            if not field:
-                continue
-            try:
-                # strip errant line feeds
-                values = [y.strip('\n') for y in info[field]]
-                if values and values in ['uid', 'cn' ]:
-                    value = values[0]
-                # separate out short/long key id's
-                elif values and x in ['keyid', 'longkeyid']:
-                    value = get_key_ids(x, values)
-                else:
-                    value = values
-                if 'undefined' in values:
-                    logger.error('%s = "undefined" for %s, %s'
-                        %(field, info['uid'][0], info['cn'][0]))
-                if value:
-                    keyinfo[x] = value
-            except KeyError:
-                pass
-        return keyinfo
-
-
-    @staticmethod
-    def build_gkeylist(info):
-        keyinfo = []
-        keyid_found = False
-        keyid_missing = False
-        #logger.debug("MAIN: build_gkeylist; info = %s" % str(info))
-        for x in GKEY._fields:
-            field = gkey2ldap_map[x]
-            if not field:
-                keyinfo.append(None)
-                continue
-            try:
-                # strip errant line feeds
-                values = [y.strip('\n') for y in info[field]]
-                if values and field in ['uid', 'cn' ]:
-                    value = values[0]
-                # separate out short/long key id's
-                elif values and x in ['keyid', 'longkeyid']:
-                    value = get_key_ids(x, values)
-                    if len(value):
-                        keyid_found = True
-                elif values and x in ['fingerprint']:
-                    value = [v.replace(' ', '') for v in values]
-                else:
-                    value = values
-                if 'undefined' in values:
-                    logger.error('%s = "undefined" for %s, %s'
-                        %(field, info['uid'][0], info['cn'][0]))
-                keyinfo.append(value)
-            except KeyError:
-                logger.error("Missing %s (%s) for %s, %s"
-                    %(field, x, info['uid'][0], info['cn'][0]))
-                if x in ['keyid', 'longkeyid']:
-                    keyid_missing = True
-                keyinfo.append(None)
-        if not keyid_found and not keyid_missing:
-            try:
-                gpgkey = info[gkey2ldap_map['longkeyid']]
-            except KeyError:
-                gpgkey = 'Missing from ldap info'
-            logger.error("A valid keyid or longkeyid was not found for")
-            logger.error("developer: %s, %s : gpgkey = %s"
-                %(info['uid'][0], info['cn'][0], gpgkey))
-        else:
-            for x in [2, 3]:
-                if not keyinfo[x]:
-                    continue
-                for y in keyinfo[x]:
-                    index = len(y.lstrip('0x'))
-                    if y.lstrip('0x') not in [x[-index:] for x in keyinfo[5]]:
-                        logger.error('GPGKey and/or fingerprint error in' +
-                            ' ladap info for: ' + info['uid'][0])
-                        logger.error(str(keyinfo))
-        return keyinfo
-


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

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeyldap/
@ 2013-11-10  1:01 Brian Dolbec
  0 siblings, 0 replies; 23+ messages in thread
From: Brian Dolbec @ 2013-11-10  1:01 UTC (permalink / raw
  To: gentoo-commits

commit:     ac7cf53481fb33721c84888a461258b99d9f8515
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Nov  9 20:51:13 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Nov  9 21:17:39 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=ac7cf534

Add missing logger.info messages.

Reduce a debug message being printed multiple times.

---
 gkeyldap/actions.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/gkeyldap/actions.py b/gkeyldap/actions.py
index 7ffa094..07130eb 100644
--- a/gkeyldap/actions.py
+++ b/gkeyldap/actions.py
@@ -74,6 +74,8 @@ class Actions(object):
             self.output(dev, devs[dev])
         self.output("============================================")
         self.output("Total number of devs in results:", len(devs))
+        self.logger.info("============================================")
+        self.logger.info("Total number of devs in results: %d" % len(devs))
         return True
 
 
@@ -83,6 +85,7 @@ class Actions(object):
         l = LdapSearch()
         if not l.connect():
             self.output("Aborting Update...Connection failed")
+            self.logger.info("Aborting Update...Connection failed")
             return False
         results = l.search('*', UID)
         info = l.result2dict(results, 'uid')
@@ -91,24 +94,25 @@ class Actions(object):
         if not self.create_seedfile(info):
             self.logger.error("Dev seed file update failure: "
                 "Original seed file is intact & untouched.")
-        old = self.config['dev-seedfile'] + '.old'
+        filename = self.config['dev-seedfile']
+        old = filename + '.old'
         try:
             self.output("Backing up existing file...")
+            self.logger.info("Backing up existing file...")
             if os.path.exists(old):
                 self.logger.debug(
                     "MAIN: _action_updateseeds; Removing 'old' seed file: %s"
                     % old)
                 os.unlink(old)
-            if os.path.exists(self.config['dev-seedfile']):
+            if os.path.exists(filename):
                 self.logger.debug(
                     "MAIN: _action_updateseeds; Renaming current seed file to: "
                     "%s" % old)
-                os.rename(self.config['dev-seedfile'], old)
+                os.rename(filename, old)
             self.logger.debug(
                 "MAIN: _action_updateseeds; Renaming '.new' seed file to: %s"
-                % self.config['dev-seedfile'])
-            os.rename(self.config['dev-seedfile'] + '.new',
-                self.config['dev-seedfile'])
+                % filename)
+            os.rename(filename + '.new', filename)
         except IOError:
             raise
         self.output("Developer Seed file updated")
@@ -132,6 +136,8 @@ class Actions(object):
                 count += 1
         self.output("Total number of seeds created:", count)
         self.output("Seeds created...saving file: %s" % filename)
+        self.logger.info("Total number of seeds created: %d" % count)
+        self.logger.info("Seeds created...saving file: %s" % filename)
         return self.seeds.save()
 
 


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

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeyldap/
@ 2013-11-10  1:01 Brian Dolbec
  0 siblings, 0 replies; 23+ messages in thread
From: Brian Dolbec @ 2013-11-10  1:01 UTC (permalink / raw
  To: gentoo-commits

commit:     55af15b6c3e64ba2f7d9a81b04d2cef6b4c9b513
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Nov  9 19:27:28 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Nov  9 21:17:39 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=55af15b6

Don't add a dev's seed if there were errors

---
 gkeyldap/actions.py | 34 ++++++++++++++++++++++++++--------
 1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/gkeyldap/actions.py b/gkeyldap/actions.py
index ee5efd9..7ffa094 100644
--- a/gkeyldap/actions.py
+++ b/gkeyldap/actions.py
@@ -125,9 +125,11 @@ class Actions(object):
                 continue
             #self.logger.debug("create_seedfile, dev = "
             #   "%s, %s" % (str(dev), str(devs[dev])))
-            new_gkey = GKEY._make(self.build_gkeylist(devs[dev]))
-            self.seeds.add(new_gkey)
-            count += 1
+            keyinfo = self.build_gkeylist(devs[dev])
+            if keyinfo:
+                new_gkey = GKEY._make(keyinfo)
+                self.seeds.add(new_gkey)
+                count += 1
         self.output("Total number of seeds created:", count)
         self.output("Seeds created...saving file: %s" % filename)
         return self.seeds.save()
@@ -174,6 +176,8 @@ class Actions(object):
         keyinfo = []
         keyid_found = False
         keyid_missing = False
+        # assume it's good until found an error is found
+        is_good = True
         #self.logger.debug("MAIN: build_gkeylist; info = %s" % str(info))
         for x in GKEY._fields:
             field = gkey2ldap_map[x]
@@ -198,6 +202,7 @@ class Actions(object):
                     self.logger.error('ERROR in ldap info for: %s, %s'
                         %(info['uid'][0],info['cn'][0]))
                     self.logger.error('  %s = "undefined"' %(field))
+                    is_good = False
                 keyinfo.append(value)
             except KeyError:
                 self.logger.error('ERROR in ldap info for: %s, %s'
@@ -207,6 +212,7 @@ class Actions(object):
                 if x in ['keyid', 'longkeyid']:
                     keyid_missing = True
                 keyinfo.append(None)
+                is_good = False
         if not keyid_found and not keyid_missing:
             try:
                 gpgkey = info[gkey2ldap_map['longkeyid']]
@@ -216,14 +222,21 @@ class Actions(object):
                 %(info['uid'][0],info['cn'][0]))
             self.logger.error('  A valid keyid or longkeyid was not found '
                 "%s : gpgkey = %s" %(info['cn'][0], gpgkey))
+            is_good = False
         else:
             if keyinfo[5]: # fingerprints exist check
-                self._check_fingerprint_integrity(info, keyinfo)
-                self._check_id_fingerprint_match(info, keyinfo)
-        return keyinfo
+                is_ok = self._check_fingerprint_integrity(info, keyinfo)
+                is_match = self._check_id_fingerprint_match(info, 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, info, keyinfo):
+        # assume it's good until found an error is found
+        is_good = True
         for x in [2, 3]:
             # skip blank id field
             if not keyinfo[x]:
@@ -236,10 +249,13 @@ class Actions(object):
                     self.logger.error('  ' + str(keyinfo))
                     self.logger.error('  GPGKey id %s not found in the '
                         % y.lstrip('0x') + 'listed fingerprint(s)')
-        return
+                    is_good = False
+        return is_good
 
 
     def _check_fingerprint_integrity(self, info, keyinfo):
+        # assume it's good until found an error is found
+        is_good = True
         for x in keyinfo[5]:
             # check fingerprint integrity
             if len(x) != 40:
@@ -247,10 +263,12 @@ class Actions(object):
                     %(info['uid'][0],info['cn'][0]))
                 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 ldap info for: %s, %s'
                     %(info['uid'][0],info['cn'][0]))
                 self.logger.error('  GPGKey: Non hexadecimal digits in ' +
                     'fingerprint for fingerprint: ' + x)
-        return
+                is_good = False
+        return is_good


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

* [gentoo-commits] proj/gentoo-keys:master commit in: gkeyldap/
@ 2013-11-10  1:01 Brian Dolbec
  0 siblings, 0 replies; 23+ messages in thread
From: Brian Dolbec @ 2013-11-10  1:01 UTC (permalink / raw
  To: gentoo-commits

commit:     e03d9b800d54c7d36ce72821761debc479c0a318
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Nov  8 04:41:26 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Nov  9 21:17:28 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=e03d9b80

Add more checks moving them to idividual functions.

Improve error messages and unify output for both logs and terminal output.

---
 gkeyldap/actions.py | 64 +++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 48 insertions(+), 16 deletions(-)

diff --git a/gkeyldap/actions.py b/gkeyldap/actions.py
index 70a2ad1..ee5efd9 100644
--- a/gkeyldap/actions.py
+++ b/gkeyldap/actions.py
@@ -11,6 +11,7 @@
 """
 
 import os
+import re
 
 from gkeys.config import GKEY
 from gkeys.seed import Seeds
@@ -54,6 +55,7 @@ class Actions(object):
         self.output = output
         self.logger = logger
         self.seeds = None
+        self.fingerprint_re = re.compile('[0-9A-Fa-f]{40}')
 
 
     def ldapsearch(self, args):
@@ -193,12 +195,15 @@ class Actions(object):
                 else:
                     value = values
                 if 'undefined' in values:
-                    self.logger.error('%s = "undefined" for %s, %s'
-                        %(field, info['uid'][0], info['cn'][0]))
+                    self.logger.error('ERROR in ldap info for: %s, %s'
+                        %(info['uid'][0],info['cn'][0]))
+                    self.logger.error('  %s = "undefined"' %(field))
                 keyinfo.append(value)
             except KeyError:
-                self.logger.error("Missing %s (%s) for %s, %s"
-                    %(field, x, info['uid'][0], info['cn'][0]))
+                self.logger.error('ERROR in ldap info for: %s, %s'
+                    %(info['uid'][0],info['cn'][0]))
+                self.logger.error('  MISSING or EMPTY ldap field ' +
+                    '[%s] GPGKey field [%s]' %(field, x))
                 if x in ['keyid', 'longkeyid']:
                     keyid_missing = True
                 keyinfo.append(None)
@@ -207,18 +212,45 @@ class Actions(object):
                 gpgkey = info[gkey2ldap_map['longkeyid']]
             except KeyError:
                 gpgkey = 'Missing from ldap info'
-            self.logger.error("A valid keyid or longkeyid was not found for")
-            self.logger.error("developer: %s, %s : gpgkey = %s"
-                %(info['uid'][0], info['cn'][0], gpgkey))
+            self.logger.error('ERROR in ldap info for: %s, %s'
+                %(info['uid'][0],info['cn'][0]))
+            self.logger.error('  A valid keyid or longkeyid was not found '
+                "%s : gpgkey = %s" %(info['cn'][0], gpgkey))
         else:
-            for x in [2, 3]:
-                if not keyinfo[x]:
-                    continue
-                for y in keyinfo[x]:
-                    index = len(y.lstrip('0x'))
-                    if y.lstrip('0x') not in [x[-index:] for x in keyinfo[5]]:
-                        self.logger.error('GPGKey and/or fingerprint error in' +
-                            ' ladap info for: ' + info['uid'][0])
-                        self.logger.error(str(keyinfo))
+            if keyinfo[5]: # fingerprints exist check
+                self._check_fingerprint_integrity(info, keyinfo)
+                self._check_id_fingerprint_match(info, keyinfo)
         return keyinfo
 
+
+    def _check_id_fingerprint_match(self, info, keyinfo):
+        for x in [2, 3]:
+            # skip blank id field
+            if not keyinfo[x]:
+                continue
+            for y in keyinfo[x]:
+                index = len(y.lstrip('0x'))
+                if y.lstrip('0x').lower() not in [x[-index:].lower() for x in keyinfo[5]]:
+                    self.logger.error('ERROR in ldap info for: %s, %s'
+                        %(info['uid'][0],info['cn'][0]))
+                    self.logger.error('  ' + str(keyinfo))
+                    self.logger.error('  GPGKey id %s not found in the '
+                        % y.lstrip('0x') + 'listed fingerprint(s)')
+        return
+
+
+    def _check_fingerprint_integrity(self, info, keyinfo):
+        for x in keyinfo[5]:
+            # check fingerprint integrity
+            if len(x) != 40:
+                self.logger.error('ERROR in ldap info for: %s, %s'
+                    %(info['uid'][0],info['cn'][0]))
+                self.logger.error('  GPGKey incorrect fingerprint ' +
+                    'length (%s) for fingerprint: %s' %(len(x), x))
+                continue
+            if not self.fingerprint_re.match(x):
+                self.logger.error('ERROR in ldap info for: %s, %s'
+                    %(info['uid'][0],info['cn'][0]))
+                self.logger.error('  GPGKey: Non hexadecimal digits in ' +
+                    'fingerprint for fingerprint: ' + x)
+        return


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

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

commit:     37f1805ad3fbcf83e8828b2b73b983dc4e550e18
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 15 05:25:35 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Nov 15 09:13:57 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=37f1805a

Add errors count to the output.

---
 gkeyldap/actions.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gkeyldap/actions.py b/gkeyldap/actions.py
index be02dfd..13e67f7 100644
--- a/gkeyldap/actions.py
+++ b/gkeyldap/actions.py
@@ -124,6 +124,7 @@ class Actions(object):
         filename = self.config['dev-seedfile'] + '.new'
         self.seeds = Seeds(filename)
         count = 0
+        error_count = 0
         for dev in sorted(devs):
             if devs[dev]['gentooStatus'][0] not in ['active']:
                 continue
@@ -134,10 +135,14 @@ class Actions(object):
                 new_gkey = GKEY._make(keyinfo)
                 self.seeds.add(new_gkey)
                 count += 1
+            else:
+                error_count += 1
         self.output("Total number of seeds created:", count)
         self.output("Seeds created...saving file: %s" % filename)
+        self.output("Total number of Dev's with gpg errors:", error_count)
         self.logger.info("Total number of seeds created: %d" % count)
         self.logger.info("Seeds created...saving file: %s" % filename)
+        self.logger.info("Total number of Dev's with gpg errors: %d" % error_count)
         return self.seeds.save()
 
 


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

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

commit:     4626141ce6464f8bb6efe04f649864315858496a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu May 15 17:13:24 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu May 15 17:13:24 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=4626141c

cli.py: Complete docstrings

---
 gkeyldap/cli.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py
index 1eba841..51a5060 100644
--- a/gkeyldap/cli.py
+++ b/gkeyldap/cli.py
@@ -27,6 +27,8 @@ class Main(object):
         """ Main class init function.
 
         @param root: string, root path to use
+        @param config: optional GKeysConfig instance, For API use
+        @param print_results: optional boolean, for API use
         """
         self.root = root or "/"
         self.config = config or GKeysConfig(root=root)
@@ -36,6 +38,11 @@ class Main(object):
 
 
     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:
             self.run(self.parse_args(args))
         else:


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

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

commit:     ad9014433b09ada7826ae7a7e7c5a999121c000f
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Mon May 19 14:50:42 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=ad901443

remove unused build_gkeydict function from gkeyldap

---
 gkeyldap/actions.py | 27 ---------------------------
 1 file changed, 27 deletions(-)

diff --git a/gkeyldap/actions.py b/gkeyldap/actions.py
index 5b33600..27b35bf 100644
--- a/gkeyldap/actions.py
+++ b/gkeyldap/actions.py
@@ -149,33 +149,6 @@ class Actions(object):
         return (x, target, search_field)
 
 
-
-    def build_gkeydict(self, info):
-        keyinfo = {}
-        for x in GKEY._fields:
-            field = gkey2ldap_map[x]
-            if not field:
-                continue
-            try:
-                # strip errant line feeds
-                values = [y.strip('\n') for y in info[field]]
-                if values and values in ['uid', 'cn' ]:
-                    value = values[0]
-                # separate out short/long key id's
-                elif values and x in ['keyid', 'longkeyid']:
-                    value = get_key_ids(x, values)
-                else:
-                    value = values
-                if 'undefined' in values:
-                    self.logger.error('%s = "undefined" for %s, %s'
-                        %(field, info['uid'][0], info['cn'][0]))
-                if value:
-                    keyinfo[x] = value
-            except KeyError:
-                pass
-        return keyinfo
-
-
     def build_gkeylist(self, info):
         keyinfo = []
         keyid_found = False


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

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

commit:     d14b6658b954fe7f521a074a1c181d1ef39ce00f
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 17 18:22:44 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=d14b6658

make all fingerprints uppercase

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

diff --git a/gkeyldap/actions.py b/gkeyldap/actions.py
index e999624..3e66872 100644
--- a/gkeyldap/actions.py
+++ b/gkeyldap/actions.py
@@ -154,6 +154,8 @@ class Actions(object):
                 if not is_ok or not is_match:
                     is_good = False
             if is_good:
+                # some developers add lowercase fingerprints
+                keyinfo['fingerprint'] = [key.upper() for key in keyinfo['fingerprint']]
                 # drop keyid and longkeyid
                 keyinfo.pop('keyid', None)
                 keyinfo.pop('longkeyid', None)


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

end of thread, other threads:[~2014-08-20  3:55 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-15 17:20 [gentoo-commits] proj/gentoo-keys:master commit in: gkeyldap/ Brian Dolbec
  -- strict thread matches above, loose matches on Subject: below --
2014-08-20  3:55 Brian Dolbec
2014-05-27 20:56 Brian Dolbec
2013-11-15  9:16 Brian Dolbec
2013-11-10  1:01 Brian Dolbec
2013-11-10  1:01 Brian Dolbec
2013-11-10  1:01 Brian Dolbec
2013-07-16  0:50 Brian Dolbec
2013-07-06 19:02 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
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

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