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

commit:     5d9e409c8e2dbd6c93052f848b02740bf8dc58c2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 27 21:37:23 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=5d9e409c

gkeys/gkey.py: Add keys and uid fields, update() to GKEY

keys field will hold the primary key fingerprints for the (to be/) installed GKEY.
fingerprints and uid fileds will be populated with all uid's and fingerprints defined in subkeys using the update().

---
 gkeys/gkeys/gkey.py | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/gkeys/gkeys/gkey.py b/gkeys/gkeys/gkey.py
index 41c6d8b..463f007 100644
--- a/gkeys/gkeys/gkey.py
+++ b/gkeys/gkeys/gkey.py
@@ -18,6 +18,7 @@ GKEY_STRING = '''    ----------
     Name.........: %(name)s
     Nick.........: %(nick)s
     Keydir.......: %(keydir)s
+    UID..........: %(uid)s
 '''
 
 GKEY_FINGERPRINTS = \
@@ -26,10 +27,11 @@ GKEY_FINGERPRINTS = \
 '''
 
 
-class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
+class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'uid'])):
     '''Class to hold the relavent info about a key'''
 
-    field_types = {'nick': str, 'name': str, 'keydir': str, 'fingerprint': list}
+    field_types = {'nick': str, 'name': str, 'keydir': str, 'keys': list,
+        'fingerprint': list, 'uid': list}
     __slots__ = ()
 
 
@@ -42,7 +44,12 @@ class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
     @property
     def pretty_print(self):
         '''Pretty printing a GKEY'''
-        gkey = {'name': self.name, 'nick': self.nick, 'keydir': self.keydir}
+        gkey = {
+            'name': self.name,
+            'nick': self.nick,
+            'keydir': self.keydir,
+            'uid': self.uid,
+            }
         output = GKEY_STRING % gkey
         for f in self.fingerprint:
             fingerprint = {'fingerprint': f, 'keyid': '0x' + f[-16:]}
@@ -50,6 +57,25 @@ class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
         return output
 
 
+    def update(self, result_list):
+        '''Processes a results instance from a colon listing
+        and mines all fingerprints found.
+
+        @param result_list: list of pyGPG.output.GPGResult instances
+            (one for each fingerprint in the list)
+        @return: A new, updated GKEY instance
+        '''
+        fingerprints = set()
+        uids = set()
+        for result in result_list:
+            for data in result.status.data:
+                if data.name ==  "FPR":
+                    fingerprints.add(data.fingerprint)
+                elif data.name ==  "UID":
+                    uids.add(data.user_ID)
+        return self._make([self.nick, self.name, self.keydir, self.keys, list(fingerprints), sorted(uids)])
+
+
 class GKEY_CHECK(namedtuple('GKEY_CHECK', ['keyid', 'revoked', 'expired', 'invalid', 'sign'])):
 
     __slots__ = ()


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-08-15 16:15 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-08-15 16:15 UTC (permalink / raw
  To: gentoo-commits

commit:     ac6e01e5646d5f6fdd14d65f43a785368e1d8b80
Author:     Brian Dolbec dolsen <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 15 16:00:32 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Aug 15 16:13:53 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=ac6e01e5

gkeys actions.py: Add unique devs pass/fail tracking to spec-check

This adds numbers tracking to identify which devs have passing keys
and which have only failing keys.

 gkeys/gkeys/actions.py | 54 +++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 42 insertions(+), 12 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 539ff26..78faa9a 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -452,6 +452,8 @@ class Actions(ActionBase):
         catdir, keyresults = self.keyhandler.determine_keys(args)
         self.logger.debug(_unicode("ACTIONS: speccheck; catdir = %s") % catdir)
         results = {}
+        unique_pass = {}
+        unique_fail = {}
         failed = defaultdict(list)
         self.output('', '\n Checking keys...')
         '''Login email'''
@@ -552,9 +554,20 @@ class Actions(ActionBase):
                             pub_pass['final'] = False
                             break
                     if pub_pass['final']:
+                        if gkey.name in unique_fail:
+                            unique_fail.pop(gkey.name)
+                        if gkey.name not in unique_pass:
+                            unique_pass[gkey.name] = []
+                        if spec not in unique_pass[gkey.name]:
+                            unique_pass[gkey.name].append(spec)
                         if spec not in failed['spec-approved']:
                             failed['spec-approved'].append(spec)
                     else:
+                        if gkey.name not in unique_pass:
+                            if gkey.name not in unique_fail:
+                                unique_fail[gkey.name] = []
+                            if spec not in unique_fail[gkey.name]:
+                                unique_fail[gkey.name].append(spec)
                         if spec not in failed['spec']:
                             failed['spec'].append(spec)
                     sdata = convert_pf(pub_pass, ['pub', 'sign', 'final'])
@@ -601,21 +614,38 @@ class Actions(ActionBase):
             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:')
+        fkeys = []
+        pkeys = []
+        if unique_fail:
+            fkeys = sorted(unique_fail)
+            failed['unique-fail'] = []
+            for k in fkeys:
+                failed['unique-fail'].extend(unique_fail[k])
+            self.output([failed['unique-fail']], '\n Unique SPEC Failed by name:')
+        if unique_pass:
+            pkeys = sorted(unique_pass)
+            #failed['unique-pass'] = []
+            #for k in pkeys:
+            #    failed['unique-pass'].extend(unique_pass[k])
+            #self.output([failed['unique-pass']], '\n Unique SPEC Passed:')
+
 
         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'])),
-                'Qualified IDs..........: %d' % len(set(failed['qualified_id'])),
-                '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'])),
+                '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'])),
+                'Qualified IDs............: %d' % len(set(failed['qualified_id'])),
+                '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'])),
+                '===============================',
+                'Unique approved by name..: %d' % len(pkeys),
+                'Unique failed by name....: %d' % len(fkeys),
             ])
 
     def removekey(self, args):


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-08-15  1:51 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-08-15  1:51 UTC (permalink / raw
  To: gentoo-commits

commit:     2bdf8c0c827cf024c4e26f9167ed4a6573625601
Author:     Brian Dolbec dolsen <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 15 01:47:19 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Aug 15 01:47:19 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=2bdf8c0c

gkeys checks.py: Remove missed DSA algorithm entries

Move bitlength calc within the primary if,

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

diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py
index 8119395..8da6414 100644
--- a/gkeys/gkeys/checks.py
+++ b/gkeys/gkeys/checks.py
@@ -64,7 +64,7 @@ TEST_SPEC = {
             'expire': 900,
             },
         },
-    'algorithms': ['DSA', 'RSA', '1', '2', '3', '17'],
+    'algorithms': ['RSA', '1', '2', '3'],
     'versions': ['4'],
     'qualified_id': '@gentoo.org',
 }
@@ -302,8 +302,8 @@ class KeyChecks(object):
 
 
     def _test_bits(self, data, stats):
-        bits = int(data.keylength)
         if data.pubkey_algo in TEST_SPEC['algorithms']:
+            bits = int(data.keylength)
             if bits >= TEST_SPEC['bits'][ALGORITHM_CODES[data.pubkey_algo]]:
                 stats[SPEC_INDEX['bits']] = True
             else:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-08-15  1:05 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-08-15  1:05 UTC (permalink / raw
  To: gentoo-commits

commit:     0b2edc8ff515b404efd8284b3b961b9ffdb4223e
Author:     Brian Dolbec dolsen <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 15 01:04:22 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Aug 15 01:04:22 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=0b2edc8f

gkeys checks.py: Update glep 63 specs

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

diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py
index 7610d70..8119395 100644
--- a/gkeys/gkeys/checks.py
+++ b/gkeys/gkeys/checks.py
@@ -51,18 +51,17 @@ SPEC_STAT = ['', '','', False, False, False, False, False, False, False, False,
 # and approved options, limits
 TEST_SPEC = {
     'bits': {
-        'DSA': 2048,
         'RSA': 2048,
         },
-    'expire': 5 * 365,      # in days
+    'expire': 900,      # in days
     'subkeys': {        # warning/error mode
         'encrypt': {
             'mode': 'notice',
-            'expire': 5 * 365,
+            'expire': 900,
             },
         'sign': {
             'mode': 'error',
-            'expire': 5 * 365,
+            'expire': 900,
             },
         },
     'algorithms': ['DSA', 'RSA', '1', '2', '3', '17'],


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07 15:10 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07 15:10 UTC (permalink / raw
  To: gentoo-commits

commit:     c311c0ad71c73b0af69c6a0e130d92b824d98322
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jul  7 15:08:28 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 15:08:28 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c311c0ad

gkeys/lock.py: Fix missed import namespace edit

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

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

diff --git a/gkeys/gkeys/lock.py b/gkeys/gkeys/lock.py
index 5614335..3e37103 100644
--- a/gkeys/gkeys/lock.py
+++ b/gkeys/gkeys/lock.py
@@ -3,7 +3,7 @@ import os
 
 from snakeoil import fileutils
 from snakeoil import osutils
-from catalyst.fileops import ensure_dirs
+from gkeys.fileops import ensure_dirs
 
 
 LockInUse = osutils.LockException


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07 15:10 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07 15:10 UTC (permalink / raw
  To: gentoo-commits

commit:     dd966401553f4632f60cb673327b9446fb326654
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jul  7 14:47:46 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 14:47:46 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=dd966401

gkeys/base.py: Fix args.email test for gkeys-ldap

gkeys-ldap does not use the email arg.
Prevents:

  File "/var/lib/gkeys/gentoo-keys/gkeys/gkeys/base.py", line 330, in setup
    if args.email:
AttributeError: 'Namespace' object has no attribute 'email'

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

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

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 8aff933..48c8a4d 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -327,7 +327,7 @@ class CliBase(object):
         if args.config:
             self.config.defaults['config'] = args.config
             self.config.defaults['configdir'] = os.path.dirname(args.config)
-            if args.email:
+            if getattr(args, 'email', False):
                 configs = [self.config.defaults['config'], os.path.abspath(os.path.join(self.config.defaults['configdir'], "email.conf"))]
                 self.config.read_config(configs)
             else:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     a297c693402827cec3c5c1740b4559b040903030
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  5 17:00:59 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:13 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=a297c693

gkeys base.py: Fix fetchonly typo and add to Args class

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

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

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 2de1493..8aff933 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -63,6 +63,7 @@ class Args(object):
         self.status = False
         self.timestamp = None
         self.uid = None
+        self.fetchonly = None
 
 
 class CliBase(object):
@@ -131,7 +132,7 @@ class CliBase(object):
             help='Use CASE matching in searches')
 
     @staticmethod
-    def _option_fetcthonly(parser=None):
+    def _option_fetchonly(parser=None):
         parser.add_argument('--fetchonly',
             dest='fetchonly', default=False,
             help="Only fetch the seed file if there is an update or doesn't exist locally")
@@ -375,6 +376,7 @@ class CliBase(object):
         func = getattr(self.actions, '%s'
             % self.cli_config['Action_Map'][args.action]['func'])
         self.logger.debug('Main: run; Found action: %s' % args.action)
+        self.logger.debug('Main: run; args: %s' % str(args.__dict__))
         success, results = func(args)
         if not results:
             print("No results found.  Check your configuration and that the",


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     9aae3603e6785ac216e97c867c09980eefedd7b6
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  5 20:02:29 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:14 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=9aae3603

gkeys: Update version and authors

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

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

diff --git a/gkeys/gkeys/__init__.py b/gkeys/gkeys/__init__.py
index a1e901c..dc19604 100644
--- a/gkeys/gkeys/__init__.py
+++ b/gkeys/gkeys/__init__.py
@@ -9,7 +9,7 @@ from collections import OrderedDict
 from gkeys.action_map import Action_Map, Available_Actions
 
 
-__version__ = '0.2'
+__version__ = '0.3'
 __license__ = 'GPLv2'
 
 if sys.version_info[0] >= 3:
@@ -32,5 +32,5 @@ the GPG keys used for validation on users and Gentoo's infrastracutre servers.
 Gentoo Keys is able to verify GPG keys used for Gentoo's release media,
 such as installation CD's, Live DVD's, packages and other GPG signed documents.''',
     'sub-cmds': subdata,
-    'authors': ['Brian Dolbec <dolsen@gentoo.org>', 'Pavlos Ratis <dastergon@gentoo.org>'],
+    'authors': ['Brian Dolbec <dolsen@gentoo.org>', 'Pavlos Ratis <dastergon@gentoo.org>', 'aeroniero33 <justthisthing@gmail.com>'],
 }


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     8c0866aa69f3b0c600d1f2f9ad7942f563409f4a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  5 18:50:41 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:14 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=8c0866aa

gkeys actions.py: Exit smoothly if fetch failed to get a new file

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index fd92a77..539ff26 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -834,6 +834,9 @@ class Actions(ActionBase):
                                                   climit=climit)
             sig_path = fetcher.sig_path
             messages.extend(msgs)
+            if not success:
+                self.logger.debug(_unicode("ACTIONS: _verify; File not downloaded, exiting... %s"), filepath)
+                return (False, messages)
         elif signature is not None and os.path.exists(signature):
             sig_path = signature
         else:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     653d1b0c231ee789a294d040a67cef141bb11cc0
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  5 17:51:36 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:13 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=653d1b0c

gkeys seedhandler.py: Simplify code, let verify() handle fetching

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

 gkeys/gkeys/seedhandler.py | 68 ++++++++++++++++++++++++----------------------
 1 file changed, 35 insertions(+), 33 deletions(-)

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index cb082ef..a7bfbaa 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -24,6 +24,7 @@ demandload(
     "json:load",
     "gkeys.exception:UpdateDbError",
     "gkeys.fileops:ensure_dirs",
+    "gkeys.fileops:updateseeds",
     "gkeys.fetch:Fetch",
     "sslfetch.connections:get_timestamp",
 )
@@ -170,9 +171,10 @@ class SeedHandler(object):
         if category == 'sign':
             catdir = self.config.get_key('sign-keydir')
         else:
-            keyrings = self.config.get_key('keyring')
-            catdir = os.path.join(keyrings, category)
-        self.logger.debug("SeedHandler: load_category; catdir = %s" % catdir)
+            #keyrings = self.config.get_key('keyring')
+            #catdir = os.path.join(keyrings, category)
+            catdir = self.config.get_key('keyrings', category)
+        self.logger.debug("SeedHandler: load_category; catdir = %s", catdir)
         try:
             if not nicks:
                 nicks = os.listdir(catdir)
@@ -185,11 +187,14 @@ class SeedHandler(object):
                 try:
                     with open(gkey_path, 'r') as fileseed:
                         seed = load(fileseed)
+                    self.logger.debug("SeedHandler: load_category; loaded seed file %s.",
+                                      gkey_path)
                 except IOError as error:
-                    self.logger.debug("SeedHandler: load_category; IOError loading seed file %s."
-                                      % gkey_path)
+                    self.logger.debug("SeedHandler: load_category; IOError loading seed file %s.",
+                                      gkey_path)
                     self.logger.debug("Error was: %s" % str(error))
                 if seed:
+                    self.logger.debug("SeedHandler: load_category; processing seeds: %s", seed)
                     for nick in sorted(seed):
                         key = seed[nick]
                         # GKEY class change auto-update
@@ -206,6 +211,7 @@ class SeedHandler(object):
             self.logger.debug("SeedHandler: load_category; OSError for %s" % catdir)
             self.logger.exception("Error was: %s" % str(error))
         self.seeds = seeds
+        self.logger.debug("SeedHandler: load_category; seeds loaded: %s", seeds)
         return seeds
 
     def fetch_seeds(self, seeds, args, verified_dl=None):
@@ -231,44 +237,40 @@ class SeedHandler(object):
         except KeyError:
             pass
         succeeded = []
-        seedsdir = os.path.join(self.config.get_key('seedsdir'))
+        seedsdir = os.path.dirname(self.config.get_key('seeds', seeds))
         updatedir = os.path.join(seedsdir, "__updates__")
         mode = int(self.config.get_key('permissions', 'directories'),0)
         ensure_dirs(updatedir, mode=mode)
         self.update_lock = LockDir(updatedir)
         self.update_lock.write_lock()
-        fetcher = Fetch(self.logger)
         for (seed, url, filepath) in urls:
             tmppath = os.path.join(updatedir, os.path.split(filepath)[-1])
             # use the real timestamp file for the dl timestamp
             tpath = filepath + ".timestamp"
-            # verify the re-fetch cycle timer
-            if fetcher.verify_cycle(tpath, climit=60):
-                timestamp = get_timestamp(filepath + ".timestamp")
-                success, msgs = fetcher.fetch_url(url, tmppath, timestamp=timestamp)
-                messages.extend(msgs)
-                if success:
-                    verify_info = self.config.get_key('verify-seeds', seed).split()
-                    args.category = verify_info[0]
-                    args.nick = verify_info[1]
-                    args.filename = url
-                    args.signature = tmppath + ".timestamp"
-                    #args.timestamp = True
-                    args.destination = tmppath
-                    verified, messages_ = verified_dl(args)
-                    messages.append(messages_)
-                if verified and not args.fetchonly:
-                    self.seedsdir_lock = LockDir(seedsdir)
-                    if updateseeds(tmppath, filepath) and updateseeds(args.signature, tpath):
-                        self.logger.info("Updated seed file...: %s ... OK" % (filepath))
-                        succeeded.append(verified)
-                    else:
-                        self.logger.info("Updating seed file...: %s ... Failed" % (filepath))
-                        succeeded.append(False)
-                    self.seedsdir_lock.unlock()
+            verify_info = self.config.get_key('verify-seeds', seed).split()
+            args.category = verify_info[0]
+            args.nick = verify_info[1]
+            args.filename = url
+            args.signature = tmppath + ".sig"
+            args.timestamp = tpath
+            args.destination = tmppath
+            args.fetchonly = False
+            verified, messages_ = verified_dl(args)
+            messages.append(messages_)
+            if verified and not args.fetchonly:
+                self.seedsdir_lock = LockDir(seedsdir)
+                if (updateseeds(self.config, self.logger, tmppath, filepath) and
+                    updateseeds(self.config, self.logger, args.signature, tpath)
+                ):
+                    self.logger.info("Updated seed file...: %s ... OK" % (filepath))
+                    succeeded.append(verified)
                 else:
-                    # sha512sum the 2 files
-                    pass
+                    self.logger.info("Updating seed file...: %s ... Failed" % (filepath))
+                    succeeded.append(False)
+                self.seedsdir_lock.unlock()
+            else:
+                # sha512sum the 2 files
+                pass
         self.update_lock.unlock()
         return (succeeded, messages)
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     d2b30942d665fd5a79cef5a933904824273928e7
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  5 17:49:59 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:13 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=d2b30942

gkeys actions.py: Assign sig_path from fetcher

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 2fe29fb..fd92a77 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -832,6 +832,7 @@ class Actions(ActionBase):
             fetcher = Fetch(self.logger)
             success, msgs = fetcher.fetch_url(url, filepath, signature, timestamp_path=timestamp_path,
                                                   climit=climit)
+            sig_path = fetcher.sig_path
             messages.extend(msgs)
         elif signature is not None and os.path.exists(signature):
             sig_path = signature


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     33625064ee63796b6b02ca9f200d3d4ff1707ff9
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  5 15:31:20 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:13 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=33625064

gkeys lib.py: Additional debug logging

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

 gkeys/gkeys/actions.py | 2 --
 gkeys/gkeys/lib.py     | 7 +++++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index e480613..2fe29fb 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -827,8 +827,6 @@ class Actions(ActionBase):
             climit = 60
         else:
             climit = 0
-        sig_path = None
-        get_sig = signature is not None
         self.logger.debug(_unicode("ACTIONS: _verify; supplied signature %s"), signature)
         if isurl:
             fetcher = Fetch(self.logger)

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index a8529f4..7928347 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -88,8 +88,8 @@ class GkeysGPG(GPG):
 
 
     def set_keydir(self, keydir, task, fingerprint=True, reset=True):
-        self.logger.debug("basedir: %s, keydir: %s" % (self.basedir, keydir))
         self.keydir = pjoin(self.basedir, keydir)
+        self.logger.debug("GkeysGPG.set_keydir; keydir: %s, task: %s, self.keydir: %s" % (keydir, task, self.keydir))
         self.task = task
         if reset:
             self.config.options['tasks'][task] = self.config.defaults['tasks'][task][:]
@@ -98,7 +98,7 @@ class GkeysGPG(GPG):
             task_value.append('--fingerprint')
         task_value.extend(['--homedir', self.keydir])
         self.config.options['tasks'][task].extend(task_value)
-        self.logger.debug("set_keydir: New task options: %s" %str(self.config.options['tasks'][task]))
+        self.logger.debug("GkeysGPG.set_keydir; New task options: %s" %str(self.config.options['tasks'][task]))
         return
 
 
@@ -147,6 +147,8 @@ class GkeysGPG(GPG):
                     fingerprint, gkey.name))
             result = self.runGPG(task='recv-keys', inputfile=fingerprint)
             self.logger.info('GPG return code: ' + str(result.returncode))
+            self.logger.debug("LIB: add_key; fingerprint: %s. type: %s", fingerprint, type(fingerprint))
+            self.logger.debug("LIB: add_key; gkey.keys: %s. type: %s", gkey.keys, [type(key) for key in gkey.keys])
             if result.fingerprint in gkey.keys:
                 result.failed = False
                 message = "Fingerprints match... Import successful: "
@@ -254,6 +256,7 @@ class GkeysGPG(GPG):
             self.logger.debug("LIB: list_keys(), invalid keydir parameter: %s"
                 % str(keydir))
             return []
+        self.logger.debug("LIB: list_keys(), keydir parameter: %s"% str(keydir))
         if fingerprint:
             task = 'list-key'
             target = fingerprint


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     a7e1d29148a3e2a2718db101797383b79f2adda6
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  5 15:29:01 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:13 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=a7e1d291

gkeys log.py: Reduce the frequency of new log files, add a timestamp  message

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

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

diff --git a/gkeys/gkeys/log.py b/gkeys/gkeys/log.py
index 4ea5cb1..6916d97 100644
--- a/gkeys/gkeys/log.py
+++ b/gkeys/gkeys/log.py
@@ -51,7 +51,7 @@ def set_logger(namespace=None, logpath='', level=None,
         ensure_dirs(logpath, mode=dirmode, fatal=True)
         os.umask(filemask)
         logname = os.path.join(logpath,
-            '%s-%s.log' % (namespace, time.strftime('%Y%m%d-%H:%M')))
+            '%s-%s.log' % (namespace, time.strftime('%Y%m%d-%H')))
         file_handler = logging.FileHandler(logname)
         if level:
             file_handler.setLevel(log_levels[level])
@@ -66,7 +66,7 @@ def set_logger(namespace=None, logpath='', level=None,
     #Console_handler.setFormatter(formatter)
     logger.addHandler(Console_handler)
     #print "File logger suppose to be initialized", logger, Console_handler
-    logger.debug("Loggers initialized")
+    logger.debug("==== Loggers initialized ==== time: %s", time.strftime('%Y%m%d-%H:%M:%S') )
 
     return logger
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     eed71e755fca18ebc271b3a3b72e70c0822f55d2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jul  2 21:57:23 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:12 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=eed71e75

gkeys: Implement use of the new Fetch class

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

 gkeys/gkeys/actions.py     | 51 +++++-------------------------------
 gkeys/gkeys/base.py        |  6 +++++
 gkeys/gkeys/seedhandler.py | 64 ++++++++++++++++++++++++++++++++++------------
 3 files changed, 61 insertions(+), 60 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 64d6123..0f03880 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -29,6 +29,7 @@ from snakeoil.demandload import demandload
 
 demandload(
     "gkeys.base:Args",
+    "gkeys.fetch:Fetch",
     "json:load",
 )
 
@@ -718,9 +719,7 @@ class Actions(ActionBase):
 
     def installed(self, args):
         '''Lists the installed key directories'''
-        if args.category:
-            keyring = self.config.get_key('keyring')
-        else:
+        if not args.category:
             return (False, ["Please specify a category."])
         catdir = self._set_category(args.category)
         self.logger.debug("ACTIONS: installed; catdir = %s" % catdir)
@@ -818,45 +817,10 @@ class Actions(ActionBase):
             climit = 0
         sig_path = None
         if isurl:
-            from sslfetch.connections import Connector
-            connector_output = {
-                 'info': self.logger.info,
-                 'debug': self.logger.debug,
-                 'error': self.logger.error,
-                 'exception': self.logger.exception,
-                 # we want any warnings to be printed to the terminal
-                 # so assign it to logging.error
-                 'warning': self.logger.error,
-                 'kwargs-info': {},
-                 'kwargs-debug': {},
-                 'kwargs-error': {},
-                 'kwargs-exception': {},
-                 'kwargs-warning': {},
-            }
-            fetcher = Connector(connector_output, None, "Gentoo Keys")
-            self.logger.debug(
-                _unicode("ACTIONS: verify; fetching %s signed file ") % filepath)
-            self.logger.debug(
-                _unicode("ACTIONS: verify; timestamp path: %s") % timestamp_path)
-            success, signedfile, timestamp = fetcher.fetch_file(
-                url, filepath, timestamp_path, climit=climit)
-            if not success:
-                messages.append(_unicode("File %s cannot be retrieved.") % filepath)
-            elif '.' + url.rsplit('.', 1)[1] not in EXTENSIONS:
-                if not signature:
-                    success_fetch = False
-                    for ext in EXTENSIONS:
-                        sig_path = filepath + ext
-                        if isurl:
-                            signature = url + ext
-                            self.logger.debug(
-                                _unicode("ACTIONS: verify; fetching %s signature ")
-                                % signature)
-                            success_fetch, sig, timestamp = fetcher.fetch_file(signature, sig_path)
-                        if success_fetch:
-                            break
-                        else:
-                            signature = None
+            fetcher = Fetch(self.logger)
+            success, msgs = fetcher.fetch_url(url, filepath, signature, timestamp_path=timestamp_path,
+                                                  climit=climit)
+            messages.extend(msgs)
         elif signature is not None and os.path.exists(signature):
             sig_path = signature
         else:
@@ -864,9 +828,8 @@ class Actions(ActionBase):
             self.logger.debug(
                 _unicode("ACTIONS: verify; local file %s") % filepath)
             success = os.path.isfile(filepath)
-            if (not signature
+            if (success and not signature
                 and '.' + filepath.rsplit('.', 1)[-1] not in EXTENSIONS):
-                success_fetch = False
                 for ext in EXTENSIONS:
                     sig_path = filepath + ext
                     sig_path = os.path.abspath(sig_path)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index a67b330..2de1493 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -130,6 +130,12 @@ class CliBase(object):
             action='store_true', default=False,
             help='Use CASE matching in searches')
 
+    @staticmethod
+    def _option_fetcthonly(parser=None):
+        parser.add_argument('--fetchonly',
+            dest='fetchonly', default=False,
+            help="Only fetch the seed file if there is an update or doesn't exist locally")
+
     @staticmethod
     def _option_file(parser=None):
         parser.add_argument('-F', '--file', dest='filename', default=None,

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index afe5971..cb082ef 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -17,12 +17,15 @@ import re
 from snakeoil.demandload import demandload
 
 from gkeys.gkey import GKEY
+from gkeys.lock import LockDir
 from gkeys.seed import Seeds, decoder
 
 demandload(
     "json:load",
     "gkeys.exception:UpdateDbError",
     "gkeys.fileops:ensure_dirs",
+    "gkeys.fetch:Fetch",
+    "sslfetch.connections:get_timestamp",
 )
 
 
@@ -34,6 +37,8 @@ class SeedHandler(object):
         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}')
         self.seeds = None
+        self.seedsdir_lock = None
+        self.update_lock = None
 
 
     def new(self, args, checkgkey=False):
@@ -70,10 +75,10 @@ class SeedHandler(object):
                 if attr in GKEY._fields:
                     keyinfo[attr] = None
         return keyinfo
-    
+
     def compare_seeds(self, seeds1, seeds2) :
         '''Compares two seed lists and returns the differences
-        
+
         @param seeds1: set of seeds to be compared
         @param seeds2: set of seeds to be compared
         @return added_gkeys: list of keys that are included in seed2 but not seed1
@@ -98,7 +103,7 @@ class SeedHandler(object):
                 if old_gkey not in new_gkeys and old_gkey not in old_changed_gkeys:
                     removed_gkeys.append(old_gkey)
         else:
-            added_gkeys = new_gkeys 
+            added_gkeys = new_gkeys
         return(added_gkeys, changed_gkeys, removed_gkeys)
 
     def compare_seeds(self, seeds1, seeds2) :
@@ -181,7 +186,8 @@ class SeedHandler(object):
                     with open(gkey_path, 'r') as fileseed:
                         seed = load(fileseed)
                 except IOError as error:
-                    self.logger.debug("SeedHandler: load_category; IOError loading seed file %s." % gkey_path)
+                    self.logger.debug("SeedHandler: load_category; IOError loading seed file %s."
+                                      % gkey_path)
                     self.logger.debug("Error was: %s" % str(error))
                 if seed:
                     for nick in sorted(seed):
@@ -206,6 +212,7 @@ class SeedHandler(object):
         '''Fetch new seed files
 
         @param seeds: list of seed nicks to download
+        @param args: argparse namespace instance
         @param verified_dl: Function pointer to the Actions.verify()
                 instance needed to do the download and verification
         '''
@@ -224,20 +231,45 @@ class SeedHandler(object):
         except KeyError:
             pass
         succeeded = []
-        seedsdir = self.config.get_key('seedsdir')
+        seedsdir = os.path.join(self.config.get_key('seedsdir'))
+        updatedir = os.path.join(seedsdir, "__updates__")
         mode = int(self.config.get_key('permissions', 'directories'),0)
-        ensure_dirs(seedsdir, mode=mode)
+        ensure_dirs(updatedir, mode=mode)
+        self.update_lock = LockDir(updatedir)
+        self.update_lock.write_lock()
+        fetcher = Fetch(self.logger)
         for (seed, url, filepath) in urls:
-            verify_info = self.config.get_key('verify-seeds', seed).split()
-            args.category = verify_info[0]
-            args.nick = verify_info[1]
-            args.filename = url
-            args.signature = None
-            args.timestamp = True
-            args.destination = filepath
-            verified, messages_ = verified_dl(args)
-            succeeded.append(verified)
-            messages.append(messages_)
+            tmppath = os.path.join(updatedir, os.path.split(filepath)[-1])
+            # use the real timestamp file for the dl timestamp
+            tpath = filepath + ".timestamp"
+            # verify the re-fetch cycle timer
+            if fetcher.verify_cycle(tpath, climit=60):
+                timestamp = get_timestamp(filepath + ".timestamp")
+                success, msgs = fetcher.fetch_url(url, tmppath, timestamp=timestamp)
+                messages.extend(msgs)
+                if success:
+                    verify_info = self.config.get_key('verify-seeds', seed).split()
+                    args.category = verify_info[0]
+                    args.nick = verify_info[1]
+                    args.filename = url
+                    args.signature = tmppath + ".timestamp"
+                    #args.timestamp = True
+                    args.destination = tmppath
+                    verified, messages_ = verified_dl(args)
+                    messages.append(messages_)
+                if verified and not args.fetchonly:
+                    self.seedsdir_lock = LockDir(seedsdir)
+                    if updateseeds(tmppath, filepath) and updateseeds(args.signature, tpath):
+                        self.logger.info("Updated seed file...: %s ... OK" % (filepath))
+                        succeeded.append(verified)
+                    else:
+                        self.logger.info("Updating seed file...: %s ... Failed" % (filepath))
+                        succeeded.append(False)
+                    self.seedsdir_lock.unlock()
+                else:
+                    # sha512sum the 2 files
+                    pass
+        self.update_lock.unlock()
         return (succeeded, messages)
 
     def check_gkey(self, args):


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     0a745d03d5dbfd1b6e31db92a5ce55aa33084c7a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jul  2 21:40:21 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:11 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=0a745d03

gkeys/utils.py: Add get_ack function

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

 gkeys/gkeys/utils.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gkeys/gkeys/utils.py b/gkeys/gkeys/utils.py
index 64f11aa..f08acc1 100644
--- a/gkeys/gkeys/utils.py
+++ b/gkeys/gkeys/utils.py
@@ -39,6 +39,8 @@ try:
 except AttributeError:
     StringTypes = [str]
 
+Y_N = ("y", "yes", "n", "no")
+
 
 def encoder(text, _encoding_):
     return codecs.encode(text, _encoding_, 'replace')
@@ -161,6 +163,13 @@ def path(path_elements):
     return pathname
 
 
+def get_ack(prompt_msg, accepted=Y_N):
+    ack = None
+    while ack not in accepted:
+        ack = py_input(prompt_msg).lower()
+    return ack
+
+
 if __name__ == '__main__':
     import doctest
     doctest.testmod(sys.modules[__name__])


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     57fc6696d44df48c6a72fd0c1e08741e11f048e8
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  5 15:28:24 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:13 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=57fc6696

gkeys keyhandler: Additional debug logging

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

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

diff --git a/gkeys/gkeys/keyhandler.py b/gkeys/gkeys/keyhandler.py
index 0a02c22..06f4b86 100644
--- a/gkeys/gkeys/keyhandler.py
+++ b/gkeys/gkeys/keyhandler.py
@@ -75,10 +75,11 @@ class KeyHandler(object):
 
 
     def determine_keys(self, args, default_cat=None):
+        self.logger.debug(_unicode("KeyHandler: determine_keys; args.category = %s"), args.category or default_cat)
         seeds = self.seedhandler.load_category(args.category or default_cat)
         keyring = self.config.get_key('keyring')
         catdir = os.path.join(keyring, args.category)
-        self.logger.debug(_unicode("KeyHandler: determine_keys; catdir = %s") % catdir)
+        self.logger.debug(_unicode("KeyHandler: determine_keys; catdir = %s"), catdir)
         kwargs = self.seedhandler.build_gkeydict(args)
         return (catdir, seeds.list(**kwargs))
 
@@ -88,10 +89,12 @@ class KeyHandler(object):
         results = {}
         search_args = [x for x in KEY_OPTIONS if getattr(args, x)]
         if args.category:
+            self.logger.debug(_unicode("KeyHandler: key_search; args.category = %s"), args.category)
             self.seedhandler.load_category(args.category)
             results[args.category] = self.seedhandler.key_search(args, search_args)
         else:
             for cat in sorted(self.config.get_key('seeds')):
+                self.logger.debug(_unicode("KeyHandler: key_search; cat = %s"), cat)
                 self.seedhandler.load_category(cat)
                 found = self.seedhandler.key_search(args, search_args)
                 if found:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     80a59eed95c17a8702da10f54f9b6fdf8e90a880
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jul  2 21:52:53 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:11 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=80a59eed

gkeys/lock.py: New LockDir class

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

 gkeys/gkeys/lock.py | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/gkeys/gkeys/lock.py b/gkeys/gkeys/lock.py
new file mode 100644
index 0000000..5614335
--- /dev/null
+++ b/gkeys/gkeys/lock.py
@@ -0,0 +1,31 @@
+
+import os
+
+from snakeoil import fileutils
+from snakeoil import osutils
+from catalyst.fileops import ensure_dirs
+
+
+LockInUse = osutils.LockException
+
+
+class LockDir(object):
+    """An object that creates locks inside dirs"""
+
+    def __init__(self, lockdir):
+        #self.gid = 250
+        self.lockfile = os.path.join(lockdir, '.gkeys_lock')
+        ensure_dirs(lockdir)
+        fileutils.touch(self.lockfile, mode=0o664)
+        #os.chown(self.lockfile, -1, self.gid)
+        self.lock = osutils.FsLock(self.lockfile)
+
+    def read_lock(self):
+        self.lock.acquire_read_lock()
+
+    def write_lock(self):
+        self.lock.acquire_write_lock()
+
+    def unlock(self):
+        # Releasing a write lock is the same as a read lock.
+        self.lock.release_write_lock()


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     c63848f59c5f960c3e7cd82ed1f5ff1efe2870ba
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  5 15:25:13 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:12 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c63848f5

gkeys actionbase.py: Update _set_category for the new keyrings config

All keyings locations can be set individually now

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

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

diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py
index 23b7161..737c9d6 100644
--- a/gkeys/gkeys/actionbase.py
+++ b/gkeys/gkeys/actionbase.py
@@ -80,13 +80,12 @@ class ActionBase(object):
 
 
     def _set_category(self, cat):
-        keyring = self.config.get_key('keyring')
-        if not keyring:
+        catdir = self.config.get_key('keyrings', cat)
+        if not catdir:
             raise Exception("No keyring set.")
         if not cat:
             raise Exception("No category set.")
         self.category = cat
-        catdir = os.path.join(keyring, cat)
         self.logger.debug(_unicode("ACTIONS: _set_category; catdir = %s") % catdir)
         self._set_trust(cat)
         return catdir


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     6a3a033243058a2724bc6c8d8cb2b2bd6cf73109
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jul  4 23:02:12 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:12 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=6a3a0332

gkeys actions.py: Add verify() recursion detection and exit

Handles the case of incorrect configuration or keyring problems.
Reported by irc user "puchu" in #gentoo-keys.

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

 gkeys/gkeys/actionbase.py |  1 +
 gkeys/gkeys/actions.py    | 10 +++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py
index 3993be4..23b7161 100644
--- a/gkeys/gkeys/actionbase.py
+++ b/gkeys/gkeys/actionbase.py
@@ -43,6 +43,7 @@ class ActionBase(object):
         self._keyhandler = None
         self._gpg = None
         self.category = None
+        self.verify_recursion = False
 
 
     @property

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 0f03880..f9bba7a 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -779,7 +779,7 @@ class Actions(ActionBase):
         if not keys:
             return (False, ['No installed keys found, try installkey action.'])
         key = self.seedhandler.seeds.nick_search(args.nick)
-        if not key:
+        if not key and not self.verify_recursion:
             if args.nick:
                 messages.append(_unicode(
                     "Failed to find.........: %s in category: %s")
@@ -788,7 +788,15 @@ class Actions(ActionBase):
             args.nick = self.config.get_key('verify-nick')
             messages.append(_unicode("Using config defaults..: %s %s")
                 % (args.category, args.nick))
+            self.verify_recursion = True
             return self.verify(args, messages)
+        elif self.verify_recursion:
+            messages.append(_unicode(
+                "Failed to find.........: %s in category: %s")
+                % (args.category, args.nick))
+            messages.append("    ...giving up")
+            self.verify_recursion = False
+            return (False, ['No installed verification keys found, try installkey action.'])
         return self._verify(args, key, messages)
 
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     8482e689c5000493655cfbdfc38d90b389319dc2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  5 15:25:56 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:12 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=8482e689

gkeys actions.py: Additional debug logging

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index f9bba7a..e480613 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -284,6 +284,7 @@ class Actions(ActionBase):
         kwargs = self.seedhandler.build_gkeydict(args)
         keyresults = seeds.list(**kwargs)
         for key in sorted(keyresults):
+            self.logger.debug("ACTIONS: listkey; key/keydir:" + str(key.keydir))
             if args.fingerprint:
                 result = self.gpg.list_keys(key.keydir, kwargs['fingerprint'])
             else:
@@ -775,6 +776,7 @@ class Actions(ActionBase):
             self.logger.debug(_unicode(
                 "ACTIONS: verify; keyring category not specified, using default: %s")
                 % args.category)
+        self.logger.debug(_unicode("ACTIONS: verify; keyring category: %s"), args.category)
         keys = self.seedhandler.load_category(args.category)
         if not keys:
             return (False, ['No installed keys found, try installkey action.'])
@@ -788,6 +790,7 @@ class Actions(ActionBase):
             args.nick = self.config.get_key('verify-nick')
             messages.append(_unicode("Using config defaults..: %s %s")
                 % (args.category, args.nick))
+            self.logger.debug(_unicode("ACTIONS: verify; going recursive... %s, %s"), args.category, args.nick)
             self.verify_recursion = True
             return self.verify(args, messages)
         elif self.verify_recursion:
@@ -808,6 +811,7 @@ class Actions(ActionBase):
         timestamp_path = None
         isurl = success = verified = False
         if filepath.startswith('http'):
+            self.logger.debug(_unicode("ACTIONS: _verify; supplied url, using current directory ./%s"), filepath)
             isurl = True
             url = filepath
             filepath = args.destination
@@ -824,6 +828,8 @@ class Actions(ActionBase):
         else:
             climit = 0
         sig_path = None
+        get_sig = signature is not None
+        self.logger.debug(_unicode("ACTIONS: _verify; supplied signature %s"), signature)
         if isurl:
             fetcher = Fetch(self.logger)
             success, msgs = fetcher.fetch_url(url, filepath, signature, timestamp_path=timestamp_path,
@@ -851,7 +857,7 @@ class Actions(ActionBase):
                         sig_path = None
             elif signature:
                 sig_path = os.path.abspath(signature)
-        self.logger.info("Verifying file...")
+        self.logger.info("Verifying file... %s, %s, %s", key, sig_path, filepath)
         verified = False
         results = self.gpg.verify_file(key, sig_path, filepath)
         keyid = key.keyid[0]


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     dfdfd7ccde868f2069de44bb5c3331482177b88d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jul  2 21:50:32 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:11 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=dfdfd7cc

gkeys/fileops.py: Add new updateseeds function

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

 gkeys/gkeys/fileops.py | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gkeys/gkeys/fileops.py b/gkeys/gkeys/fileops.py
index 5b89ea8..f6341ca 100644
--- a/gkeys/gkeys/fileops.py
+++ b/gkeys/gkeys/fileops.py
@@ -1,4 +1,6 @@
 import os
+import shutil
+
 from snakeoil.osutils import (ensure_dirs as snakeoil_ensure_dirs)
 
 
@@ -61,3 +63,29 @@ def updatefiles(config, logger, category=None, filename = None):
         raise
         return False
     return True
+
+
+def updateseeds(config, logger, src, dst):
+    if not src or not dst:
+        logger.error("MAIN: updateseeds();  source and/or destination not supplied")
+        return False
+    try:
+        if os.path.exists(dst):
+            logger.debug(
+                "MAIN: updateseeds(); Removing 'old' seed file: %s"
+                % dst)
+            os.unlink(dst)
+        if os.path.exists(src):
+            logger.debug(
+                "MAIN: updateseeds(); Moving new seed file to: "
+                "%s" % dst)
+            shutil.move(src, dst)
+    except IOError:
+        raise
+        return False
+    return True
+
+
+def rm_files(config, logger, files, lock=None):
+    pass
+


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     f048645778033bed905ca391c93234dc9c880067
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jul  2 21:33:38 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:11 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=f0486457

gkeys/actions/py: Move the py_input & _unicode import to __init__.py

This way it is done once and can be re-used anywhere in the code.

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

 gkeys/gkeys/__init__.py | 8 ++++++++
 gkeys/gkeys/actions.py  | 9 +--------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/gkeys/gkeys/__init__.py b/gkeys/gkeys/__init__.py
index 05fc730..a1e901c 100644
--- a/gkeys/gkeys/__init__.py
+++ b/gkeys/gkeys/__init__.py
@@ -2,6 +2,7 @@
 # -*- coding: utf-8 -*-
 
 
+import sys
 
 from collections import OrderedDict
 
@@ -11,6 +12,13 @@ from gkeys.action_map import Action_Map, Available_Actions
 __version__ = '0.2'
 __license__ = 'GPLv2'
 
+if sys.version_info[0] >= 3:
+    py_input = input
+    _unicode = str
+else:
+    py_input = raw_input
+    _unicode = unicode
+
 
 subdata = OrderedDict()
 for cmd in Available_Actions:

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 71ed081..64d6123 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -15,18 +15,11 @@ from __future__ import print_function
 
 import itertools
 import os
-import sys
-
-if sys.version_info[0] >= 3:
-    py_input = input
-    _unicode = str
-else:
-    py_input = raw_input
-    _unicode = unicode
 
 
 from collections import defaultdict
 
+from gkeys import _unicode, py_input
 from gkeys.actionbase import ActionBase
 from gkeys.gkey import GKEY
 from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     691285b64caf4497d693462751d81a74934b36a1
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jul  2 21:52:17 2018 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:11 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=691285b6

gkeys/fetch.py: New Fetch class

Add sig_path assignment, makes the sig_path available to class instance holders like _verify()
Use the lack of a returned timestamp to abort the process
If the main file is not downloaded, then don't bother looking for a signature.
This allows a verify action to exit smoothly.
There is a message about the reason for not downloading, so is not hidden.

Signed-off-by: Brian Dolbec <dolsen <AT> gentoo.org>

 gkeys/gkeys/fetch.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/gkeys/gkeys/fetch.py b/gkeys/gkeys/fetch.py
new file mode 100644
index 0000000..365124a
--- /dev/null
+++ b/gkeys/gkeys/fetch.py
@@ -0,0 +1,63 @@
+
+from sslfetch.connections import Connector, get_timestamp
+from gkeys import _unicode
+
+EXTENSIONS = ['.sig', '.asc', '.gpg','.gpgsig']
+
+
+class Fetch(object):
+
+    def __init__(self, logger):
+        self.logger = logger
+        connector_output = {
+             'info': self.logger.info,
+             'debug': self.logger.debug,
+             'error': self.logger.error,
+             'exception': self.logger.exception,
+             # we want any warnings to be printed to the terminal
+             # so assign it to logging.error
+             'warning': self.logger.error,
+             'kwargs-info': {},
+             'kwargs-debug': {},
+             'kwargs-error': {},
+             'kwargs-exception': {},
+             'kwargs-warning': {},
+        }
+        self.fetcher = Connector(connector_output, None, "Gentoo Keys")
+        self.sig_path = None
+
+    def fetch_url(self, url, filepath, signature=True, timestamp=None, timestamp_path=None, climit=60):
+        if not timestamp_path:
+            timestamp_path = filepath + ".timestamp"
+        messages = []
+        self.logger.debug(
+            _unicode("FETCH: fetching %s signed file ") % filepath)
+        self.logger.debug(
+            _unicode("FETCH: timestamp path: %s") % timestamp_path)
+        success, signedfile, timestamp = self.fetcher.fetch_file(
+            url, filepath, timestamp_path, climit=climit, timestamp=timestamp)
+        if timestamp is '':
+            self.logger.debug("Fetch.fetch_url; file not downloaded")
+            return (False, messages)
+        elif not success:
+            messages.append(_unicode("File %s cannot be retrieved.") % filepath)
+        elif '.' + url.rsplit('.', 1)[1] not in EXTENSIONS:
+            self.logger.debug("File %s successfully retrieved.", filepath)
+            if signature:
+                success_fetch = False
+                for ext in EXTENSIONS:
+                    sig_path = filepath + ext
+                    signature = url + ext
+                    self.logger.debug(
+                        _unicode("FETCH: fetching %s signature ")
+                        % signature)
+                    success_fetch, sig, timestamp = self.fetcher.fetch_file(signature, sig_path)
+                    if success_fetch:
+                        self.sig_path = sig_path
+                        break
+                    else:
+                        signature = None
+        return (success, messages)
+
+    def verify_cycle(self, tpath, climit=60):
+        return self.fetcher.verify_cycle(tpath, climit=60)


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2018-07-07  5:23 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2018-07-07  5:23 UTC (permalink / raw
  To: gentoo-commits

commit:     5ac5f27889115cd48e89e910a3d12380367cccb6
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 24 09:11:08 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul  7 05:22:10 2018 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=5ac5f278

gkeys base.py: Remove the auto-update code from run()

This code was causing the fetch-seed action to fail with empty urls to connect to.
This code should also not be running directly from the CliBase class.
I'll move this code to the actions or lib class, to be determined later.

 gkeys/gkeys/base.py | 58 -----------------------------------------------------
 1 file changed, 58 deletions(-)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 3ecbd1b..a67b330 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -358,7 +358,6 @@ class CliBase(object):
             return False
         return True
 
-
     def run(self, args):
         '''Run the action selected
 
@@ -366,63 +365,6 @@ class CliBase(object):
         '''
         # establish our actions instance
         self.actions = self.cli_config['Actions'](self.config, self.output_results, self.logger)
-        # check for seed update
-        from sslfetch.connections import Connector
-        connector_output = {
-             'info': self.logger.info,
-             'debug': self.logger.debug,
-             'error': self.logger.error,
-             'exception': self.logger.exception,
-             'warning': self.warning_output,
-             'kwargs-info': {},
-             'kwargs-debug': {},
-             'kwargs-error': {},
-             'kwargs-exception': {},
-             'kwargs-warning': {},
-        }
-        fetcher = Connector(connector_output, None, "Gentoo Keys")
-        successes = []
-        up_to_date = True
-        categories = list(self.config.defaults['seeds'])
-        '''Attemp to download seed and seed.sig files for each available category'''
-        for category in categories:
-            filepath = self.config.defaults['seedsdir'] + "/" + category + ".seeds"
-            timestamp_path = filepath + ".timestamp"
-            url = self.config.defaults['seedurls'][category]
-            success, signedfile, timestamp = fetcher.fetch_file(
-                url, filepath, timestamp_path)
-            if timestamp != "":
-                up_to_date = False
-            successes.append(success)
-            url += ".sig"
-            filepath += ".sig"
-            success, signedfile, timestamp = fetcher.fetch_file(
-                url, filepath, timestamp_path)
-            if timestamp != "":
-                up_to_date = False
-            successes.append(success)
-        if False not in successes and not up_to_date:
-            print("Seeds need to be updated")
-            ack = None
-            while ack not in ("y", "yes", "n", "no"):
-                ack = py_input("Would you like to update the seeds now? (y/n) ").lower()
-            if ack in ("y", "yes"):
-                custom_args = copy.copy(args)
-                for attr in GKEY._fields:
-                    if attr != "debug":
-                        custom_args.attr = None
-                custom_args.category = None
-                custom_args.action = "update-seed"
-                print("Updating seeds")
-                self.run(custom_args)
-        elif False not in successes:
-            print("Seeds are up to date")
-        else:
-<<<<<<< HEAD
-            print("Seed update check failed, check your internet connection.")
-=======
-            print("Seed update check failed, check your internet connection.")
->>>>>>> b9e64a9... gkeys actions: Added automatic seeds,keys update capability
         # run the action
         func = getattr(self.actions, '%s'
             % self.cli_config['Action_Map'][args.action]['func'])


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:gsoc-2016 commit in: gkeys/gkeys/
@ 2016-12-24  9:13 Brian Dolbec
  2016-12-24  0:38 ` [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
  0 siblings, 1 reply; 144+ messages in thread
From: Brian Dolbec @ 2016-12-24  9:13 UTC (permalink / raw
  To: gentoo-commits

commit:     93c87f84c607819b8b544705f2b50d6721911bd3
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 24 00:36:55 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Dec 24 00:36:55 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=93c87f84

gkeys actionbase:  Fix trust model detection & setting in _set_trust()

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

diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py
index 67d3520..3993be4 100644
--- a/gkeys/gkeys/actionbase.py
+++ b/gkeys/gkeys/actionbase.py
@@ -95,8 +95,8 @@ class ActionBase(object):
         trust = self.config.get_key('trust-model', cat)
         if trust in [None]:
             trust = 'auto'
-        if 'trust-model' in self.config.defaults['gpg_defaults']:
-            index = self.config.defaults['gpg_defaults'].index('trust-model')
+        if '--trust-model' in self.config.defaults['gpg_defaults']:
+            index = self.config.defaults['gpg_defaults'].index('--trust-model')
             self.config.defaults['gpg_defaults'][index+1] = trust
         else:
             self.config.defaults['gpg_defaults'].extend(['--trust-model', trust])


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:gsoc-2016 commit in: gkeys/gkeys/
@ 2016-12-24  9:13 Brian Dolbec
  2016-12-24  0:38 ` [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
  0 siblings, 1 reply; 144+ messages in thread
From: Brian Dolbec @ 2016-12-24  9:13 UTC (permalink / raw
  To: gentoo-commits

commit:     db9c5818bdf1623bdb96a2656e9f2d7d3985eed3
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 24 00:35:11 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Dec 24 00:35:11 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=db9c5818

gkeys actions: Fix missing category errors for sign action

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index b38db19..07dba7a 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -830,8 +830,10 @@ class Actions(ActionBase):
             nicks = [args.nick]
         else:
             nicks = args.nick
+        args.category = 'sign'
         # load our installed signing keys db
         self.seeds = self.seedhandler.load_category('sign', nicks)
+        self.category = args.category
         if not self.seeds.seeds:
             return (False, ['No installed keys, try installkey action.', ''])
         keydir  = self.config.get_key("sign", "keydir")


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:gsoc-2016 commit in: gkeys/gkeys/
@ 2016-12-24  9:13 Brian Dolbec
  2016-10-27 21:49 ` [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
  0 siblings, 1 reply; 144+ messages in thread
From: Brian Dolbec @ 2016-12-24  9:13 UTC (permalink / raw
  To: gentoo-commits

commit:     cc14fb9350cbfea5d07564bee963d9dc60b94239
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 27 21:48:07 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Oct 27 21:49:01 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=cc14fb93

Actions._verify: support --signature path argument

If the --signature argument refers to an existing file path,
use it. This fixes an issue where signature verification would
fail because the sig_path variable referred to None.

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index d51fb3f..b38db19 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -758,6 +758,8 @@ class Actions(ActionBase):
                             break
                         else:
                             signature = None
+        elif signature is not None and os.path.exists(signature):
+            sig_path = signature
         else:
             filepath = os.path.abspath(filepath)
             self.logger.debug(


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:gsoc-2016 commit in: gkeys/gkeys/
@ 2016-12-24  9:13 Brian Dolbec
  2016-10-27 18:41 ` [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
  0 siblings, 1 reply; 144+ messages in thread
From: Brian Dolbec @ 2016-12-24  9:13 UTC (permalink / raw
  To: gentoo-commits

commit:     961f66af2d741386bc917de569153863e086732a
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 24 05:45:59 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Oct 24 05:58:34 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=961f66af

Actions.checkkey: fix success returncode

The failed dictionary contains lists for each type of failure,
so return success if all of those lists are emtpy.

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 1b27605..d51fb3f 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -13,6 +13,7 @@
 
 from __future__ import print_function
 
+import itertools
 import os
 import sys
 
@@ -360,7 +361,7 @@ class Actions(ActionBase):
             self.output([failed['invalid']], '\n Invalid keys:\n')
         if failed['sign']:
             self.output([failed['sign']], '\n No signing capable subkeys:\n')
-        return (len(failed) <1,
+        return (not any(itertools.chain.from_iterable(failed.values())),
             ['\nFound:\n-------', 'Expired: %d' % len(failed['expired']),
                 'Revoked: %d' % len(failed['revoked']),
                 'Invalid: %d' % len(failed['invalid']),


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2016-12-24  4:52 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2016-12-24  4:52 UTC (permalink / raw
  To: gentoo-commits

commit:     c1cf82a2f2f651da4749065be050154f23e07469
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 24 04:51:55 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Dec 24 04:51:55 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c1cf82a2

gkeys actions: Migrate self.category setting to _set_category()

 gkeys/gkeys/actions.py | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 07dba7a..a9d2b69 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -108,6 +108,7 @@ class Actions(ActionBase):
         if args.uid is None:
             args.uid = []
         gkey = self.seedhandler.new(args, checkgkey=True)
+        self._set_category(args.category)
         if not gkey:
             return (False, ["Failed to create a valid GKEY instance.",
                 "Check for invalid data entries"])
@@ -198,7 +199,7 @@ class Actions(ActionBase):
         # fill in code here
         if not args.category:
             args.category = 'gentoo'
-        self.category = args.category
+        self._set_category(args.category)
         if args.keydir:
             self.gpg.set_keydir(args.keydir, "list-keys")
             self.gpg.set_keyseedfile()
@@ -267,7 +268,7 @@ class Actions(ActionBase):
                     return (False, ["Search failed for search term"])
             # get confirmation
             # fill in code here
-            self.category = args.category
+            self._set_category(args.category)
             for gkey in gkeys:
                 self.gpg.set_keydir(gkey.keydir, "recv-keys")
                 self.gpg.set_keyseedfile()
@@ -325,7 +326,7 @@ class Actions(ActionBase):
             return (False, [_unicode("Please specify seeds category.")])
         self.logger.debug(_unicode("ACTIONS: checkkey; args: %s") % _unicode(args))
         seeds = self.seedhandler.load_category(args.category)
-        self.category = args.category
+        self._set_category(args.category)
         results = {}
         failed = defaultdict(list)
         kwargs = self.seedhandler.build_gkeydict(args)
@@ -375,7 +376,7 @@ class Actions(ActionBase):
             return (False, ["Please specify seeds category."])
         self.logger.debug(_unicode("ACTIONS: speccheck; args: %s")
             % _unicode(args))
-        self.category = args.category
+        self._set_category(args.category)
         catdir, keyresults = self.keyhandler.determine_keys(args)
         self.logger.debug(_unicode("ACTIONS: speccheck; catdir = %s") % catdir)
         results = {}
@@ -524,6 +525,7 @@ class Actions(ActionBase):
         self.logger.debug(_unicode("ACTIONS: removekey; kwargs: %s")
             % _unicode(kwargs))
         seeds = self.seedhandler.load_category(args.category)
+        self._set_category(args.category)
         messages = []
         if args.nick == '*':
             self.output([''],_unicode('Remove All keys in category: %s')
@@ -620,9 +622,9 @@ class Actions(ActionBase):
         '''Lists the installed key directories'''
         if args.category:
             keyring = self.config.get_key('keyring')
-            catdir = os.path.join(keyring, args.category)
         else:
             return (False, ["Please specify a category."])
+        catdir = self._set_category(args.category)
         self.logger.debug("ACTIONS: installed; catdir = %s" % catdir)
         installed_keys = []
         try:
@@ -697,7 +699,7 @@ class Actions(ActionBase):
     def _verify(self, args, key, messages=None):
         if messages == None:
             messages = []
-        self.category = args.category
+        self._set_category(args.category)
         filepath, signature  = args.filename, args.signature
         timestamp_path = None
         isurl = success = verified = False
@@ -831,9 +833,9 @@ class Actions(ActionBase):
         else:
             nicks = args.nick
         args.category = 'sign'
+        self._set_category(args.category)
         # load our installed signing keys db
         self.seeds = self.seedhandler.load_category('sign', nicks)
-        self.category = args.category
         if not self.seeds.seeds:
             return (False, ['No installed keys, try installkey action.', ''])
         keydir  = self.config.get_key("sign", "keydir")
@@ -877,7 +879,7 @@ class Actions(ActionBase):
         self.logger.debug(_unicode("ACTIONS: refreshkey; args: %s")
             % _unicode(args))
         seeds = self.seedhandler.load_category(args.category, refresh=True)
-        self.category = args.category
+        self._set_category(args.category)
         results = {}
         kwargs = self.seedhandler.build_gkeydict(args)
         keyresults = seeds.list(**kwargs)


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

commit:     bacec7da1e7ff446f232d48dcf34b71966df7068
Author:     aeroniero33 <justthisthing <AT> gmail <DOT> com>
AuthorDate: Tue Apr 12 23:49:05 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Jun  1 15:13:48 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=bacec7da

Count Incorrect Qualified IDs and present them in the speccheck summary.

Changed the names of Qualified_IDs

Changed Qualified_Id position

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index d61b415..ef8a30e 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -407,6 +407,8 @@ class Actions(ActionBase):
                                 'encrypts': [],
                                 'authens': [],
                                 'final': False,
+                                'qualified_id_checks': [],
+                                'qualified_id_passed': False
                             }
                         if key.key is "SUB":
                             if key.sign_capable and key.passed_spec:
@@ -419,6 +421,9 @@ class Actions(ActionBase):
                                 pub_pass['authens'].append(key.passed_spec)
                                 if key.passed_spec:
                                     pub_pass['auth'] = True
+                        if key.id:
+                            pub_pass['qualified_id_checks'].append(key.id)
+                            pub_pass['qualified_id_passed'] = True
                         validity = key.validity.split(',')[0]
                         if not key.expire and not 'r' in validity:
                             failed['expired'].append(_unicode("%s <%s>: %s")
@@ -446,6 +451,9 @@ class Actions(ActionBase):
                     if not pub_pass['sign']:
                         failed['sign'].append(_unicode("%s <%s>: %s")
                             % (gkey.name, gkey.nick, pub_pass['key'].fingerprint))
+                    if not pub_pass['qualified_id_passed']:
+                        failed['qualified_id'].append(_unicode("%s <%s>: %s")
+                            % (gkey.name, gkey.nick, pub_pass['key'].fingerprint))
                     if not pub_pass['encrypt']:
                         failed['encrypt'].append(_unicode("%s <%s>: %s")
                             % (gkey.name, gkey.nick, pub_pass['key'].fingerprint))
@@ -483,6 +491,8 @@ class Actions(ActionBase):
             self.output([sorted(set(failed['expired']))], '\n Expiry keys:')
         if failed['warn']:
             self.output([sorted(set(failed['warn']))], '\n Expiry Warnings:')
+        if failed['qualified_id']:
+            self.output([sorted(set(failed['qualified_id']))], '\n Qualified IDs:')
         if failed['spec']:
             self.output([sorted(set(failed['spec']))], '\n Failed to pass SPEC requirements:')
         if failed['spec-approved']:
@@ -496,6 +506,7 @@ class Actions(ActionBase):
                 'No Encryption subkey...: %d' % len(set(failed['encrypt'])),
                 'Algorithm..............: %d' % len(set(failed['algo'])),
                 'Bit length.............: %d' % len(set(failed['bits'])),
+                'Qualified IDs..........: %d' % len(set(failed['qualified_id'])),
                 'Expiry.................: %d' % len(set(failed['expired'])),
                 'Expiry Warnings........: %d' % len(set(failed['warn'])),
                 'SPEC requirements......: %d' % len(set(failed['spec'])),
@@ -889,4 +900,3 @@ class Actions(ActionBase):
             msgs.append(keys[cat])
         del keys
         return (True, msgs)
-


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

commit:     423c3bf0b3ae993e15886858aede0a94372b55fd
Author:     aeroniero33 <justthisthing <AT> gmail <DOT> com>
AuthorDate: Fri May 27 13:28:38 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Jun  1 15:14:55 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=423c3bf0

Fixed move-seed function

 gkeys/gkeys/action_map.py  | 4 +---
 gkeys/gkeys/actions.py     | 4 ++--
 gkeys/gkeys/seedhandler.py | 3 ++-
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py
index d7eac63..80c59fe 100644
--- a/gkeys/gkeys/action_map.py
+++ b/gkeys/gkeys/action_map.py
@@ -15,7 +15,7 @@ from collections import OrderedDict
 
 
 Seed_Actions = ['----seeds----', 'add-seed', 'fetch-seed',
-    'list-seed', 'list-seedfiles', 'remove-seed']
+    'list-seed', 'list-seedfiles', 'move-seed', 'remove-seed']
 
 Key_Actions = ['----keys-----', 'check-key', 'installed',
     'install-key', 'list-key', 'refresh-key', 'remove-key',
@@ -430,5 +430,3 @@ Found Failures:
 ''',
         }),
 ])
-
-

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index ef8a30e..1b27605 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -153,10 +153,10 @@ class Actions(ActionBase):
         self.logger.debug(_unicode("ACTIONS: moveseed; gkey: %s")
             % _unicode(searchkey))
         if not self.seeds:
-            self.seeds = self.load_seeds(args.category)
+            self.seeds = self.seedhandler.load_seeds(args.category)
         kwargs = self.seedhandler.build_gkeydict(args)
         sourcekeys = self.seeds.list(**kwargs)
-        dest = self.load_seeds(args.destination)
+        dest = self.seedhandler.load_seeds(args.destination)
         destkeys = dest.list(**kwargs)
         messages = []
         if len(sourcekeys) == 1 and destkeys == []:

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 248b7b6..de2a6ad 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -67,7 +67,8 @@ class SeedHandler(object):
                 else:
                     keyinfo[attr] = value
             except AttributeError:
-                pass
+                if attr in GKEY._fields:
+                    keyinfo[attr] = None
         return keyinfo
 
     def load_seeds(self, seedfile=None, filepath=None, refresh=False):


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2016-01-23 23:33 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2016-01-23 23:33 UTC (permalink / raw
  To: gentoo-commits

commit:     dc793f99c4b68e025bf4415d6162288bcaa971eb
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 23 23:32:31 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 23 23:32:31 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=dc793f99

gkeys: Increase a few logger.error messages to logger.exception

This will include a full traceback for debugging.

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

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index f1bf7db..96bd8b2 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -246,10 +246,10 @@ class Seeds(object):
         '''Class error logging function'''
         if debug:
             self.logger.debug("Seed: Error processing seed file %s" % self.filename)
-            self.logger.debug("Seed: Error was: %s" % str(err))
+            self.logger.exception("Seed: Error was: %s" % str(err))
         else:
             self.logger.error("Seed: Error processing seed file %s" % self.filename)
-            self.logger.error("Seed: Error was: %s" % str(err))
+            self.logger.exception("Seed: Error was: %s" % str(err))
 
 
     def _seeds2json(self, seeds):

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 5c3e8aa..248b7b6 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -137,7 +137,7 @@ class SeedHandler(object):
                         seeds.add(nick, GKEY(**key))
         except OSError as error:
             self.logger.debug("SeedHandler: load_category; OSError for %s" % catdir)
-            self.logger.debug("Error was: %s" % str(error))
+            self.logger.exception("Error was: %s" % str(error))
         self.seeds = seeds
         return seeds
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2016-01-23 23:33 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2016-01-23 23:33 UTC (permalink / raw
  To: gentoo-commits

commit:     fd8b642afb7ec732f2407553788fe49aed27cdec
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 23 23:31:07 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 23 23:31:07 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=fd8b642a

actions.py: Update for ssl-fetch API changes

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index d3e403d..d61b415 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -712,9 +712,15 @@ class Actions(ActionBase):
                  'info': self.logger.info,
                  'debug': self.logger.debug,
                  'error': self.logger.error,
+                 'exception': self.logger.exception,
+                 # we want any warnings to be printed to the terminal
+                 # so assign it to logging.error
+                 'warning': self.logger.error,
                  'kwargs-info': {},
                  'kwargs-debug': {},
                  'kwargs-error': {},
+                 'kwargs-exception': {},
+                 'kwargs-warning': {},
             }
             fetcher = Connector(connector_output, None, "Gentoo Keys")
             self.logger.debug(


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2016-01-23 19:04 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2016-01-23 19:04 UTC (permalink / raw
  To: gentoo-commits

commit:     8843c85e7b579e80db80b327dbbee159746b87e9
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 20 15:58:41 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Jan 20 15:58:41 2016 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=8843c85e

actions.py: Update ssl-fetch Connector call, add climit

Update for an ssl-fetch API change

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 01255eb..d3e403d 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -702,6 +702,9 @@ class Actions(ActionBase):
                     "not supplied, using current directory ./%s") % filepath)
         if args.timestamp:
             timestamp_path = filepath + ".timestamp"
+            climit = 60
+        else:
+            climit = 0
         sig_path = None
         if isurl:
             from sslfetch.connections import Connector
@@ -719,7 +722,7 @@ class Actions(ActionBase):
             self.logger.debug(
                 _unicode("ACTIONS: verify; timestamp path: %s") % timestamp_path)
             success, signedfile, timestamp = fetcher.fetch_file(
-                url, filepath, timestamp_path)
+                url, filepath, timestamp_path, climit=climit)
             if not success:
                 messages.append(_unicode("File %s cannot be retrieved.") % filepath)
             elif '.' + url.rsplit('.', 1)[1] not in EXTENSIONS:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-12-25 17:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-12-25 17:03 UTC (permalink / raw
  To: gentoo-commits

commit:     d30a4c052be16bc01f82c2893ab26114f9ac54a5
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 13 02:22:25 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Dec 13 02:22:25 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=d30a4c05

gkeys/actionbase.py: Add an exception to the raise statements

There were no active exceptions at this point which in itself caused an exception.

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

diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py
index c53bfdb..67d3520 100644
--- a/gkeys/gkeys/actionbase.py
+++ b/gkeys/gkeys/actionbase.py
@@ -81,9 +81,9 @@ class ActionBase(object):
     def _set_category(self, cat):
         keyring = self.config.get_key('keyring')
         if not keyring:
-            raise
+            raise Exception("No keyring set.")
         if not cat:
-            raise
+            raise Exception("No category set.")
         self.category = cat
         catdir = os.path.join(keyring, cat)
         self.logger.debug(_unicode("ACTIONS: _set_category; catdir = %s") % catdir)


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-12-13  0:51 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-12-13  0:51 UTC (permalink / raw
  To: gentoo-commits

commit:     0ea1407c73ade111e1459099be1bf5ebf585b517
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 13 00:48:13 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Dec 13 00:48:13 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=0ea1407c

gkeys/log.py: Remove a couple commented out debug prints

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

diff --git a/gkeys/gkeys/log.py b/gkeys/gkeys/log.py
index f9b7963..4ea5cb1 100644
--- a/gkeys/gkeys/log.py
+++ b/gkeys/gkeys/log.py
@@ -54,10 +54,8 @@ def set_logger(namespace=None, logpath='', level=None,
             '%s-%s.log' % (namespace, time.strftime('%Y%m%d-%H:%M')))
         file_handler = logging.FileHandler(logname)
         if level:
-            #print "Setting cli log level", level, log_levels[level]
             file_handler.setLevel(log_levels[level])
         else:
-            #print "Create file handler which logs even debug messages"
             file_handler.setLevel(log_levels['DEBUG'])
         file_handler.setFormatter(formatter)
         logger.addHandler(file_handler)


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-25 14:10 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-25 14:10 UTC (permalink / raw
  To: gentoo-commits

commit:     1a9629201a102f2a173116a9e9ce368315501c0e
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 25 14:09:09 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Aug 25 14:09:09 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=1a962920

gkeys: Set default verify-keyring, add verify-nick default

Fix verify-keyring typo in verify action.
Add missed self.category setting in verify().

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 69d05b6..01255eb 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -660,7 +660,7 @@ class Actions(ActionBase):
         if not args.filename:
             return (False, ['Please provide a signed file.'])
         if not args.category:
-            args.category = self.config.get_key('verify_keyring')
+            args.category = self.config.get_key('verify-keyring')
             self.logger.debug(_unicode(
                 "ACTIONS: verify; keyring category not specified, using default: %s")
                 % args.category)
@@ -685,6 +685,7 @@ class Actions(ActionBase):
     def _verify(self, args, key, messages=None):
         if messages == None:
             messages = []
+        self.category = args.category
         filepath, signature  = args.filename, args.signature
         timestamp_path = None
         isurl = success = verified = False

diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py
index 592aad6..ee667ec 100644
--- a/gkeys/gkeys/config.py
+++ b/gkeys/gkeys/config.py
@@ -82,7 +82,8 @@ class GKeysConfig(GPGConfig):
             'keyring': None,
             'type': 'clearsign',
         }
-        self.defaults['verify-keyring'] = ''
+        self.defaults['verify-keyring'] = 'gentoo'
+        self.defaults['verify-nick'] = 'gkeys'
         self.defaults['verify-seeds'] = {}
 
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-25 14:10 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-25 14:10 UTC (permalink / raw
  To: gentoo-commits

commit:     54c1719b1701ce9f4b5853b029a2e9bc9412db8e
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 25 14:05:26 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Aug 25 14:05:26 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=54c1719b

actionbase.py: Fix sanity check in _set_category

pyGPG changed, it now returns None for a key/subkey that it fails to find.
Add a cat check as well.

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

diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py
index e8d5ba4..c53bfdb 100644
--- a/gkeys/gkeys/actionbase.py
+++ b/gkeys/gkeys/actionbase.py
@@ -80,7 +80,9 @@ class ActionBase(object):
 
     def _set_category(self, cat):
         keyring = self.config.get_key('keyring')
-        if "foo-bar'd" in keyring:
+        if not keyring:
+            raise
+        if not cat:
             raise
         self.category = cat
         catdir = os.path.join(keyring, cat)


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-09 22:52 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-09 22:52 UTC (permalink / raw
  To: gentoo-commits

commit:     396d5c5afab583fc1873d4a211c856d9df0b8074
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Aug  9 22:29:46 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun Aug  9 22:29:46 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=396d5c5a

gkeys/seedhandler.py: Add an isdir check to load_category

This prevents trying to look into a file like it does a keyring directory.
(I accidentlly added garbage to a keyring using gpg directly)

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

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 3e51bb2..5c3e8aa 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -112,6 +112,8 @@ class SeedHandler(object):
                 nicks = os.listdir(catdir)
             for nick in nicks:
                 seed_path = os.path.join(catdir, nick)
+                if not os.path.isdir(seed_path):
+                    continue
                 gkey_path = os.path.join(seed_path, 'gkey.seeds')
                 seed = None
                 try:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-09  1:09 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-09  1:09 UTC (permalink / raw
  To: gentoo-commits

commit:     24aa5eb9f92883fb0fb3e7222b78eeddf33b9bf6
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 29 06:39:47 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Aug  8 15:51:40 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=24aa5eb9

gkeys/lib.py: Creation of the code for the verify_text()

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

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index 528464b..5ad1aab 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -318,10 +318,19 @@ class GkeysGPG(GPG):
         pass
 
 
-    def verify_text(self, text):
+    def verify_text(self, gkey, text, filepath=None):
         '''Verify a text block in memory
+
+        @param gkey: GKEY instance of the gpg key used to verify it
+        @param text: string of the of the text to verify
+        @param filepath: optional string with the path or url of the signed file
         '''
-        pass
+        self.set_keydir(gkey.keydir, 'verify', fingerprint=False, reset=True)
+        self.logger.debug("** Calling runGPG with Running 'gpg %s --verify %s'"
+                % (' '.join(self.config['tasks']['verify']), filepath))
+        results = self.runGPG(task='verify', inputfile=filepath, inputtxt=text)
+        self._log_result('verification', gkey, results)
+        return results
 
 
     def verify_file(self, gkey, signature, filepath):


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-09  1:09 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-09  1:09 UTC (permalink / raw
  To: gentoo-commits

commit:     3fd82a0c97b291da10ca116fb80f24c0d3bcef90
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 29 05:59:39 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Aug  3 03:59:36 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=3fd82a0c

gkeys/lib.py: Split out _log_result()

Split out common code to be used for all veritf_* functions.

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

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index bce4e55..838ebf0 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -338,14 +338,7 @@ class GkeysGPG(GPG):
             self.logger.debug("** Calling runGPG with Running 'gpg %s --decrypt %s'"
                     % (' '.join(self.config['tasks']['decrypt']), filepath))
             results = self.runGPG(task='decrypt', inputfile=filepath)
-        keyid = gkey.keyid[0]
-        if results.verified[0]:
-            self.logger.info("GPG verification succeeded. Name: %s / Key: %s" % (gkey.name, keyid))
-            self.logger.info("\tSignature result:" + str(results.verified))
-        else:
-            self.logger.debug("GPG verification failed. Name: %s / Key: %s" % (gkey.name, keyid))
-            self.logger.debug("\t Signature result:"+ str(results.verified))
-            self.logger.debug("LIB: verify; stderr_out:" + str(results.stderr_out))
+        self._log_result('verification', gkey, results)
         return results
 
 
@@ -369,12 +362,20 @@ class GkeysGPG(GPG):
         self.logger.debug("** Calling runGPG with Running 'gpg %s --%s %s %s'"
                 % (' '.join(self.config['tasks'][mode]), mode, fingerprint, filepath))
         results = self.runGPG(task=mode, inputfile=filepath)
+        self._log_result('signing', gkey, results)
+        return results
+
 
+    def _log_result(self, mode, gkey, results):
         if results.verified[0]:
-            self.logger.info("GPG signing succeeded. Name: %s / Key: %s" % (str(gkey.name), str(keyid)))
+            self.logger.info("GPG %s succeeded. Name: %s / Key: %s"
+                % (mode, gkey.name, gkey.keyid[0]))
             self.logger.info("\tSignature result:" + str(results.verified))
         else:
-            self.logger.debug("GPG signing failed. Name: %s / Key: %s" % (str(gkey.name), str(keyid)))
+            self.logger.debug("GPG %s failed. Name: %s / Key: %s"
+                % (mode, gkey.name, gkey.keyid[0]))
             self.logger.debug("\t Signature result:"+ str(results.verified))
-            self.logger.debug("LIB: sign; stderr_out:" + str(results.stderr_out))
-        return results
+            self.logger.debug("LIB: verify; stderr_out:" +
+                str(results.stderr_out))
+
+


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-09  1:09 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-09  1:09 UTC (permalink / raw
  To: gentoo-commits

commit:     4aac84d4a8e95d1cac079036a61c2f61df4a7608
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 29 06:55:37 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Aug  8 15:51:39 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=4aac84d4

gkeys: Update copyrights, Add Pavlos to several files

 gkeys/gkeys/actions.py     | 3 ++-
 gkeys/gkeys/base.py        | 2 +-
 gkeys/gkeys/checks.py      | 3 ++-
 gkeys/gkeys/cli.py         | 2 +-
 gkeys/gkeys/lib.py         | 7 ++++---
 gkeys/gkeys/seed.py        | 8 +++++---
 gkeys/gkeys/seedhandler.py | 3 ++-
 7 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index a4081c9..e24d24d 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -6,7 +6,8 @@
 
     Primary api interface module
 
-    @copyright: 2012 by Brian Dolbec <dol-sen@gentoo.org>
+    @copyright: 2012-2015 by Brian Dolbec <dol-sen@gentoo.org>
+    @copyright: 2014-2015 by Pavlos Ratis <dastergon@gentoo.org>
     @license: GNU GPL2, see COPYING for details.
 """
 

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 7253b7b..4cee27d 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -7,7 +7,7 @@
     Command line interface argsparse options module
     and common functions
 
-    @copyright: 2012 by Brian Dolbec <dol-sen@gentoo.org>
+    @copyright: 2012-2015 by Brian Dolbec <dol-sen@gentoo.org>
     @license: GNU GPL2, see COPYING for details.
 """
 

diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py
index 7e40720..7610d70 100644
--- a/gkeys/gkeys/checks.py
+++ b/gkeys/gkeys/checks.py
@@ -5,7 +5,8 @@
     Gentoo-Keys - gkeygen/checks.py
 
     Primary key checks module
-    @copyright: 2014 by Brian Dolbec <dolsen@gentoo.org>
+    @copyright: 2014-2015 by Brian Dolbec <dolsen@gentoo.org>
+    @copyright: 2014-2015 by Pavlos Ratis <dastergon@gentoo.org>
     @license: GNU GPL2, see COPYING for details
 """
 

diff --git a/gkeys/gkeys/cli.py b/gkeys/gkeys/cli.py
index 194afd2..532c03e 100644
--- a/gkeys/gkeys/cli.py
+++ b/gkeys/gkeys/cli.py
@@ -6,7 +6,7 @@
 
     Command line interface module
 
-    @copyright: 2012 by Brian Dolbec <dol-sen@gentoo.org>
+    @copyright: 2012-2015 by Brian Dolbec <dol-sen@gentoo.org>
     @license: GNU GPL2, see COPYING for details.
 """
 

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index 96a57f2..528464b 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -8,11 +8,12 @@ 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
+    @copyright: 2011-2015 by Brian Dolbec <dol-sen@gentoo.org>
+    @copyright: 2014-2015 by Pavlos Ratis <dastergon@gentoo.org>
+    Distributed under the terms of the GNU General Public License v2
 
  Author(s):
-             Brian Dolbec <dolsen@gentoo.org>
+    Brian Dolbec <dolsen@gentoo.org>
 
 '''
 

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index 01ca5a5..f1bf7db 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -8,11 +8,13 @@ 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
+    @copyright: 2011-2015 by Brian Dolbec <dol-sen@gentoo.org>
+    @copyright: 2014-2015 by Pavlos Ratis <dastergon@gentoo.org>
+    Distributed under the terms of the GNU General Public License v2
 
  Author(s):
-             Brian Dolbec <dolsen@gentoo.org>
+    Brian Dolbec <dolsen@gentoo.org>
+    Pavlos Ratis <dastergon@gentoo.org>
 
 '''
 

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 01abf78..3e51bb2 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -6,7 +6,8 @@
 
     Seed handling interface module
 
-    @copyright: 2012 by Brian Dolbec <dol-sen@gentoo.org>
+    @copyright: 2012-2015 by Brian Dolbec <dol-sen@gentoo.org>
+    @copyright: 2014-2015 by Pavlos Ratis <dastergon@gentoo.org>
     @license: GNU GPL2, see COPYING for details.
 """
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-09  1:09 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-09  1:09 UTC (permalink / raw
  To: gentoo-commits

commit:     7f42bd9d867372b75b4e1657ebc6552e9ef062e1
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 25 20:55:18 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Aug  3 03:59:35 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=7f42bd9d

gkeys/actions.py: Fix a traceback when a filename does not have an extension

This will instead get the filename itself back.

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 6610480..a4081c9 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -779,7 +779,7 @@ class Actions(object):
                 _unicode("ACTIONS: verify; local file %s") % filepath)
             success = os.path.isfile(filepath)
             if (not signature
-                and '.' + filepath.rsplit('.', 1)[1] not in EXTENSIONS):
+                and '.' + filepath.rsplit('.', 1)[-1] not in EXTENSIONS):
                 success_fetch = False
                 for ext in EXTENSIONS:
                     sig_path = filepath + ext


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-09  1:09 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-09  1:09 UTC (permalink / raw
  To: gentoo-commits

commit:     534fac884f2ce1a45cf6a73d0491884e1bfe0d0a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 25 20:56:30 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Aug  3 03:59:36 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=534fac88

gkeys/base.py: Add missing action and timestamp attributes

Sort the staus attribute.

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

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index b422caf..7fd9908 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -34,7 +34,7 @@ class Args(object):
 
 
     def __init__(self):
-        self.status = False
+        self.ation = None
         self.all = False
         self.category = None
         self.cleankey = False
@@ -50,6 +50,8 @@ class Args(object):
         self.keydir = None
         self.seedfile = None
         self.signature = None
+        self.status = False
+        self.timestamp = None
         self.uid = None
 
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-09  1:09 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-09  1:09 UTC (permalink / raw
  To: gentoo-commits

commit:     c8aaf3c1f7137f10bba74308d4067b3584a59985
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 29 06:57:56 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Aug  3 04:00:55 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c8aaf3c1

gkeys/lib.py: Whitespace cleanup, remove an unused variable assignment

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

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index 838ebf0..96a57f2 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -20,6 +20,7 @@ with gentoo-keys specific convienience functions.
 from __future__ import print_function
 
 import os
+
 from os.path import abspath, pardir
 from os.path import join as pjoin
 from shutil import rmtree
@@ -29,6 +30,7 @@ from gkeys.checks import KeyChecks
 from gkeys.fileops import ensure_dirs
 from gkeys.seed import Seeds
 
+
 class GkeysGPG(GPG):
     '''Gentoo-keys primary gpg class'''
 
@@ -357,7 +359,6 @@ class GkeysGPG(GPG):
         @param fingerprint: string of the fingerprint to sign with
         @param filepath: string with the path of the file to sign
         '''
-        keyid = gkey.keyid[0]
         self.set_keydir(gkey.keydir, mode, reset=True)
         self.logger.debug("** Calling runGPG with Running 'gpg %s --%s %s %s'"
                 % (' '.join(self.config['tasks'][mode]), mode, fingerprint, filepath))


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-09  1:09 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-09  1:09 UTC (permalink / raw
  To: gentoo-commits

commit:     fd5717c14ae65678f268ac9802d597b237f43a3a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 29 06:06:18 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Aug  8 15:51:39 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=fd5717c1

gkeys/base.py: Fix typo in action initialization

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

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 970ad7c..7253b7b 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -34,7 +34,7 @@ class Args(object):
 
 
     def __init__(self):
-        self.ation = None
+        self.action = None
         self.all = False
         self.category = None
         self.cleankey = False


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-09  1:09 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-09  1:09 UTC (permalink / raw
  To: gentoo-commits

commit:     9e7539d68b75a37626cc4a2b6c59a8d21208b57c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 29 06:35:53 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Aug  8 15:51:40 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=9e7539d6

gkeys: [2 of 2] Move common key handling to it's own class

Creation of a new KeyHandler class.
Move primary seed handling intialization and control to the new KeyHandler class.
This unifies key handling and removes suplicated code throughout Actions class.
Break out a KEY_OPTIONS list. Cleans up a long line and makes it available for
import use to ensure the correct options are added to the cli (gkeys-gpg) for
correct key_search() operation.

 gkeys/gkeys/actions.py    | 156 +++++++++++-----------------------------------
 gkeys/gkeys/keyhandler.py | 110 ++++++++++++++++++++++++++++++++
 2 files changed, 148 insertions(+), 118 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 11f1ca8..69d05b6 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -26,18 +26,17 @@ else:
 
 from collections import defaultdict
 
-from snakeoil.demandload import demandload
 from gkeys.actionbase import ActionBase
 from gkeys.gkey import GKEY
 from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn
 
+from snakeoil.demandload import demandload
+
 demandload(
+    "gkeys.base:Args",
     "json:load",
-    "gkeys.lib:GkeysGPG",
-    "gkeys.seedhandler:SeedHandler",
 )
 
-
 EXTENSIONS = ['.sig', '.asc', '.gpg','.gpgsig']
 
 
@@ -67,13 +66,12 @@ class Actions(ActionBase):
 
     def listseed(self, args):
         '''Pretty-print the selected seed file'''
-        handler = SeedHandler(self.logger, self.config)
-        kwargs = handler.build_gkeydict(args)
+        kwargs = self.seedhandler.build_gkeydict(args)
         self.logger.debug(_unicode("ACTIONS: listseed; kwargs: %s")
             % _unicode(kwargs))
         if not self.seeds:
             try:
-                self.seeds = handler.load_seeds(args.category, args.nick)
+                self.seeds = self.seedhandler.load_seeds(args.category, args.nick)
             except ValueError:
                 return (False, ['', "Failed to load seed file. Consider fetching seedfiles."])
         if self.seeds:
@@ -89,8 +87,10 @@ class Actions(ActionBase):
             % _unicode(args))
         if not args.category:
             return (False, ["Please specify seeds category."])
-        handler = SeedHandler(self.logger, self.config)
-        success, messages = handler.fetch_seeds(args.category, args, self.verify)
+        self._set_category(self.config.get_key('verify-keyring'))
+        verifyargs = Args()
+        verifyargs.category=args.category
+        success, messages = self.seedhandler.fetch_seeds(args.category, verifyargs, self.verify)
         messages.append("")
         messages.append("Fetch operation completed")
         return (False not in success, messages)
@@ -98,7 +98,6 @@ class Actions(ActionBase):
 
     def addseed(self, args):
         '''Add or replace a key in the selected seed file'''
-        handler = SeedHandler(self.logger, self.config)
         success, data = self.listseed(args)
         gkeys = data[1]
         if not args.nick or not args.name or not args.keys or not args.keydir:
@@ -107,7 +106,7 @@ class Actions(ActionBase):
             args.fingerprint = args.keys
         if args.uid is None:
             args.uid = []
-        gkey = handler.new(args, checkgkey=True)
+        gkey = self.seedhandler.new(args, checkgkey=True)
         if not gkey:
             return (False, ["Failed to create a valid GKEY instance.",
                 "Check for invalid data entries"])
@@ -150,13 +149,12 @@ class Actions(ActionBase):
 
     def moveseed(self, args):
         '''Move keys between seed files'''
-        handler = SeedHandler(self.logger, self.config)
-        searchkey = handler.new(args, checkgkey=False)
+        searchkey = self.seedhandler.new(args, checkgkey=False)
         self.logger.debug(_unicode("ACTIONS: moveseed; gkey: %s")
             % _unicode(searchkey))
         if not self.seeds:
             self.seeds = self.load_seeds(args.category)
-        kwargs = handler.build_gkeydict(args)
+        kwargs = self.seedhandler.build_gkeydict(args)
         sourcekeys = self.seeds.list(**kwargs)
         dest = self.load_seeds(args.destination)
         destkeys = dest.list(**kwargs)
@@ -199,21 +197,17 @@ class Actions(ActionBase):
         # fill in code here
         if not args.category:
             args.category = 'gentoo'
-        keyring = self.config.get_key('keyring')
-        catdir = os.path.join(keyring, args.category)
-        self.logger.debug(_unicode("ACTIONS: listkey; catdir = %s") % catdir)
-        self.gpg = GkeysGPG(self.config, catdir, self.logger)
-        handler = SeedHandler(self.logger, self.config)
+        self.category = args.category
         if args.keydir:
             self.gpg.set_keydir(args.keydir, "list-keys")
             self.gpg.set_keyseedfile()
             seeds = self.gpg.seedfile
         else:
-            seeds = handler.load_category(args.category)
+            seeds = self.seedhandler.load_category(args.category)
         results = {}
         success = []
         messages = []
-        kwargs = handler.build_gkeydict(args)
+        kwargs = self.seedhandler.build_gkeydict(args)
         keyresults = seeds.list(**kwargs)
         for key in sorted(keyresults):
             if args.fingerprint:
@@ -272,11 +266,7 @@ class Actions(ActionBase):
                     return (False, ["Search failed for search term"])
             # get confirmation
             # fill in code here
-            keyring = self.config.get_key('keyring')
-            catdir = os.path.join(keyring, args.category)
-            self.logger.debug(_unicode("ACTIONS: installkey; catdir = %s")
-                % catdir)
-            self.gpg = GkeysGPG(self.config, catdir, self.logger)
+            self.category = args.category
             for gkey in gkeys:
                 self.gpg.set_keydir(gkey.keydir, "recv-keys")
                 self.gpg.set_keyseedfile()
@@ -333,15 +323,11 @@ class Actions(ActionBase):
         if not args.category:
             return (False, [_unicode("Please specify seeds category.")])
         self.logger.debug(_unicode("ACTIONS: checkkey; args: %s") % _unicode(args))
-        handler = SeedHandler(self.logger, self.config)
-        seeds = handler.load_category(args.category)
-        keyring = self.config.get_key('keyring')
-        catdir = os.path.join(keyring, args.category)
-        self.logger.debug(_unicode("ACTIONS: checkkey; catdir = %s") % catdir)
-        self.gpg = GkeysGPG(self.config, catdir, self.logger)
+        seeds = self.seedhandler.load_category(args.category)
+        self.category = args.category
         results = {}
         failed = defaultdict(list)
-        kwargs = handler.build_gkeydict(args)
+        kwargs = self.seedhandler.build_gkeydict(args)
         keyresults = seeds.list(**kwargs)
         self.output('', '\n Checking keys...')
         for gkey in sorted(keyresults):
@@ -388,16 +374,11 @@ class Actions(ActionBase):
             return (False, ["Please specify seeds category."])
         self.logger.debug(_unicode("ACTIONS: speccheck; args: %s")
             % _unicode(args))
-        handler = SeedHandler(self.logger, self.config)
-        seeds = handler.load_category(args.category)
-        keyring = self.config.get_key('keyring')
-        catdir = os.path.join(keyring, args.category)
+        self.category = args.category
+        catdir, keyresults = self.keyhandler.determine_keys(args)
         self.logger.debug(_unicode("ACTIONS: speccheck; catdir = %s") % catdir)
-        self.gpg = GkeysGPG(self.config, catdir, self.logger)
         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(_unicode("Checking key %s, %s")
@@ -527,11 +508,10 @@ class Actions(ActionBase):
         '''Remove an installed key'''
         if not args.nick:
             return (False, ["Please provide a nickname or -n *"])
-        handler = SeedHandler(self.logger, self.config)
-        kwargs = handler.build_gkeydict(args)
+        kwargs = self.seedhandler.build_gkeydict(args)
         self.logger.debug(_unicode("ACTIONS: removekey; kwargs: %s")
             % _unicode(kwargs))
-        seeds = handler.load_category(args.category)
+        seeds = self.seedhandler.load_category(args.category)
         messages = []
         if args.nick == '*':
             self.output([''],_unicode('Remove All keys in category: %s')
@@ -565,11 +545,6 @@ class Actions(ActionBase):
                 if ans in ["no", "n"]:
                     messages.append("Key removal aborted... Nothing to be done.")
                 else:
-                    keyring = self.config.get_key('keyring')
-                    catdir = os.path.join(keyring, args.category)
-                    self.logger.debug(_unicode("ACTIONS: removekey; catdir = %s")
-                        % catdir)
-                    self.gpg = GkeysGPG(self.config, catdir, self.logger)
                     if len(gkey.keys) == 1 or args.keys == gkey.keys:
                         success, msgs = self.gpg.del_keydir(gkey)
                         messages.extend(msgs)
@@ -592,11 +567,7 @@ class Actions(ActionBase):
     def importkey(self, args):
         '''Add a specified key to a specified keyring'''
         if args.category:
-            keyring = self.config.get_key('keyring')
-            catdir = os.path.join(keyring, args.category)
-            self.logger.debug(_unicode("ACTIONS: importkey; catdir = %s")
-                % catdir)
-            self.gpg = GkeysGPG(self.config, catdir, self.logger)
+            catdir = self._set_category(args.category)
             success, data = self.listseed(args)
             gkeys = data[1]
             results = {}
@@ -693,11 +664,10 @@ class Actions(ActionBase):
             self.logger.debug(_unicode(
                 "ACTIONS: verify; keyring category not specified, using default: %s")
                 % args.category)
-        handler = SeedHandler(self.logger, self.config)
-        keys = handler.load_category(args.category)
+        keys = self.seedhandler.load_category(args.category)
         if not keys:
             return (False, ['No installed keys found, try installkey action.'])
-        key = handler.seeds.nick_search(args.nick)
+        key = self.seedhandler.seeds.nick_search(args.nick)
         if not key:
             if args.nick:
                 messages.append(_unicode(
@@ -709,14 +679,10 @@ class Actions(ActionBase):
                 % (args.category, args.nick))
             return self.verify(args, messages)
 
-        keyrings = self.config.get_key('keyring')
-        catdir = os.path.join(keyrings, args.category)
-        self.logger.debug(_unicode("ACTIONS: verify; catdir = %s") % catdir)
-        self.gpg = GkeysGPG(self.config, catdir, self.logger)
-        return self._verify(args, handler, key, messages)
+        return self._verify(args, key, messages)
 
 
-    def _verify(self, args, handler, key, messages=None):
+    def _verify(self, args, key, messages=None):
         if messages == None:
             messages = []
         filepath, signature  = args.filename, args.signature
@@ -807,25 +773,10 @@ class Actions(ActionBase):
                 [_unicode("Verification failed....: %s") % (filepath),
                 _unicode("Key info...............: %s <%s>, %s")
                 % ( key.name, key.nick, keyid)])
-            has_no_pubkey, s_keyid = results.no_pubkey
-            if has_no_pubkey:
-                messages.append(
-                    _unicode("Auto-searching for key.: 0x%s") % s_keyid)
-                # reset all but keyid and pass thru data
-                args.keyid = s_keyid
-                args.keydir = None
-                args.fingerprint = None
-                args.exact = False
-                args.category = None
-                args.nick = None
-                args.name = None
-                args.all = False
-                keys = self.key_search(args, data_only=True)
-                if keys:
-                    args.category = list(keys)[0]
-                    args.nick = keys[args.category][0].nick
-                    return self.verify(args, messages)
-                messages.append(_unicode("Failed to find gpg key.: 0x%s") % s_keyid)
+            found, args, new_msgs = self.keyhandler.autosearch_key(args, results)
+            messages.extend(new_msgs)
+            if found:
+                return self.verify(args, messages)
         return (verified, messages)
 
 
@@ -856,11 +807,9 @@ class Actions(ActionBase):
         else:
             nicks = args.nick
         # load our installed signing keys db
-        handler = SeedHandler(self.logger, self.config)
-        self.seeds = handler.load_category('sign', nicks)
+        self.seeds = self.seedhandler.load_category('sign', nicks)
         if not self.seeds.seeds:
             return (False, ['No installed keys, try installkey action.', ''])
-        basedir = self.config.get_key("sign-keydir")
         keydir  = self.config.get_key("sign", "keydir")
         task = self.config.get_key("sign", "type")
         keyring = self.config.get_key("sign", "keyring")
@@ -869,7 +818,6 @@ class Actions(ActionBase):
 
         self.logger.debug(_unicode("ACTIONS: sign; keydir = %s") % keydir)
 
-        self.gpg = GkeysGPG(self.config, basedir, self.logger)
         self.gpg.set_keydir(keydir, task)
         if keyring not in ['', None]:
             self.gpg.set_keyring(keyring, task)
@@ -902,14 +850,10 @@ class Actions(ActionBase):
             return (False, ["Please specify seeds type."])
         self.logger.debug(_unicode("ACTIONS: refreshkey; args: %s")
             % _unicode(args))
-        handler = SeedHandler(self.logger, self.config)
-        seeds = handler.load_category(args.category, refresh=True)
-        keyring = self.config.get_key('keyring')
-        catdir = os.path.join(keyring, args.category)
-        self.logger.debug(_unicode("ACTIONS: refreshkey; catdir = %s") % catdir)
-        self.gpg = GkeysGPG(self.config, catdir, self.logger)
+        seeds = self.seedhandler.load_category(args.category, refresh=True)
+        self.category = args.category
         results = {}
-        kwargs = handler.build_gkeydict(args)
+        kwargs = self.seedhandler.build_gkeydict(args)
         keyresults = seeds.list(**kwargs)
         self.output('', '\n Refreshig keys...')
         for gkey in sorted(keyresults):
@@ -926,37 +870,13 @@ class Actions(ActionBase):
 
     def key_search(self, args, data_only=False):
         '''Search for a key's seed in the installed keys db'''
-        handler = SeedHandler(self.logger, self.config)
-        results = {}
-        search_args = [x for x in
-            ['nick', 'name', 'keydir', 'fingerprint', 'keyid', 'uid']
-            if getattr(args, x)]
-        if args.category:
-            handler.load_category(args.category)
-            results[args.category] = handler.key_search(args, search_args)
-        else:
-            for cat in list(self.config.get_key('seeds')):
-                handler.load_category(cat)
-                found = handler.key_search(args, search_args)
-                if found:
-                    if cat in results:
-                        results[cat].extend(found)
-                    else:
-                        results[cat] = found
-        keys = {}
-        for cat in results:
-            keys[cat] = []
-            for result in results[cat]:
-                if result and result.nick not in keys[cat]:
-                    if isinstance(result, GKEY):
-                        keys[cat].append(result)
+        keys = self.keyhandler.key_search(args)
         if data_only:
-            del found, cat, handler
             return keys
         msgs = []
         for cat in list(keys):
             msgs.append(_unicode("Category.....: %s") % cat)
             msgs.append(keys[cat])
-        del keys, cat
+        del keys
         return (True, msgs)
 

diff --git a/gkeys/gkeys/keyhandler.py b/gkeys/gkeys/keyhandler.py
new file mode 100644
index 0000000..9043fcd
--- /dev/null
+++ b/gkeys/gkeys/keyhandler.py
@@ -0,0 +1,110 @@
+#
+#-*- coding:utf-8 -*-
+
+"""
+    Gentoo-keys - keyhandler.py
+
+    GKEY handling interface module
+
+    @copyright: 2015 by Brian Dolbec <dol-sen@gentoo.org>
+    @license: GNU GPL2, see COPYING for details.
+"""
+import os
+import sys
+
+from snakeoil.demandload import demandload
+
+if sys.version_info[0] >= 3:
+    _unicode = str
+else:
+    _unicode = unicode
+
+from  gkeys.gkey import GKEY
+
+
+demandload(
+    "gkeys.seedhandler:SeedHandler",
+)
+
+KEY_OPTIONS = ['nick', 'name', 'keydir', 'fingerprint', 'keyid', 'uid']
+
+
+class KeyHandler(object):
+    '''Class to hold various key operations'''
+
+
+    def __init__(self, config, logger):
+        self.config = config
+        self.logger = logger
+        self._seedhandler = None
+
+
+    @property
+    def seedhandler(self):
+        if not self._seedhandler:
+            self._seedhandler = SeedHandler(self.logger, self.config)
+        return self._seedhandler
+
+
+    def autosearch_key(self, args, results):
+        '''Search for the correct keyid from the GPGResult'''
+        messages = []
+        has_no_pubkey, s_keyid = results.no_pubkey
+        if has_no_pubkey:
+            messages.append(
+                _unicode("Auto-searching for key.: 0x%s") % s_keyid)
+            # reset all but keyid and pass thru data
+            args.keyid = s_keyid
+            args.keydir = None
+            args.fingerprint = None
+            args.exact = False
+            args.category = None
+            args.nick = None
+            args.name = None
+            args.all = False
+            keys = self.key_search(args)
+            if keys:
+                args.category = list(keys)[0]
+                args.nick = keys[args.category][0].nick
+                return (True, args, messages)
+            messages.append(_unicode("Failed to find gpg key.: 0x%s") % s_keyid)
+        return (False, args, messages)
+
+
+    def determine_keys(self, args, default_cat=None):
+        seeds = self.seedhandler.load_category(args.category or default_cat)
+        keyring = self.config.get_key('keyring')
+        catdir = os.path.join(keyring, args.category)
+        self.logger.debug(_unicode("KeyHandler: determine_keys; catdir = %s") % catdir)
+        kwargs = self.seedhandler.build_gkeydict(args)
+        return (catdir, seeds.list(**kwargs))
+
+
+    def key_search(self, args, first_match=False):
+        '''Search for a key's seed in the installed keys db'''
+        results = {}
+        search_args = [x for x in KEY_OPTIONS if getattr(args, x)]
+        if args.category:
+            self.seedhandler.load_category(args.category)
+            results[args.category] = self.seedhandler.key_search(args, search_args)
+        else:
+            for cat in sorted(self.config.get_key('seeds')):
+                self.seedhandler.load_category(cat)
+                found = self.seedhandler.key_search(args, search_args)
+                if found:
+                    if cat in results:
+                        results[cat].extend(found)
+                    else:
+                        results[cat] = found
+                    if first_match:
+                        break
+        keys = {}
+        for cat in results:
+            keys[cat] = []
+            for result in results[cat]:
+                if result and result.nick not in keys[cat]:
+                    if isinstance(result, GKEY):
+                        keys[cat].append(result)
+
+        self.logger.debug(_unicode("KeyHandler: key_search; keys = %s") % str(keys))
+        return keys


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-09  1:09 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-09  1:09 UTC (permalink / raw
  To: gentoo-commits

commit:     918a9e0e3375b394979dc13c95176f9e333a5c7a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 29 06:03:23 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Aug  8 15:51:15 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=918a9e0e

gkeys/seedhandler.py: Add an addtional debug log message

Re-arrange the sorting of search_args for a better debug message.

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

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 18725b9..01abf78 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -223,10 +223,11 @@ class SeedHandler(object):
 
     def key_search(self, args, search_args):
         '''Performs a search for all listed args in the seeds'''
-        results = []
+        search_args.sort()
         self.logger.debug("SeedHandler.key_search() search_args: %s" % str(search_args))
+        self.logger.debug("SeedHandler.key_search() search_args values: %s" % str(args))
+        results = []
         found = {}
-        search_args.sort()
         if isinstance(args, dict):
             exact = args.get('exact', False)
             _all = args.get('all', False)


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-09  1:09 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-09  1:09 UTC (permalink / raw
  To: gentoo-commits

commit:     317de4981cc9208f5ff4595f048fb17f522283f6
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 29 06:18:41 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Aug  8 15:51:40 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=317de498

gkeys: [1 of 2] Creation of a new ActionBase class

This class is to hold non-action functions/methods
Restructure external handlers.
Creation of @property decorated keyhandler, seedhandler, gpg functions to
initialize and return.the classwide instances of their code.

 gkeys/gkeys/actionbase.py | 90 +++++++++++++++++++++++++++++++++++++++++++++++
 gkeys/gkeys/actions.py    | 10 ++----
 2 files changed, 93 insertions(+), 7 deletions(-)

diff --git a/gkeys/gkeys/actionbase.py b/gkeys/gkeys/actionbase.py
new file mode 100644
index 0000000..77748c5
--- /dev/null
+++ b/gkeys/gkeys/actionbase.py
@@ -0,0 +1,90 @@
+#
+#-*- coding:utf-8 -*-
+
+"""
+    Gentoo-keys - actionbase.py
+
+    Base api interface module
+
+    @copyright: 2012-2015 by Brian Dolbec <dol-sen@gentoo.org>
+    @license: GNU GPL2, see COPYING for details.
+"""
+
+from __future__ import print_function
+
+import os
+import sys
+
+if sys.version_info[0] >= 3:
+    _unicode = str
+else:
+    _unicode = unicode
+
+
+from snakeoil.demandload import demandload
+
+demandload(
+    "json:load",
+    "gkeys.lib:GkeysGPG",
+    "gkeys.keyhandler:KeyHandler",
+)
+
+
+
+class ActionBase(object):
+    '''Base actions class holding comon functions and init'''
+
+    def __init__(self, config, output=None, logger=None):
+        self.config = config
+        self.output = output
+        self.logger = logger
+        self.seeds = None
+        self._seedhandler = None
+        self._keyhandler = None
+        self._gpg = None
+        self.category = None
+
+
+    @property
+    def gpg(self):
+        '''Holds the classwide GkeysGPG instance'''
+        if not self._gpg:
+            self._gpg = GkeysGPG(self.config,
+                self._set_category(self.category), self.logger)
+        else:
+            self._gpg.basedir = self._set_category(self.category)
+        return self._gpg
+
+
+    @property
+    def keyhandler(self):
+        '''Holds the classwide KeyHandler instance'''
+        if not self._keyhandler:
+            self._init_keyhandler()
+        return self._keyhandler
+
+
+    def _init_keyhandler(self):
+        self._keyhandler = KeyHandler(self.config, self.logger)
+        self._seedhandler = self._keyhandler.seedhandler
+
+
+    @property
+    def seedhandler(self):
+        '''Holds the classwide SeedHandler instance
+        which is a convienience variable for the keyhandler's instance of it'''
+        if not self._seedhandler:
+            self._init_keyhandler()
+        return self._seedhandler
+
+
+    def _set_category(self, cat):
+        keyring = self.config.get_key('keyring')
+        if "foo-bar'd" in keyring:
+            raise
+        self.category = cat
+        catdir = os.path.join(keyring, cat)
+        self.logger.debug(_unicode("ACTIONS: _set_category; catdir = %s") % catdir)
+        return catdir
+
+

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index e24d24d..11f1ca8 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -27,7 +27,7 @@ else:
 from collections import defaultdict
 
 from snakeoil.demandload import demandload
-
+from gkeys.actionbase import ActionBase
 from gkeys.gkey import GKEY
 from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn
 
@@ -41,14 +41,11 @@ demandload(
 EXTENSIONS = ['.sig', '.asc', '.gpg','.gpgsig']
 
 
-class Actions(object):
+class Actions(ActionBase):
     '''Primary API actions'''
 
     def __init__(self, config, output=None, logger=None):
-        self.config = config
-        self.output = output
-        self.logger = logger
-        self.seeds = None
+        ActionBase.__init__(self, config, output, logger)
 
 
     @staticmethod
@@ -68,7 +65,6 @@ class Actions(object):
         '''-----< general actions >------'''
         pass
 
-
     def listseed(self, args):
         '''Pretty-print the selected seed file'''
         handler = SeedHandler(self.logger, self.config)


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-08-09  1:09 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-08-09  1:09 UTC (permalink / raw
  To: gentoo-commits

commit:     79b95d1d05ed9ce82b94167074b068e63cfa2cb8
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 29 04:39:37 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Aug  3 03:59:36 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=79b95d1d

gkeys: Fix the user config location and operation

Move the config to ~/.config/gkeys/ along with the logs.
Fix the improper ensure_dirs() call in base.py.

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

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 7fd9908..970ad7c 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -299,8 +299,8 @@ class CliBase(object):
         if not self.config.defaults['homedir']:
             self.config.defaults['homedir'] = os.path.expanduser('~')
         if not os.access(self.config['logdir'], os.W_OK):
-            self.config['logdir'] = ensure_dirs(
-                os.path.join(self.config['user-dir'], 'logs'))
+            self.config.options['logdir'] = os.path.join(self.config['userconfigdir'], 'logs')
+            ensure_dirs(self.config.options['logdir'])
         # establish our logger and update it in the imported files
         self.logger = set_logger(self.cli_config['prog'], self.config['logdir'], args.debug,
             dirmode=int(self.config.get_key('permissions', 'directories'),0),
@@ -314,6 +314,7 @@ class CliBase(object):
         if args.config:
             self.logger.debug("Main: run; Found alternate config request: %s"
                 % args.config)
+        self.logger.debug("Main: run; Using config: %s" % self.config['config'])
 
         # check if a -C, --category was input
         # if it was, check if the category is listed in the [seeds]

diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py
index 7cd856a..592aad6 100644
--- a/gkeys/gkeys/config.py
+++ b/gkeys/gkeys/config.py
@@ -54,10 +54,11 @@ class GKeysConfig(GPGConfig):
 
     def _set_default_config(self):
             self.defaults['homedir'] = os.path.expanduser('~')
-            self.defaults['configdir'] = os.path.join(
-                self.defaults['homedir'], '.gkeys')
+            self.defaults['userconfigdir'] = os.path.join(
+                self.defaults['homedir'], '.config', 'gkeys')
+            self.defaults['configdir'] = self.defaults['userconfigdir']
             self.defaults['config']= os.path.join(
-                self.defaults['configdir'], 'gkeys.conf')
+                self.defaults['userconfigdir'], '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'
@@ -101,6 +102,9 @@ class GKeysConfig(GPGConfig):
             defaults[key] = self.defaults[key]
         if filename == None:
             filename = self.defaults['config']
+        if "foo-bar'd" in filename:
+            print("Config: read_config(); Configuration ERROR: filename: %s, access: %s"
+                % (filename, os.access(filename, os.R_OK)))
         self.configparser = SaneConfigParser(defaults)
         self.configparser.read(filename)
         if self.configparser.has_section('base'):


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-07-25 16:45 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-07-25 16:45 UTC (permalink / raw
  To: gentoo-commits

commit:     734aed55964979017863639edfc9ca9036a629c0
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 23 15:40:21 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul 25 16:43:13 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=734aed55

gkeys/base.py: Add an alternate args class for compatibility use for Action as an API

Rough draft, so it can be used for the args arguments in Actions functions.
An alternate to having an argsparser innstance.

 gkeys/gkeys/base.py | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index fba1976..b422caf 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -26,6 +26,33 @@ if sys.version_info[0] >= 3:
     unicode = str
 
 
+class Args(object):
+    '''Basic argsparser replacement for using gkeys Actions via an API
+
+    Holds the full spectrum of possible options supported.
+    Not all options used by all actions.'''
+
+
+    def __init__(self):
+        self.status = False
+        self.all = False
+        self.category = None
+        self.cleankey = False
+        self.destination = None
+        self.exact = False
+        self.filename = None
+        self.fingerprint = None
+        self.keyid = None
+        self.keyring = None
+        self.keys = None
+        self.nick = None
+        self.name = None
+        self.keydir = None
+        self.seedfile = None
+        self.signature = None
+        self.uid = None
+
+
 class CliBase(object):
     '''Common cli and argsparse options class'''
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-07-25 16:45 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-07-25 16:45 UTC (permalink / raw
  To: gentoo-commits

commit:     7c2b40ebb75a5b7d86fa8f2657e673ac8e0285b5
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 18 20:49:54 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul 25 16:43:05 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=7c2b40eb

gkeys: Re-enable remove-key action

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

diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py
index 3b1b9d0..d7eac63 100644
--- a/gkeys/gkeys/action_map.py
+++ b/gkeys/gkeys/action_map.py
@@ -18,7 +18,7 @@ Seed_Actions = ['----seeds----', 'add-seed', 'fetch-seed',
     'list-seed', 'list-seedfiles', 'remove-seed']
 
 Key_Actions = ['----keys-----', 'check-key', 'installed',
-    'install-key', 'list-key', 'refresh-key',
+    'install-key', 'list-key', 'refresh-key', 'remove-key',
     'search-key', 'spec-check']
 
 General_Actions = ['---general---', 'list-cats', 'sign','verify']


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-07-25 16:45 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-07-25 16:45 UTC (permalink / raw
  To: gentoo-commits

commit:     afee05b427446ffdc12b3d138a1f1d712a757b2d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 21 19:56:49 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul 25 16:43:21 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=afee05b4

gkeys/gkeysinterface.py: Initial commit of an api consumer interface

First use was for creating a gpg signed Manifest verification in portage.
Use snakeoil's demandload for imports

 gkeys/gkeys/gkeysinterface.py | 120 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 120 insertions(+)

diff --git a/gkeys/gkeys/gkeysinterface.py b/gkeys/gkeys/gkeysinterface.py
new file mode 100644
index 0000000..8618268
--- /dev/null
+++ b/gkeys/gkeys/gkeysinterface.py
@@ -0,0 +1,120 @@
+'''Gkeys comsumer app API interface'''
+
+
+import os
+
+from snakeoil.demandload import demandload
+
+from gkeys.config import GKeysConfig
+from gkeys.gkey import GKEY
+
+demandload(
+    "gkeys:log",
+    "gkeys.lib:GkeysGPG",
+    "gkeys.seedhandler:SeedHandler",
+)
+
+
+class GkeysInterface(object):
+    '''High level class to hold and operate our gkeys GkeysGPG instance'''
+
+    def __init__(self, namespace, root='/', config=None,
+        logger=None, loglevel='DEBUG'):
+        '''GkeysInterface init
+
+        @param namespace: string of the logging namespace setting to use
+        @param root: string of the root path to initialize with, default is '/'
+        @param logger: optional logging instance, if undefiined, it
+            will use it's gkeys logger.
+        @param loglevel: string one of {'CRITICAL', 'DEBUG', 'ERROR', 'FATAL',
+            'INFO', 'NOTSET', 'WARN', 'WARNING'}
+        '''
+        self.root = root
+        self.namespace = namespace
+        self.config = config or GKeysConfig(root=root, read_configfile=True)
+        self.logger = logger or log.logger or log.set_logger(
+            namespace=namespace,
+            logpath=self.config.get_key('logdir'),
+            level=loglevel)
+        self.gpg = None
+        self.handler = None
+
+
+    def keyid_search(self, keyid):
+        '''Searches for a keyid in the installed keyrings
+
+        @param keyid: string of the longkeyid to search for
+        @returns dictionary of  {category: [GKEY, ...]}
+        '''
+        results = {}
+        for cat in list(self.config.get_key('seeds')):
+            self.handler.load_category(cat)
+            found = self.handler.key_search({'keyid': keyid,}, ['keyid'])
+            if found:
+                if cat in results:
+                    results[cat].extend(found)
+                else:
+                    results[cat] = found
+        return results
+
+
+    def verify_file(self, filepath, category='gentoo', nick='snapshot',
+            strict=False):
+        '''One stop action to verify a file.
+
+        If the first gpg verification fails, it will auto-search
+        for the correct key to validate against.
+        @param filepath: path of the file to verify
+        @param category: string, optional keyring category, default is 'gentoo'
+        @param nick: string, optional keyring nick, default is 'snapshot'
+        @param strict: boolean toggles off the auto-search if the category/nick
+            supplied fail
+        @return (bool, bool)  (verification pass/fail, file had a signature)
+        '''
+        if not self.handler:
+            self.handler = SeedHandler(self.logger, self.config)
+        keys = self.handler.load_category(category)
+        if not keys:
+            self.logger.warn('No installed keys found, try installing keys.')
+            return False
+        key = self.handler.seeds.nick_search(nick)
+        if not key:
+            self.logger.debug("Failed to find.........: %s in category: %s"
+                % (category, nick))
+            category = self.config.get_key('verify-keyring')
+            nick = self.config.get_key('verify-nick')
+            self.logger.debug("Using config defaults..: %s %s"
+                % (category, nick))
+            return self.verify_file(filepath, category, nick)
+
+        keyrings = self.config.get_key('keyring')
+        catdir = os.path.join(keyrings, category)
+        self.logger.debug("ACTIONS: verify; catdir = %s" % catdir)
+        self.gpg = GkeysGPG(self.config, catdir, self.logger)
+        results = self.gpg.verify_file(key, None, filepath)
+
+        (valid, trust) = results.verified
+        if valid:
+            return True, True
+        self.logger.debug("Verification failed....: %s" % (filepath))
+        self.logger.debug("Key info...............: %s <%s>, %s"
+            % ( key.name, key.nick, key.keyid))
+        has_no_pubkey, s_keyid = results.no_pubkey
+        if has_no_pubkey and s_keyid and not strict:
+            self.logger.debug("Auto-searching for key.: 0x%s" % s_keyid)
+        elif not s_keyid or strict:
+            return False, has_no_pubkey
+        keys = self.keyid_search(s_keyid)
+        for cat in list(keys):
+            for key in keys[cat]:
+                if key and key.nick:
+                    if isinstance(key, GKEY):
+                        self.gpg.basedir = os.path.join(keyrings, cat)
+                        results = self.gpg.verify_file(key, None, filepath)
+                        (valid, trust) = results.verified
+                        if valid:
+                            return True, True
+
+        self.logger.debug("Failed to find gpg key.: 0x%s" % s_keyid)
+        return False, False
+


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-06-22 13:41 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-06-22 13:41 UTC (permalink / raw
  To: gentoo-commits

commit:     d996f4c306e6ca366b288f8ba329f77b54768d51
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 22 13:41:29 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Jun 22 13:41:29 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=d996f4c3

gkeys/actions.py: Add filename extension check exclusion 

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 7275739..6610480 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -778,7 +778,8 @@ class Actions(object):
             self.logger.debug(
                 _unicode("ACTIONS: verify; local file %s") % filepath)
             success = os.path.isfile(filepath)
-            if not signature:
+            if (not signature
+                and '.' + filepath.rsplit('.', 1)[1] not in EXTENSIONS):
                 success_fetch = False
                 for ext in EXTENSIONS:
                     sig_path = filepath + ext


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-06-01  1:56 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-06-01  1:56 UTC (permalink / raw
  To: gentoo-commits

commit:     b0402fd5d51b95ca32705936444ae082f4b3a5c4
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jun  1 01:56:24 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Jun  1 01:56:24 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=b0402fd5

gkeys/actions.py: verify url was not smart about being passed a sig url and would fail to verify

Move EXTENSIONS out as a constant instead of being defined twice.

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 24c323e..7275739 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -36,6 +36,10 @@ demandload(
     "gkeys.seedhandler:SeedHandler",
 )
 
+
+EXTENSIONS = ['.sig', '.asc', '.gpg','.gpgsig']
+
+
 class Actions(object):
     '''Primary API actions'''
 
@@ -754,9 +758,8 @@ class Actions(object):
                 url, filepath, timestamp_path)
             if not success:
                 messages.append(_unicode("File %s cannot be retrieved.") % filepath)
-            else:
+            elif '.' + url.rsplit('.', 1)[1] not in EXTENSIONS:
                 if not signature:
-                    EXTENSIONS = ['.sig', '.asc', 'gpg','.gpgsig']
                     success_fetch = False
                     for ext in EXTENSIONS:
                         sig_path = filepath + ext
@@ -776,7 +779,6 @@ class Actions(object):
                 _unicode("ACTIONS: verify; local file %s") % filepath)
             success = os.path.isfile(filepath)
             if not signature:
-                EXTENSIONS = ['.sig', '.asc', 'gpg','.gpgsig']
                 success_fetch = False
                 for ext in EXTENSIONS:
                     sig_path = filepath + ext


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     9f19528a9d61517cb262081b2cf28a3c2d5ee95b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 20 17:48:15 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun May 31 04:45:22 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=9f19528a

gkeys/actions.py: Seed handling fixes

Update for newer listseed() data returned.

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 80c3c72..d467500 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -98,7 +98,8 @@ class Actions(object):
     def addseed(self, args):
         '''Add or replace a key in the selected seed file'''
         handler = SeedHandler(self.logger, self.config)
-        success, gkeys = self.listseed(args)[1]
+        success, data = self.listseed(args)
+        gkeys = data[1]
         if not args.nick or not args.name or not args.keys or not args.keydir:
             return (False, ["Provide a nickname, a name and a public key fingerprint (-K, --keys)."])
         if not args.fingerprint:
@@ -126,7 +127,8 @@ class Actions(object):
 
     def removeseed(self, args):
         '''Remove a seed from the selected seed file'''
-        success, gkeys = self.listseed(args)[1]
+        success, data = self.listseed(args)
+        gkeys = data[1]
         if not gkeys:
             return (False, ["Failed to remove seed: No gkeys returned from listseed()",
                 []])
@@ -249,7 +251,8 @@ class Actions(object):
     def installkey(self, args):
         '''Install a key from the seed(s)'''
         self.logger.debug("ACTIONS: installkey; args: %s" % str(args))
-        success, gkeys = self.listseed(args)[1]
+        success, data = self.listseed(args)
+        gkeys = data[1]
         if gkeys:
             if gkeys and not args.nick == '*' and self.output:
                 self.output(['', gkeys], "\n Found GKEY seeds:")
@@ -593,7 +596,8 @@ class Actions(object):
             self.logger.debug(_unicode("ACTIONS: importkey; catdir = %s")
                 % catdir)
             self.gpg = GkeysGPG(self.config, catdir, self.logger)
-            success, gkeys = self.listseed(args)[1]
+            success, data = self.listseed(args)
+            gkeys = data[1]
             results = {}
             failed = []
             print("Importing specified keys to keyring.")


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     666b8a6c00251b0034d5e57ee338a44aa6b0a997
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat May 30 23:13:46 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sun May 31 04:46:31 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=666b8a6c

gkeys/actions.py: Fix an UnboundLocalError

File "/usr/lib64/python2.7/site-packages/gkeys/actions.py", line 798, in _verify
    results = self.gpg.verify_file(key, sig_path, filepath)
UnboundLocalError: local variable 'sig_path' referenced before assignment
Reported by: Johannes Huber <johu <AT> gentoo.org>

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index d467500..24c323e 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -734,6 +734,7 @@ class Actions(object):
                     "not supplied, using current directory ./%s") % filepath)
         if args.timestamp:
             timestamp_path = filepath + ".timestamp"
+        sig_path = None
         if isurl:
             from sslfetch.connections import Connector
             connector_output = {


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     328359a9c6d7fb5192b2e4fc3e0a458563cfcdfd
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 21 19:07:06 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:18:50 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=328359a9

gkeys/config.py:  Correctly set default keyring dir name to keyrings

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

diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py
index 6abec96..7cd856a 100644
--- a/gkeys/gkeys/config.py
+++ b/gkeys/gkeys/config.py
@@ -64,7 +64,7 @@ class GKeysConfig(GPGConfig):
 
     def _add_gkey_defaults(self):
         self.defaults['gkeysdir'] = path([self.root, EPREFIX, '/var/lib/gentoo/gkeys'])
-        self.defaults['keyring'] = '%(gkeysdir)s/keyring'
+        self.defaults['keyring'] = '%(gkeysdir)s/keyrings'
         self.defaults['sign-keydir'] = '%(gkeysdir)s/sign',
         self.defaults['logdir'] = '/var/log/gkeys'
         # local directory to scan for seed files installed via ebuild, layman


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     d1abd2a51a3712a5c9f8c55a8d1baa3bdae4907f
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 21 19:06:01 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:18:50 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=d1abd2a5

gkeys/config.py: Remove no longer used MAPSEEDS constant

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

diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py
index 1cac0b0..6abec96 100644
--- a/gkeys/gkeys/config.py
+++ b/gkeys/gkeys/config.py
@@ -30,9 +30,6 @@ if "GENTOO_PORTAGE_EPREFIX" in EPREFIX:
     EPREFIX = ''
 
 
-MAPSEEDS = { 'dev' : 'gentoodevs.seeds', 'rel': 'gentoo.seeds' }
-
-
 class GKeysConfig(GPGConfig):
     """ Configuration superclass which holds our gentoo-keys
     config settings for pygpg """


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     8c6da8152ca04b3a1d706abc2bbd57b1cd982e82
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 21 19:12:22 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:18:51 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=8c6da815

gkeys/actions.py: Refactor installkey to refresh keys that are already installed and unchanged

 gkeys/gkeys/actions.py | 78 +++++++++++++++++++++++++++++---------------------
 1 file changed, 46 insertions(+), 32 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 8e078f0..7b834a4 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -245,11 +245,11 @@ class Actions(object):
     def installkey(self, args):
         '''Install a key from the seed(s)'''
         self.logger.debug("ACTIONS: installkey; args: %s" % str(args))
-        success, gkey = self.listseed(args)[1]
-        if gkey:
-            if gkey and not args.nick == '*' and self.output:
-                self.output(['', gkey], "\n Found GKEY seeds:")
-            elif gkey and self.output:
+        success, gkeys = self.listseed(args)[1]
+        if gkeys:
+            if gkeys and not args.nick == '*' and self.output:
+                self.output(['', gkeys], "\n Found GKEY seeds:")
+            elif gkeys and self.output:
                 self.output(['all'], "\n Installing seeds:")
             else:
                 self.logger.info("ACTIONS: installkey; "
@@ -269,33 +269,47 @@ class Actions(object):
             self.logger.debug(_unicode("ACTIONS: installkey; catdir = %s")
                 % catdir)
             self.gpg = GkeysGPG(self.config, catdir, self.logger)
-            results = {}
-            failed = []
-            for key in gkey:
-                self.logger.debug("ACTIONS: installkey; 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: installkey; result.failed = " +
-                                      str(result.failed))
-                if self.config.options['print_results']:
-                    msg = _unicode("key desired: %(name)s, key added: %(key)s, succeeded:" +\
-                        " %(success)s, fingerprint: %(fpr)s")
-                    for result in results[key.name]:
-                        umsg = msg % ({'name': key.name, 'key': result.username,
-                                'success': str(not result.failed),
-                                'fpr': result.fingerprint})
-                        try:
-                            print(umsg)
-                        except UnicodeDecodeError:
-                            print(_unicode("UnicodeDecodeError printing results for:"), key.name)
-                            self.logger.debug(_unicode("installkey(); UnicodeDecodeError for:") + key.name)
-                            self.logger.debug(_unicode("    result.username...:") + result.username)
-                            self.logger.debug(_unicode("    result.failed.....:") + result.failed)
-                            self.logger.debug(_unicode("    result.fingerprint:") + result.fingerprint)
-                        self.logger.debug("stderr_out: " + str(result.stderr_out))
-                        if result.failed:
-                            failed.append(key)
+            for gkey in gkeys:
+                self.gpg.set_keydir(gkey.keydir, "recv-keys")
+                self.gpg.set_keyseedfile()
+                seeds = self.gpg.seedfile.seeds
+                #print(seeds)
+                if seeds:
+                    self.logger.debug("ACTIONS: installkey; found installed seeds:"
+                        "\n %s" % seeds)
+                results = {}
+                failed = []
+                if gkey.nick in seeds and gkey.keys == seeds[gkey.nick].keys:
+                    self.logger.debug("ACTIONS: installkey; refreshing key:")
+                    if self.config.options['print_results']:
+                        print(_unicode("Refreshing already installed key: %s, %s"
+                            %(gkey.nick, gkey.keys)))
+                    self.gpg.refresh_key(gkey)
+                else:
+                    self.logger.debug("ACTIONS: installkey; adding key:")
+                    self.logger.debug("ACTIONS: " + str(gkey))
+                    results[gkey.name] = self.gpg.add_key(gkey)
+                    for result in results[gkey.name]:
+                        self.logger.debug("ACTIONS: installkey; result.failed = " +
+                                          str(result.failed))
+                    if self.config.options['print_results']:
+                        msg = _unicode("key desired: %(name)s, key added: %(key)s, succeeded:" +\
+                            " %(success)s, fingerprint: %(fpr)s")
+                        for result in results[gkey.name]:
+                            umsg = msg % ({'name': gkey.name, 'key': result.username,
+                                    'success': str(not result.failed),
+                                    'fpr': result.fingerprint})
+                            try:
+                                print(umsg)
+                            except UnicodeDecodeError:
+                                print(_unicode("UnicodeDecodeError printing results for:"), gkey.name)
+                                self.logger.debug(_unicode("installkey(); UnicodeDecodeError for:") + gkey.name)
+                                self.logger.debug(_unicode("    result.username...:") + result.username)
+                                self.logger.debug(_unicode("    result.failed.....:") + result.failed)
+                                self.logger.debug(_unicode("    result.fingerprint:") + result.fingerprint)
+                            self.logger.debug("stderr_out: " + str(result.stderr_out))
+                            if result.failed:
+                                failed.append(gkey)
             if failed and self.output:
                 self.output([failed], "\n Failed to install:")
             if failed:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     ffe53b207532d165f3e6019e10ee27f23e0b3e84
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 18 23:18:13 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:18:50 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=ffe53b20

gkeys: Remove gpgsearch option from list-key action

The default action for list-key is to now list all keys found in the keydir.
Regardless if they are in the db's seed file for that keydir.

 gkeys/gkeys/action_map.py |  2 +-
 gkeys/gkeys/actions.py    | 48 ++++++++++-------------------------------------
 2 files changed, 11 insertions(+), 39 deletions(-)

diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py
index d547ab3..3b1b9d0 100644
--- a/gkeys/gkeys/action_map.py
+++ b/gkeys/gkeys/action_map.py
@@ -157,7 +157,7 @@ Found:
     ('list-key', {
         'func': 'listkey',
         'options': ['category', 'nick', 'name', 'fingerprint', 'keyid', 'keys',
-            'keydir', 'keyring', 'gpgsearch'],
+            'keydir', 'keyring'],
         'desc': '''Pretty-print the selected gpg key''',
         'long_desc': '''Pretty-print the selected gpg key''',
         'example': '''gkeys list-key -C gentoo -n gkeys

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index efab4fa..edbea0d 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -206,45 +206,17 @@ class Actions(object):
         results = {}
         success = []
         messages = []
-        if args.gpgsearch:
-            keyresults = seeds.seeds
-            # pick any key
-            key = keyresults[sorted(keyresults)[0]]
-            result = self.gpg.list_keys(key.keydir, args.gpgsearch)
-            # now split the results and reverse lookup the gkey
-            lines = result.output.split('\n')
-            while lines:
-                # determine the end of the first key listing
-                index = lines.index('')
-                keyinfo = lines[:index]
-                # trim off the first keys info
-                lines = lines[index + 1:]
-                # make sure it is a key listing
-                if len(keyinfo) < 2:
-                    break
-                # get the fingerprint from the line
-                fpr = keyinfo[1].split('= ')[1]
-                # search for the matching gkey
-                kwargs = {'keydir': args.keydir, 'fingerprint': [fpr]}
-                keyresults = seeds.list(**kwargs)
-                # list the results
-                for key in sorted(keyresults):
-                    ls, lr = self._list_it(key, '\n'.join(keyinfo))
-                    success.append(ls)
-                    results[key.name] = lr
+        kwargs = handler.build_gkeydict(args)
+        keyresults = seeds.list(**kwargs)
+        for key in sorted(keyresults):
+            if args.fingerprint:
+                result = self.gpg.list_keys(key.keydir, kwargs['fingerprint'])
+            else:
+                result = self.gpg.list_keys(key.keydir)
+            ls, lr = self._list_it(key, result.output)
+            success.append(ls)
+            results[key.name] = lr
             messages = ["Done."]
-        else:
-            kwargs = handler.build_gkeydict(args)
-            keyresults = seeds.list(**kwargs)
-            for key in sorted(keyresults):
-                if args.fingerprint:
-                    result = self.gpg.list_keys(key.keydir, kwargs['fingerprint'])
-                else:
-                    result = self.gpg.list_keys(key.keydir)
-                ls, lr = self._list_it(key, result.output)
-                success.append(ls)
-                results[key.name] = lr
-                messages = ["Done."]
 
         if not messages:
             messages = ['No results found meeting criteria', "Did you specify -n foo or -n '*'"]


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     75cd2f50c181c78863e71ebbef17c70da90bfe6c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 23 15:37:24 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:18:51 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=75cd2f50

gkeys: Use snakeoil's demandload where appropriate

 gkeys/gkeys/actions.py     | 10 +++++++---
 gkeys/gkeys/seed.py        | 10 +++++++---
 gkeys/gkeys/seedhandler.py | 11 ++++++++---
 gkeys/gkeys/utils.py       | 13 +++++++++----
 4 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 7b834a4..80c3c72 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -24,13 +24,17 @@ else:
 
 
 from collections import defaultdict
-from json import load
 
-from gkeys.lib import GkeysGPG
-from gkeys.seedhandler import SeedHandler
+from snakeoil.demandload import demandload
+
 from gkeys.gkey import GKEY
 from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn
 
+demandload(
+    "json:load",
+    "gkeys.lib:GkeysGPG",
+    "gkeys.seedhandler:SeedHandler",
+)
 
 class Actions(object):
     '''Primary API actions'''

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index ca5e2d2..985f6a1 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -21,11 +21,15 @@ import json
 import os
 import sys
 
-from gkeys.exception import UpdateDbError
-from gkeys.log import logger
+from snakeoil.demandload import demandload
+
 from gkeys.gkey import GKEY
-from gkeys.fileops import ensure_dirs
 
+demandload(
+    "gkeys.log:logger",
+    "gkeys.exception:UpdateDbError",
+    "gkeys.fileops:ensure_dirs",
+)
 
 if sys.version_info[0] >= 3:
     def decoder(text, enc='utf_8'):

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 8b787d1..86cab25 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -12,12 +12,17 @@
 
 import os
 import re
-from json import load
 
-from gkeys.exception import UpdateDbError
+from snakeoil.demandload import demandload
+
 from gkeys.gkey import GKEY
 from gkeys.seed import Seeds, decoder
-from gkeys.fileops import ensure_dirs
+
+demandload(
+    "json:load",
+    "gkeys.exception:UpdateDbError",
+    "gkeys.fileops:ensure_dirs",
+)
 
 
 class SeedHandler(object):

diff --git a/gkeys/gkeys/utils.py b/gkeys/gkeys/utils.py
index 92abc50..64f11aa 100644
--- a/gkeys/gkeys/utils.py
+++ b/gkeys/gkeys/utils.py
@@ -24,10 +24,15 @@ Utility functions'''
 
 import types
 import re
-import os
-import sys
-import locale
-import codecs
+
+from snakeoil.demandload import demandload
+
+demandload(
+    "os",
+    "sys",
+    "locale",
+    "codecs",
+)
 
 try:
     StringTypes = types.StringTypes


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     5b11872bd684d0bac674b65832c737280d001e11
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 22 15:54:59 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:18:51 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=5b11872b

gkeys/gkey.py: Fix typo in @license

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

diff --git a/gkeys/gkeys/gkey.py b/gkeys/gkeys/gkey.py
index a305804..ab62f5b 100644
--- a/gkeys/gkeys/gkey.py
+++ b/gkeys/gkeys/gkey.py
@@ -7,7 +7,7 @@
     Holds GKEY class and related values
 
     @copyright: 2012-2015 by Brian Dolbec <dol-sen@gentoo.org>
-    @license: GNU GNU GPL2, see COPYING for details.
+    @license: GNU GPL2, see COPYING for details.
 """
 
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     c3b217c2c8e0402a71e75407e7d37f9639f045f2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 21 19:09:03 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:18:50 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c3b217c2

gkeys/seedhandler.py: Make key_search accept args as a dictionary or argsparse object

 gkeys/gkeys/seedhandler.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index a905051..8b787d1 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -216,17 +216,27 @@ class SeedHandler(object):
     def key_search(self, args, search_args):
         '''Performs a search for all listed args in the seeds'''
         results = []
-        self.logger.debug("_field_search search_args: %s" % str(search_args))
+        self.logger.debug("SeedHandler.key_search() search_args: %s" % str(search_args))
         found = {}
         search_args.sort()
+        if isinstance(args, dict):
+            exact = args.get('exact', False)
+            _all = args.get('all', False)
+        else:
+            exact = getattr(args, 'exact', False)
+            _all = getattr(args, 'all', False)
         for arg in search_args:
-            seeds = self.seeds.field_search(arg, getattr(args, arg), args.exact)
+            if isinstance(args, dict):
+                value = args.get(arg, '')
+            else:
+                value = getattr(args, arg)
+            seeds = self.seeds.field_search(arg, value, exact)
             for seed in seeds:
                 if seed.nick in found:
                     found[seed.nick]['args'].append(arg)
                 else:
                     found[seed.nick] = {'args': [arg], 'seed': seed}
-        if args.all:
+        if _all:
             for possible in sorted(found):
                 if search_args == found[possible]['args']:
                     results.append(found[possible]['seed'])


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     25e13adf18f29529287868abe32ee522b898c66e
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 21 19:10:36 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:18:50 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=25e13adf

gkeys/actions.py: Remove unused keyring_dir assignment

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index edbea0d..8e078f0 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -572,7 +572,6 @@ class Actions(object):
         if args.category:
             keyring = self.config.get_key('keyring')
             catdir = os.path.join(keyring, args.category)
-            keyring_dir = self.config.get_key("keyring")
             self.logger.debug(_unicode("ACTIONS: importkey; catdir = %s")
                 % catdir)
             self.gpg = GkeysGPG(self.config, catdir, self.logger)


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     35ecad248a81436dcad7e6b9928ed3eeb098c9af
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 20 17:44:59 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:29:06 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=35ecad24

gkeys/seed.py: Replace codecs usage with unicode()

Add a noop for an empty kwargs[key].

jgjhgj

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

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index 985f6a1..01ca5a5 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -36,7 +36,7 @@ if sys.version_info[0] >= 3:
         return text
 else:
     def decoder(text, enc='utf_8'):
-        return codecs.decode(text, enc)
+        return unicode(text)
 
 
 class Seeds(object):
@@ -155,6 +155,8 @@ class Seeds(object):
         keys = kwargs
         result = self.seeds
         for key in keys:
+            if not kwargs[key]:
+                continue
             if key in ['fingerprint', 'keys', 'keyid']:
                 kwargs[key] = [x.replace(' ', '').upper() for x in kwargs[key]]
             if key in ['fingerprint', 'keys', 'uid']:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     695631f23ad2bddff1f3efda698a90a23d38db1c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 20 17:46:59 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:32:17 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=695631f2

gkeys/seedhandler.py: Fix build_gkeydict()

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

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 86cab25..18725b9 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -58,10 +58,13 @@ class SeedHandler(object):
                 value = getattr(args, attr)
                 if attr == 'name' and isinstance(value, list):
                     value = " ".join(value)
-                if attr == 'fingerprint' and value:
+                if attr in ['fingerprint', 'keys'] and value:
                     value = [x.replace(" ", "") for x in value]
-                if value is not None:
+                    keyinfo[attr] = value
+                if value is not None and attr in ['keydir', 'name', 'nick']:
                     keyinfo[attr] = decoder(value)
+                else:
+                    keyinfo[attr] = value
             except AttributeError:
                 pass
         return keyinfo


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     37c128e77c7d9e3220561b5ca7bb5ff9bae51f32
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 18 20:50:57 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:18:50 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=37c128e7

gkeys/actionspy: Fix grammar in the confirmation input message

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 6975c38..efab4fa 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -542,7 +542,7 @@ class Actions(object):
         if args.nick == '*':
             self.output([''],_unicode('Remove All keys in category: %s')
                 % _unicode(args.category))
-            ans = py_input ("Do you really want to remove ALL of keys?[y/n]: ")
+            ans = py_input ("Do you really want to remove ALL of the keys?[y/n]: ")
             while ans not in ["yes", "y", "no", "n"]:
                 ans = py_input ("Do you really want to remove ALL keys?[y/n]: ")
             if ans in ["no", "n"]:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     c05d6a6e622d14a6dc9d3b72b34e7d040efe7a37
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 18 20:49:18 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:18:50 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=c05d6a6e

gkeys: Fix list-key action to list all keys found in the keydir unless -f is passed in

This now ignores the keys listed in the db's seed file and lists all keys seen by gpg.
Except when -f, --fingerprint is an argument, then it lists only that key.

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 22d660f..6975c38 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -237,7 +237,10 @@ class Actions(object):
             kwargs = handler.build_gkeydict(args)
             keyresults = seeds.list(**kwargs)
             for key in sorted(keyresults):
-                result = self.gpg.list_keys(key.keydir, key.fingerprint)
+                if args.fingerprint:
+                    result = self.gpg.list_keys(key.keydir, kwargs['fingerprint'])
+                else:
+                    result = self.gpg.list_keys(key.keydir)
                 ls, lr = self._list_it(key, result.output)
                 success.append(ls)
                 results[key.name] = lr

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index a740dd9..bce4e55 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -254,16 +254,17 @@ class GkeysGPG(GPG):
         if fingerprint:
             task = 'list-key'
             target = fingerprint
+            self.set_keydir(keydir, task, fingerprint=True)
         else:
             task = 'list-keys'
-            target = keydir
-        self.set_keydir(keydir, task, fingerprint=True)
-        self.config.options['tasks'][task].extend(['--keyid-format', 'long', '--fingerprint', '--fingerprint'])
+            target = ''
+            self.set_keydir(keydir, task, fingerprint=False)
+        self.config.options['tasks'][task].extend(['--keyid-format', 'long', '--fingerprint'])
         if colons:
             task_value = ['--with-colons']
             self.config.options['tasks'][task].extend(task_value)
         self.logger.debug("** Calling runGPG with Running 'gpg %s --%s %s'"
-            % (' '.join(self.config['tasks'][task]), task, keydir)
+            % (' '.join(self.config['tasks'][task]), task, target)
             )
         result = self.runGPG(task=task, inputfile=target)
         self.logger.info('GPG return code: ' + str(result.returncode))


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     2573d49b85fabcb871d067c678888f92fe75cfd4
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 18 20:42:30 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:18:50 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=2573d49b

gkeys/seedhandler.py: Add space removal for fingerprints in build_gkeydict()

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

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index adf9507..a905051 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -53,6 +53,8 @@ class SeedHandler(object):
                 value = getattr(args, attr)
                 if attr == 'name' and isinstance(value, list):
                     value = " ".join(value)
+                if attr == 'fingerprint' and value:
+                    value = [x.replace(" ", "") for x in value]
                 if value is not None:
                     keyinfo[attr] = decoder(value)
             except AttributeError:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     46bbcbc3cc1b11577eceb9291fc469f4aad8469f
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 18 20:44:58 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat May 30 23:18:50 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=46bbcbc3

gkeys/lib.py: Fix logger message to show the correct function

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

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index 3eb267c..a740dd9 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -234,7 +234,7 @@ class GkeysGPG(GPG):
             lresults.append(self.list_keys(gkey.keydir, fpr, colons=True))
         self.seedfile.update(gkey.update(lresults))
         if save and not self.seedfile.save():
-            self.logger.error("GkeysGPG.refresh_key(); failed to save seed: " + gkey.nick)
+            self.logger.error("GkeysGPG.update_gkey(); failed to save seed: " + gkey.nick)
             return False
         return True
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-05-31  5:03 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-05-31  5:03 UTC (permalink / raw
  To: gentoo-commits

commit:     8afad8720eea5e69c9247fe207c9cd8e20a2a0e6
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  9 21:04:04 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Apr 20 17:49:44 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=8afad872

gkeys: remove-key refactoring

Update the remove-key action to use the proper installed db.
Populate the del_key, del_keydir functions in lib.py

 gkeys/gkeys/actions.py | 27 +++++++++++++--------------
 gkeys/gkeys/lib.py     | 35 +++++++++++++++++++++++++++++------
 2 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index cfe69ee..22d660f 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -25,7 +25,6 @@ else:
 
 from collections import defaultdict
 from json import load
-from shutil import rmtree
 
 from gkeys.lib import GkeysGPG
 from gkeys.seedhandler import SeedHandler
@@ -551,7 +550,7 @@ class Actions(object):
             keyresults = seeds.list(**kwargs)
         self.output('', '\n Removing keys...')
         success = True
-        print(keyresults)
+        #print(keyresults)
         for gkey in sorted(keyresults):
             if kwargs['nick'] != '*' and  kwargs['nick'] not in gkey.nick:
                 messages.append(_unicode("%s does not seem to be a valid key.")
@@ -569,22 +568,22 @@ class Actions(object):
                 if ans in ["no", "n"]:
                     messages.append("Key removal aborted... Nothing to be done.")
                 else:
-                    ## This next code is total crap  now
-                    ## re-write it from scratch
-                    ## there could be multiple keys installed in one keyring
-                    ## this code just rm's everything.
                     keyring = self.config.get_key('keyring')
                     catdir = os.path.join(keyring, args.category)
-                    rm_candidate = os.path.join(catdir, gkey.nick)
                     self.logger.debug(_unicode("ACTIONS: removekey; catdir = %s")
                         % catdir)
-                    if args.category:
-                        try:
-                            rmtree(rm_candidate)
-                            messages.append(_unicode("Done removing %s key.") % kwargs['nick'])
-                        except OSError:
-                            messages.append(_unicode("%s directory does not exist.") % rm_candidate)
-                            success = False
+                    self.gpg = GkeysGPG(self.config, catdir, self.logger)
+                    if len(gkey.keys) == 1 or args.keys == gkey.keys:
+                        success, msgs = self.gpg.del_keydir(gkey)
+                        messages.extend(msgs)
+                    elif args.keys:
+                        for key in args.keys:
+                            success, msgs = self.gpg.del_key(gkey, key)
+                            msgs.extend(msgs)
+                    else:
+                        for key in gkey.keys:
+                            success, msgs = self.gpg.del_key(gkey, key)
+                            msgs.extend(msgs)
         return (success, messages)
 
 

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index 9687c24..3eb267c 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -19,9 +19,10 @@ with gentoo-keys specific convienience functions.
 # for py 2.6 compatibility
 from __future__ import print_function
 
-
+import os
 from os.path import abspath, pardir
 from os.path import join as pjoin
+from shutil import rmtree
 
 from pyGPG.gpg import GPG
 from gkeys.checks import KeyChecks
@@ -165,18 +166,40 @@ class GkeysGPG(GPG):
         return results
 
 
-    def del_key(self, gkey, keydir):
-        '''Delete the specified key in the specified keydir
+    def del_key(self, gkey, key):
+        '''Delete the specified key
 
         @param gkey: GKEY namedtuple with (name, nick, keydir, fingerprint)
+        @param key: Fingerprint of the primary key to delete
         '''
-        return []
+        self.set_keydir(gkey.keydir, 'del-key', reset=True)
+        self.set_keyring('pubring.gpg', 'del-key', reset=False)
+        self.set_keyseedfile(refresh=True)
+        self.logger.debug("LIB: del_key, gkey: %s" % str(gkey))
+        self.logger.debug("LIB: del_key, key: %s" % key)
+        self.logger.debug("** Calling runGPG with: 'gpg %s --delete-keys' for: %s"
+            % (' '.join(self.config.get_key('tasks', 'delete-keys')), str(gkey)))
+        result = self.runGPG(task='delete-keys', inputfile=key)
+        self.logger.info('GPG return code: ' + str(result.returncode))
+        self.update_gkey(gkey, save=True)
+        return (False, [])
 
 
-    def del_keydir(self, keydir):
+    def del_keydir(self, gkey):
         '''Delete the specified keydir
+
+        @param gkey: GKEY namedtuple with (name, nick, keydir, fingerprint)
         '''
-        return []
+        rm_candidate = os.path.join(self.basedir, gkey.keydir)
+        success = False
+        messages = []
+        try:
+            rmtree(rm_candidate)
+            messages.append("Done removing %s key." % gkey.nick)
+            success = True
+        except OSError:
+            messages.append("%s directory does not exist or is a symbolic link." % rm_candidate)
+        return (success, messages)
 
 
     def refresh_key(self, gkey):


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-03-18 15:32 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-03-18 15:32 UTC (permalink / raw
  To: gentoo-commits

commit:     1f8fc87469153591e4cefeb93bdff0ba995c5190
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 18 15:32:17 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Mar 18 15:32:17 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=1f8fc874

gkeys/checks.py: Downgrade the logging to warn from error

logging.error also prints to the screen which we don't want in this case.
The logging.warn is fine for these errors since they are already shown in a formatted output.

 gkeys/gkeys/checks.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py
index a3af3ab..7e40720 100644
--- a/gkeys/gkeys/checks.py
+++ b/gkeys/gkeys/checks.py
@@ -369,10 +369,10 @@ class KeyChecks(object):
             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'
-            self.logger.error("ERROR in key %s : gpg key expire date: %s EXCEEDS specification"
+            self.logger.warn("ERROR in key %s : gpg key expire date: %s EXCEEDS specification"
                 % (data.long_keyid, data.expiredate))
         else:
-            self.logger.error("ERROR in key %s : invalid gpg key expire date: %s"
+            self.logger.warn("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'
@@ -398,7 +398,7 @@ class KeyChecks(object):
                     stats[SPEC_INDEX['encrypt_capable']] = True
                 elif cap not in CAPABILITY_MAP:
                     stats[SPEC_INDEX['caps']] = False
-                    self.logger.error("ERROR in key %s : unknown gpg key capability: %s"
+                    self.logger.warn("ERROR in key %s : unknown gpg key capability: %s"
                         % (data.long_keyid, cap))
         stats[SPEC_INDEX['long_caps']] = ', '.join(kcaps)
         return stats


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-03-17 19:51 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-03-17 19:51 UTC (permalink / raw
  To: gentoo-commits

commit:     f12dcd69d558b3b5f58ecd21ee20e347a06a3405
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 17 19:50:53 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Mar 17 19:50:53 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=f12dcd69

gkeys/checks.py: Fix the expiry warning summary not detecting any

Add logger messages for expiry errors/warnings

 gkeys/gkeys/actions.py | 2 +-
 gkeys/gkeys/checks.py  | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index b2b8cf3..cfe69ee 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -459,7 +459,7 @@ class Actions(object):
                             if not key.bits:
                                 failed['bits'].append(_unicode("%s <%s>: %s")
                                     % (gkey.name, gkey.nick, key.fingerprint))
-                        if "Warning" in key.expire_reason:
+                        if "warning" in key.expire_reason.lower():
                             failed['warn'].append(_unicode("%s <%s>: %s ")
                                 % (gkey.name, gkey.nick, key.fingerprint))
                     if True in pub_pass['signs']:

diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py
index bddad5f..a3af3ab 100644
--- a/gkeys/gkeys/checks.py
+++ b/gkeys/gkeys/checks.py
@@ -369,12 +369,15 @@ class KeyChecks(object):
             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'
+            self.logger.error("ERROR in key %s : gpg key expire date: %s EXCEEDS specification"
+                % (data.long_keyid, data.expiredate))
         else:
-            self.logger.debug("ERROR in key %s : invalid gpg key expire date: %s"
+            self.logger.error("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'
-
+            self.logger.warn("WARNING in key %s : gpg key expire date: %s WARNING < 30 days"
+                % (data.long_keyid, data.expiredate))
         return stats
 
 
@@ -395,7 +398,7 @@ class KeyChecks(object):
                     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"
+                    self.logger.error("ERROR in key %s : unknown gpg key capability: %s"
                         % (data.long_keyid, cap))
         stats[SPEC_INDEX['long_caps']] = ', '.join(kcaps)
         return stats


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-03-08 15:09 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-03-08 15:09 UTC (permalink / raw
  To: gentoo-commits

commit:     5a12b768465c9e68f2c46354d8f77316c40f9ef6
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Mar  7 18:04:52 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Mar  7 18:04:52 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=5a12b768

gkeys/base.py: Fix expanduser error reported by K_F

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

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 08bfe5f..fba1976 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -267,8 +267,8 @@ class CliBase(object):
             self.config.read_config(configs)
 
         # check for permissions and adjust configs accordngly
-        if not self.config['homedir']:
-            self.config['homedir'] = os.path.expanduser('~')
+        if not self.config.defaults['homedir']:
+            self.config.defaults['homedir'] = os.path.expanduser('~')
         if not os.access(self.config['logdir'], os.W_OK):
             self.config['logdir'] = ensure_dirs(
                 os.path.join(self.config['user-dir'], 'logs'))


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-03-06 21:04 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-03-06 21:04 UTC (permalink / raw
  To: gentoo-commits

commit:     104269d7a6bf20cc0a618ba9194c2be6e2970abe
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Mar  6 21:03:46 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Mar  6 21:03:46 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=104269d7

gkeys/seed.py: Revert the use of codecs to open the seed file

It was causing tracebacks in python-2.7 running in vulture.gentoo.org

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

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index 262ba57..ca5e2d2 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -61,7 +61,7 @@ class Seeds(object):
         seedlines = None
         self.seeds = {}
         try:
-            with codecs.open(self.filename, "r+", encoding='utf_8') as seedfile:
+            with open(self.filename, "r+") as seedfile:
                 seedlines = json.load(seedfile)
         except IOError as err:
             self.logger.debug("Seed: load; IOError occurred while loading file")
@@ -104,7 +104,7 @@ class Seeds(object):
             fatal=True)
         os.umask(int(self.config.get_key("permissions", "files"),0))
         try:
-            with codecs.open(self.filename, 'w', encoding='utf_8') as seedfile:
+            with open(self.filename, 'w') as seedfile:
                 seedfile.write(self._seeds2json(self.seeds))
                 seedfile.write("\n")
         except IOError as err:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-02-11 17:37 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-02-11 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     9ecc173ca9dfa1b22af86ba9412c6f6777cbb54b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 28 21:30:04 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 31 04:40:29 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=9ecc173c

gkeys: Fix verify -F logic for inline sigs

---
 gkeys/gkeys/actions.py | 115 ++++++++++++++++++++++++++-----------------------
 gkeys/gkeys/lib.py     |   2 +-
 2 files changed, 62 insertions(+), 55 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 16dbb26..dfc9f09 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -755,71 +755,78 @@ class Actions(object):
                 _unicode("ACTIONS: verify; timestamp path: %s") % timestamp_path)
             success, signedfile, timestamp = fetcher.fetch_file(
                 url, filepath, timestamp_path)
+            if not success:
+                messages.append(_unicode("File %s cannot be retrieved.") % filepath)
+            else:
+                if not signature:
+                    EXTENSIONS = ['.sig', '.asc', 'gpg','.gpgsig']
+                    success_fetch = False
+                    for ext in EXTENSIONS:
+                        sig_path = filepath + ext
+                        if isurl:
+                            signature = url + ext
+                            self.logger.debug(
+                                _unicode("ACTIONS: verify; fetching %s signature ")
+                                % signature)
+                            success_fetch, sig, timestamp = fetcher.fetch_file(signature, sig_path)
+                        if success_fetch:
+                            break
+                        else:
+                            signature = None
         else:
             filepath = os.path.abspath(filepath)
             self.logger.debug(
                 _unicode("ACTIONS: verify; local file %s") % filepath)
             success = os.path.isfile(filepath)
-        if not success:
-            messages.append(_unicode("File %s cannot be retrieved.") % filepath)
-        else:
             if not signature:
                 EXTENSIONS = ['.sig', '.asc', 'gpg','.gpgsig']
                 success_fetch = False
                 for ext in EXTENSIONS:
                     sig_path = filepath + ext
-                    if isurl:
-                        signature = url + ext
-                        self.logger.debug(
-                            _unicode("ACTIONS: verify; fetching %s signature ")
-                            % signature)
-                        success_fetch, sig, timestamp = fetcher.fetch_file(signature, sig_path)
-                    else:
-                        signature = filepath + ext
-                        signature = os.path.abspath(signature)
-                        self.logger.debug(
-                            _unicode("ACTIONS: verify; checking %s signature ")
-                            % signature)
-                        success_fetch = os.path.isfile(signature)
-                    if success_fetch:
+                    sig_path = os.path.abspath(sig_path)
+                    self.logger.debug(
+                        _unicode("ACTIONS: verify; checking %s signature ")
+                        % sig_path)
+                    success_sig = os.path.isfile(sig_path)
+                    if success_sig:
                         break
-            else:
-                sig_path = signature
-            self.logger.info("Verifying file...")
-            verified = False
-            results = self.gpg.verify_file(key, sig_path, filepath)
-            keyid = key.keyid[0]
-            (valid, trust) = results.verified
-            if valid:
-                verified = True
-                messages.extend(
-                    [_unicode("Verification succeeded.: %s") % (filepath),
-                    _unicode("Key info...............: %s <%s>, %s")
-                    % ( key.name, key.nick, keyid),
-                    _unicode("    category, nick.....: %s %s")
-                    % (args.category, args.nick)])
-            else:
-                messages.extend(
-                    [_unicode("Verification failed....: %s") % (filepath),
-                    _unicode("Key info...............: %s <%s>, %s")
-                    % ( key.name, key.nick, keyid)])
-                has_no_pubkey, s_keyid = results.no_pubkey
-                if has_no_pubkey:
-                    messages.append(
-                        _unicode("Auto-searching for key.: 0x%s") % s_keyid)
-                    # reset all but keyid and pass thru data
-                    args.keyid = s_keyid
-                    args.keydir = None
-                    args.fingerprint = None
-                    args.exact = False
-                    args.category = None
-                    args.nick = None
-                    args.name = None
-                    args.all = False
-                    keys = self.key_search(args, data_only=True)
-                    args.category = list(keys)[0]
-                    args.nick = keys[args.category][0].nick
-                    return self.verify(args, messages)
+                    else:
+                        sig_path = None
+        self.logger.info("Verifying file...")
+        verified = False
+        results = self.gpg.verify_file(key, sig_path, filepath)
+        keyid = key.keyid[0]
+        (valid, trust) = results.verified
+        if valid:
+            verified = True
+            messages.extend(
+                [_unicode("Verification succeeded.: %s") % (filepath),
+                _unicode("Key info...............: %s <%s>, %s")
+                % ( key.name, key.nick, keyid),
+                _unicode("    category, nick.....: %s %s")
+                % (args.category, args.nick)])
+        else:
+            messages.extend(
+                [_unicode("Verification failed....: %s") % (filepath),
+                _unicode("Key info...............: %s <%s>, %s")
+                % ( key.name, key.nick, keyid)])
+            has_no_pubkey, s_keyid = results.no_pubkey
+            if has_no_pubkey:
+                messages.append(
+                    _unicode("Auto-searching for key.: 0x%s") % s_keyid)
+                # reset all but keyid and pass thru data
+                args.keyid = s_keyid
+                args.keydir = None
+                args.fingerprint = None
+                args.exact = False
+                args.category = None
+                args.nick = None
+                args.name = None
+                args.all = False
+                keys = self.key_search(args, data_only=True)
+                args.category = list(keys)[0]
+                args.nick = keys[args.category][0].nick
+                return self.verify(args, messages)
         return (verified, messages)
 
 

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index 4ae534d..9687c24 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -311,7 +311,7 @@ class GkeysGPG(GPG):
             results = self.runGPG(task='verify', inputfile=[signature,filepath])
         else:
             self.set_keydir(gkey.keydir, 'decrypt', reset=True)
-            self.logger.debug("** Calling runGPG with Running 'gpg %s --decrypt %s and %s'"
+            self.logger.debug("** Calling runGPG with Running 'gpg %s --decrypt %s'"
                     % (' '.join(self.config['tasks']['decrypt']), filepath))
             results = self.runGPG(task='decrypt', inputfile=filepath)
         keyid = gkey.keyid[0]


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-02-11 17:37 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-02-11 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     50670d9212b29b27192f3e951d680391e0fbd70a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 11 17:21:35 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Feb 11 17:30:27 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=50670d92

gkeys/actions.py: Remove result from del list, it's not always defined

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 3852372..0a30679 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -953,7 +953,7 @@ class Actions(object):
                     if isinstance(result, GKEY):
                         keys[cat].append(result)
         if data_only:
-            del found, cat, result, handler
+            del found, cat, handler
             return keys
         msgs = []
         for cat in list(keys):


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-02-11 17:37 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-02-11 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     d3446934815ba262e479cea7272a524b65d3f041
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 13 05:58:59 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 31 03:43:47 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=d3446934

gkeys/actions.py: Trap UnicodeDecodeError for installkey()

Add debug logging for the error.

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 23c71fc..ad03038 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -292,9 +292,16 @@ class Actions(object):
                     msg = "key desired: %(name)s, key added: %(key)s, succeeded:" +\
                         " %(success)s, fingerprint: %(fpr)s"
                     for result in results[key.name]:
-                        print(msg % ({'name': key.name, 'key': result.username,
-                            'success': not result.failed,
-                            'fpr': result.fingerprint}))
+                        try:
+                            print(msg % ({'name': key.name, 'key': result.username,
+                                'success': str(not result.failed),
+                                'fpr': result.fingerprint}))
+                        except UnicodeDecodeError:
+                            print("UnicodeDecodeError printing results for:", key.name)
+                            self.logger.debug("installkey(); UnicodeDecodeError for:" + key.name)
+                            self.logger.debug("    result.username...:" + result.username)
+                            self.logger.debug("    result.failed.....:" + result.failed)
+                            self.logger.debug("    result.fingerprint:" + result.fingerprint)
                         self.logger.debug("stderr_out: " + str(result.stderr_out))
                         if result.failed:
                             failed.append(key)
@@ -564,7 +571,7 @@ class Actions(object):
                         "succeeded: %(success)s, fingerprint: %(fpr)s"
                     for result in results[gkey.name]:
                         print(msg % ({'name': gkey.name, 'key': result.username,
-                            'success': not result.failed,
+                            'success': str(not result.failed),
                             'fpr': result.fingerprint}))
                         self.logger.debug("stderr_out: " + str(result.stderr_out))
                         if result.failed:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-02-11 17:37 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-02-11 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     0b5e90a96d8434177c7ef8f5cfc34129a879baf3
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 11 17:20:24 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Feb 11 17:30:27 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=0b5e90a9

gkeys/action_map.py: Add uid to possible options

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

diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py
index 2a11146..d547ab3 100644
--- a/gkeys/gkeys/action_map.py
+++ b/gkeys/gkeys/action_map.py
@@ -58,7 +58,7 @@ Action_Map = OrderedDict([
     ('verify', {
         'func': 'verify',
         'options': ['category', 'nick', 'name', 'fingerprint', 'keydir', 'keys',
-            '1file', 'signature', 'timestamp', 'dest'],
+            '1file', 'signature', 'timestamp', 'dest', 'uid'],
         'desc': '''File automatic download and/or verification action.''',
         'long_desc': '''File automatic download and/or verification action.
     Note: If the specified key/keyring to verify against does not contain


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-02-11 17:37 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-02-11 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     7243efa95b7f2da8f1d61af8a2ad643d9f10a8fa
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 11 17:22:34 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Feb 11 17:30:28 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=7243efa9

gkeys/actions.py: _verify() Properly report a failed search

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 0a30679..b2b8cf3 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -825,9 +825,11 @@ class Actions(object):
                 args.name = None
                 args.all = False
                 keys = self.key_search(args, data_only=True)
-                args.category = list(keys)[0]
-                args.nick = keys[args.category][0].nick
-                return self.verify(args, messages)
+                if keys:
+                    args.category = list(keys)[0]
+                    args.nick = keys[args.category][0].nick
+                    return self.verify(args, messages)
+                messages.append(_unicode("Failed to find gpg key.: 0x%s") % s_keyid)
         return (verified, messages)
 
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-02-11 17:37 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-02-11 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     f67614b04b13ba636d4b95be353d165bf85f9078
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 13 05:10:32 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 31 03:43:47 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=f67614b0

gkeys/base.py: Remove no longer used code

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

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index cfd3702..8308df8 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -219,8 +219,6 @@ class CliBase(object):
             description='Valid subcommands',
             help='Additional help')
         for name in self.cli_config['Available_Actions']:
-            action_method = getattr(self.cli_config['Actions'],
-                self.cli_config['Action_Map'][name]['func'])
             actiondoc = self.cli_config['Action_Map'][name]['desc']
             try:
                 text = actiondoc.splitlines()[0]


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-02-11 17:37 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-02-11 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     22173b6b70d6c1ba88249cf948801365cb1f64e1
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 31 03:33:59 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 31 04:40:29 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=22173b6b

gkeys/actions.py: separate the message info substitution

It is usually the result.username that gives the error.
This tries to trap it and keep going.

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index dfc9f09..3852372 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -308,10 +308,11 @@ class Actions(object):
                     msg = _unicode("key desired: %(name)s, key added: %(key)s, succeeded:" +\
                         " %(success)s, fingerprint: %(fpr)s")
                     for result in results[key.name]:
-                        try:
-                            print(msg % ({'name': key.name, 'key': result.username,
+                        umsg = msg % ({'name': key.name, 'key': result.username,
                                 'success': str(not result.failed),
-                                'fpr': result.fingerprint}))
+                                'fpr': result.fingerprint})
+                        try:
+                            print(umsg)
                         except UnicodeDecodeError:
                             print(_unicode("UnicodeDecodeError printing results for:"), key.name)
                             self.logger.debug(_unicode("installkey(); UnicodeDecodeError for:") + key.name)


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-02-11 17:37 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-02-11 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     80fbd3d7da1720844103a202809b7583a3f11c7b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 20 05:58:00 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan 31 04:40:29 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=80fbd3d7

gkeys: Wrap all strings which have %s with _unicode() to prevent decode errors

Hopefully this will stop the intermittent python-2.7 UnicodeDecodeError that some people get during string substitution.

---
 gkeys/gkeys/actions.py | 278 ++++++++++++++++++++++++++++++-------------------
 gkeys/gkeys/base.py    |   2 +-
 2 files changed, 172 insertions(+), 108 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index ad03038..16dbb26 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -17,8 +17,10 @@ import sys
 
 if sys.version_info[0] >= 3:
     py_input = input
+    _unicode = str
 else:
     py_input = raw_input
+    _unicode = unicode
 
 
 from collections import defaultdict
@@ -63,7 +65,8 @@ class Actions(object):
         '''Pretty-print the selected seed file'''
         handler = SeedHandler(self.logger, self.config)
         kwargs = handler.build_gkeydict(args)
-        self.logger.debug("ACTIONS: listseed; kwargs: %s" % str(kwargs))
+        self.logger.debug(_unicode("ACTIONS: listseed; kwargs: %s")
+            % _unicode(kwargs))
         if not self.seeds:
             try:
                 self.seeds = handler.load_seeds(args.category, args.nick)
@@ -78,7 +81,8 @@ class Actions(object):
 
     def fetchseed(self, args):
         '''Download the selected seed file(s)'''
-        self.logger.debug("ACTIONS: fetchseed; args: %s" % str(args))
+        self.logger.debug(_unicode("ACTIONS: fetchseed; args: %s")
+            % _unicode(args))
         if not args.category:
             return (False, ["Please specify seeds category."])
         handler = SeedHandler(self.logger, self.config)
@@ -103,7 +107,9 @@ class Actions(object):
             return (False, ["Failed to create a valid GKEY instance.",
                 "Check for invalid data entries"])
         if len(gkeys) == 0:
-            self.logger.debug("ACTIONS: installkey; now adding gkey: %s" % str(gkey))
+            self.logger.debug(
+                _unicode("ACTIONS: installkey; now adding gkey: %s")
+                % _unicode(gkey))
             success = self.seeds.add(getattr(gkey, 'nick'), gkey)
             if success:
                 success = self.seeds.save()
@@ -122,12 +128,14 @@ class Actions(object):
             return (False, ["Failed to remove seed: No gkeys returned from listseed()",
                 []])
         if len(gkeys) == 1:
-            self.logger.debug("ACTIONS: removeseed; now deleting gkey: %s" % str(gkeys))
+            self.logger.debug(
+                _unicode("ACTIONS: removeseed; now deleting gkey: %s")
+                % _unicode(gkeys))
             success = self.seeds.delete(gkeys[0])
             if success:
                 success = self.seeds.save()
-            return (success, ["Successfully removed seed: %s" % str(success),
-                gkeys])
+            return (success, [_unicode("Successfully removed seed: %s")
+                % _unicode(success), gkeys])
         elif len(gkeys):
             return (False, ["Too many seeds found to remove", gkeys])
         return (False, ["Failed to remove seed:", args,
@@ -138,7 +146,8 @@ class Actions(object):
         '''Move keys between seed files'''
         handler = SeedHandler(self.logger, self.config)
         searchkey = handler.new(args, checkgkey=False)
-        self.logger.debug("ACTIONS: moveseed; gkey: %s" % str(searchkey))
+        self.logger.debug(_unicode("ACTIONS: moveseed; gkey: %s")
+            % _unicode(searchkey))
         if not self.seeds:
             self.seeds = self.load_seeds(args.category)
         kwargs = handler.build_gkeydict(args)
@@ -147,17 +156,21 @@ class Actions(object):
         destkeys = dest.list(**kwargs)
         messages = []
         if len(sourcekeys) == 1 and destkeys == []:
-            self.logger.debug("ACTIONS: moveseed; now adding destination gkey: %s"
-                % str(sourcekeys[0]))
+            self.logger.debug(
+                _unicode("ACTIONS: moveseed; now adding destination gkey: %s")
+                % _unicode(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]))
+            self.logger.debug("ACTIONS: moveseed; success: %s" % str(success))
+            self.logger.debug(
+                _unicode("ACTIONS: moveseed; now deleting sourcekey: %s")
+                % _unicode(sourcekeys[0]))
             success = self.seeds.delete(sourcekeys[0])
             if success:
                 success = dest.save()
-                self.logger.debug("ACTIONS: moveseed; destination saved... %s" %str(success))
+                self.logger.debug("ACTIONS: moveseed; destination saved... %s"
+                    % str(success))
                 success = self.seeds.save()
-            messages.extend(["Successfully Moved %s seed: %s"
+            messages.extend([_unicode("Successfully Moved %s seed: %s")
                 % (args.category, str(success)), sourcekeys[0]])
             return (success, messages)
         elif len(sourcekeys):
@@ -182,7 +195,7 @@ class Actions(object):
             args.category = 'gentoo'
         keyring = self.config.get_key('keyring')
         catdir = os.path.join(keyring, args.category)
-        self.logger.debug("ACTIONS: listkey; catdir = %s" % catdir)
+        self.logger.debug(_unicode("ACTIONS: listkey; catdir = %s") % catdir)
         self.gpg = GkeysGPG(self.config, catdir, self.logger)
         handler = SeedHandler(self.logger, self.config)
         if args.keydir:
@@ -241,17 +254,17 @@ class Actions(object):
         if self.config.options['print_results']:
             if print_key:
                 print()
-                print("Nick.....: %s" % key.nick)
-                print("Name.....: %s" % key.name)
-                print("Keydir...: %s" % key.keydir)
+                print(_unicode("Nick.....: %s") % key.nick)
+                print(_unicode("Name.....: %s") % key.name)
+                print(_unicode("Keydir...: %s") % key.keydir)
             c = 0
             for line in result.split('\n'):
                 if c == 0:
-                    print("Gpg info.: %s" % line)
+                    print(_unicode("Gpg info.: %s") % line)
                 else:
-                    print("           %s" % line)
+                    print(_unicode("           %s") % line)
                 c += 1
-            self.logger.debug("data output:\n" + str(result))
+            self.logger.debug(_unicode("data output:\n") + str(result))
         return (True, result)
 
 
@@ -268,16 +281,19 @@ class Actions(object):
                 self.logger.info("ACTIONS: installkey; "
                     "Matching seed entry not found")
                 if args.nick:
-                    return (False, ["Search failed for: %s" % args.nick])
+                    return (False,
+                        [_unicode("Search failed for: %s") % args.nick])
                 elif args.name:
-                    return (False, ["Search failed for: %s" % args.name])
+                    return (False,
+                        [_unicode("Search failed for: %s") % args.name])
                 else:
                     return (False, ["Search failed for search term"])
             # get confirmation
             # fill in code here
             keyring = self.config.get_key('keyring')
             catdir = os.path.join(keyring, args.category)
-            self.logger.debug("ACTIONS: installkey; catdir = %s" % catdir)
+            self.logger.debug(_unicode("ACTIONS: installkey; catdir = %s")
+                % catdir)
             self.gpg = GkeysGPG(self.config, catdir, self.logger)
             results = {}
             failed = []
@@ -289,19 +305,19 @@ class Actions(object):
                     self.logger.debug("ACTIONS: installkey; result.failed = " +
                                       str(result.failed))
                 if self.config.options['print_results']:
-                    msg = "key desired: %(name)s, key added: %(key)s, succeeded:" +\
-                        " %(success)s, fingerprint: %(fpr)s"
+                    msg = _unicode("key desired: %(name)s, key added: %(key)s, succeeded:" +\
+                        " %(success)s, fingerprint: %(fpr)s")
                     for result in results[key.name]:
                         try:
                             print(msg % ({'name': key.name, 'key': result.username,
                                 'success': str(not result.failed),
                                 'fpr': result.fingerprint}))
                         except UnicodeDecodeError:
-                            print("UnicodeDecodeError printing results for:", key.name)
-                            self.logger.debug("installkey(); UnicodeDecodeError for:" + key.name)
-                            self.logger.debug("    result.username...:" + result.username)
-                            self.logger.debug("    result.failed.....:" + result.failed)
-                            self.logger.debug("    result.fingerprint:" + result.fingerprint)
+                            print(_unicode("UnicodeDecodeError printing results for:"), key.name)
+                            self.logger.debug(_unicode("installkey(); UnicodeDecodeError for:") + key.name)
+                            self.logger.debug(_unicode("    result.username...:") + result.username)
+                            self.logger.debug(_unicode("    result.failed.....:") + result.failed)
+                            self.logger.debug(_unicode("    result.fingerprint:") + result.fingerprint)
                         self.logger.debug("stderr_out: " + str(result.stderr_out))
                         if result.failed:
                             failed.append(key)
@@ -318,13 +334,13 @@ class Actions(object):
         Performs basic validity checks on the key(s), checks expiry,
         and presence of a signing sub-key'''
         if not args.category:
-            return (False, ["Please specify seeds category."])
-        self.logger.debug("ACTIONS: checkkey; args: %s" % str(args))
+            return (False, [_unicode("Please specify seeds category.")])
+        self.logger.debug(_unicode("ACTIONS: checkkey; args: %s") % _unicode(args))
         handler = SeedHandler(self.logger, self.config)
         seeds = handler.load_category(args.category)
         keyring = self.config.get_key('keyring')
         catdir = os.path.join(keyring, args.category)
-        self.logger.debug("ACTIONS: checkkey; catdir = %s" % catdir)
+        self.logger.debug(_unicode("ACTIONS: checkkey; catdir = %s") % catdir)
         self.gpg = GkeysGPG(self.config, catdir, self.logger)
         results = {}
         failed = defaultdict(list)
@@ -332,21 +348,27 @@ class Actions(object):
         keyresults = seeds.list(**kwargs)
         self.output('', '\n Checking keys...')
         for gkey in sorted(keyresults):
-            self.logger.info("Checking key %s, %s" % (gkey.nick, gkey.pub_keyid))
+            self.logger.info(_unicode("Checking key %s, %s")
+                % (gkey.nick, gkey.pub_keyid))
             self.output('',
-                "\n  %s, %s: %s" % (gkey.nick, gkey.name, ', '.join(gkey.pub_keyid)) +
-                "\n  ==============================================")
-            self.logger.debug("ACTIONS: checkkey; gkey = %s" % str(gkey))
+                _unicode("\n  %s, %s: %s" % (gkey.nick, gkey.name,
+                _unicode(', ').join(gkey.pub_keyid))) +
+                _unicode("\n  =============================================="))
+            self.logger.debug(_unicode("ACTIONS: checkkey; gkey = %s") % _unicode(gkey))
             for key in gkey.pub_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))
+                    failed['expired'].append(_unicode("%s <%s>: %s")
+                        % (gkey.name, gkey.nick, key))
                 if results[gkey.name].revoked:
-                    failed['revoked'].append("%s <%s>: %s" % (gkey.name, gkey.nick, key))
+                    failed['revoked'].append(_unicode("%s <%s>: %s")
+                        % (gkey.name, gkey.nick, key))
                 if results[gkey.name].invalid:
-                    failed['invalid'].append("%s <%s>: %s" % (gkey.name, gkey.nick, key))
+                    failed['invalid'].append(_unicode("%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))
+                    failed['sign'].append(_unicode("%s <%s>: %s ")
+                        % (gkey.name, gkey.nick, key))
         if failed['expired']:
             self.output([failed['expired']], '\n Expired keys:\n')
         if failed['revoked']:
@@ -367,12 +389,13 @@ class Actions(object):
         '''Check if keys meet specifications requirements'''
         if not args.category:
             return (False, ["Please specify seeds category."])
-        self.logger.debug("ACTIONS: speccheck; args: %s" % str(args))
+        self.logger.debug(_unicode("ACTIONS: speccheck; args: %s")
+            % _unicode(args))
         handler = SeedHandler(self.logger, self.config)
         seeds = handler.load_category(args.category)
         keyring = self.config.get_key('keyring')
         catdir = os.path.join(keyring, args.category)
-        self.logger.debug("ACTIONS: speccheck; catdir = %s" % catdir)
+        self.logger.debug(_unicode("ACTIONS: speccheck; catdir = %s") % catdir)
         self.gpg = GkeysGPG(self.config, catdir, self.logger)
         results = {}
         failed = defaultdict(list)
@@ -380,11 +403,14 @@ class Actions(object):
         keyresults = seeds.list(**kwargs)
         self.output('', '\n Checking keys...')
         for gkey in sorted(keyresults):
-            self.logger.info("Checking key %s, %s" % (gkey.nick, gkey.keys))
+            self.logger.info(_unicode("Checking key %s, %s")
+                % (gkey.nick, gkey.keys))
             self.output('',
-                "\n  %s, %s: %s" % (gkey.nick, gkey.name, ', '.join(gkey.pub_keyid)) +
-                "\n  ==============================================")
-            self.logger.debug("ACTIONS: speccheck; gkey = %s" % str(gkey))
+                _unicode("\n  %s, %s: %s") % (gkey.nick, gkey.name,
+                _unicode(', ').join(gkey.pub_keyid)) +
+                _unicode("\n  =============================================="))
+            self.logger.debug(_unicode("ACTIONS: speccheck; gkey = %s")
+                % _unicode(gkey))
             for key in gkey.keys:
                 results = self.gpg.speccheck(gkey.keydir, key)
                 for g in results:
@@ -417,27 +443,36 @@ class Actions(object):
                                     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))
+                            failed['expired'].append(_unicode("%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))
+                            failed['revoked'].append(_unicode("%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))
+                            failed['invalid'].append(_unicode("%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))
+                                failed['algo'].append(_unicode("%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))
+                                failed['bits'].append(_unicode("%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))
+                            failed['warn'].append(_unicode("%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))
+                        failed['sign'].append(_unicode("%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)
+                        failed['encrypt'].append(_unicode("%s <%s>: %s")
+                            % (gkey.name, gkey.nick, pub_pass['key'].fingerprint))
+                    spec = _unicode("%s <%s>: %s") % (
+                        gkey.name, gkey.nick, pub_pass['key'].fingerprint)
                     for k in ['pub', 'sign']:
                         if pub_pass[k]:
                             pub_pass['final'] = True
@@ -497,11 +532,13 @@ class Actions(object):
             return (False, ["Please provide a nickname or -n *"])
         handler = SeedHandler(self.logger, self.config)
         kwargs = handler.build_gkeydict(args)
-        self.logger.debug("ACTIONS: removekey; kwargs: %s" % str(kwargs))
+        self.logger.debug(_unicode("ACTIONS: removekey; kwargs: %s")
+            % _unicode(kwargs))
         seeds = handler.load_category(args.category)
         messages = []
         if args.nick == '*':
-            self.output([''],'Remove All keys in category: %s' % args.category)
+            self.output([''],_unicode('Remove All keys in category: %s')
+                % _unicode(args.category))
             ans = py_input ("Do you really want to remove ALL of keys?[y/n]: ")
             while ans not in ["yes", "y", "no", "n"]:
                 ans = py_input ("Do you really want to remove ALL keys?[y/n]: ")
@@ -516,15 +553,18 @@ class Actions(object):
         print(keyresults)
         for gkey in sorted(keyresults):
             if kwargs['nick'] != '*' and  kwargs['nick'] not in gkey.nick:
-                messages.append("%s does not seem to be a valid key." % kwargs['nick'])
+                messages.append(_unicode("%s does not seem to be a valid key.")
+                    % _unicode(kwargs['nick']))
                 success = False
             else:
                 self.output(['', [gkey]], '\n Found GKEY seed:')
-                ans = py_input ("Do you really want to remove %s?[y/n]: "
-                                % kwargs['nick'].lower())
+                ans = py_input (
+                    _unicode("Do you really want to remove %s?[y/n]: ")
+                    % _unicode(kwargs['nick'].lower()))
                 while ans not in ["yes", "y", "no", "n"]:
-                    ans = py_input ("Do you really want to remove %s?[y/n]: "
-                                    % kwargs['nick'].lower())
+                    ans = py_input (
+                        _unicode("Do you really want to remove %s?[y/n]: ")
+                        % _unicode(kwargs['nick'].lower()))
                 if ans in ["no", "n"]:
                     messages.append("Key removal aborted... Nothing to be done.")
                 else:
@@ -535,13 +575,14 @@ class Actions(object):
                     keyring = self.config.get_key('keyring')
                     catdir = os.path.join(keyring, args.category)
                     rm_candidate = os.path.join(catdir, gkey.nick)
-                    self.logger.debug("ACTIONS: removekey; catdir = %s" % catdir)
+                    self.logger.debug(_unicode("ACTIONS: removekey; catdir = %s")
+                        % catdir)
                     if args.category:
                         try:
                             rmtree(rm_candidate)
-                            messages.append("Done removing %s key." % kwargs['nick'])
+                            messages.append(_unicode("Done removing %s key.") % kwargs['nick'])
                         except OSError:
-                            messages.append("%s directory does not exist." % rm_candidate)
+                            messages.append(_unicode("%s directory does not exist.") % rm_candidate)
                             success = False
         return (success, messages)
 
@@ -557,18 +598,19 @@ class Actions(object):
             keyring = self.config.get_key('keyring')
             catdir = os.path.join(keyring, args.category)
             keyring_dir = self.config.get_key("keyring")
-            self.logger.debug("ACTIONS: importkey; catdir = %s" % catdir)
+            self.logger.debug(_unicode("ACTIONS: importkey; catdir = %s")
+                % catdir)
             self.gpg = GkeysGPG(self.config, catdir, self.logger)
             success, gkeys = self.listseed(args)[1]
             results = {}
             failed = []
             print("Importing specified keys to keyring.")
             for gkey in gkeys:
-                self.logger.debug("ACTIONS: importkey; adding key: %s", gkey.name)
+                self.logger.debug(_unicode("ACTIONS: importkey; adding key: %s"), gkey.name)
                 results[gkey.name] = self.gpg.add_key(gkey)
                 if self.config.options['print_results']:
-                    msg = "key desired: %(name)s, key added: %(key)s, " + \
-                        "succeeded: %(success)s, fingerprint: %(fpr)s"
+                    msg = _unicode("key desired: %(name)s, key added: %(key)s, " + \
+                        "succeeded: %(success)s, fingerprint: %(fpr)s")
                     for result in results[gkey.name]:
                         print(msg % ({'name': gkey.name, 'key': result.username,
                             'success': str(not result.failed),
@@ -579,8 +621,9 @@ class Actions(object):
                                 + str(result.failed))
                             failed.append(gkey)
                 if not results[gkey.name][0].failed:
-                    print("Importing: %s" % gkey.name)
-                    self.logger.debug("ACTIONS: importkey; importing key: %s"
+                    print(_unicode("Importing: %s") % gkey.name)
+                    self.logger.debug(
+                        _unicode("ACTIONS: importkey; importing key: %s")
                         % gkey.name)
                     _keyring = os.path.join(catdir, args.keyring + '.gpg')
                     self.gpg.add_to_keyring(gkey, catdir, _keyring)
@@ -620,7 +663,7 @@ class Actions(object):
                     for val in list(seed.values()):
                         installed_keys.append(GKEY(**val))
         except OSError:
-            return (False, ["%s directory does not exist." % catdir, ""])
+            return (False, [_unicode("%s directory does not exist.") % catdir, ""])
         return (True, ['Found Key(s):', installed_keys])
 
 
@@ -650,7 +693,8 @@ class Actions(object):
             return (False, ['Please provide a signed file.'])
         if not args.category:
             args.category = self.config.get_key('verify_keyring')
-            self.logger.debug("ACTIONS: verify; keyring category not specified, using default: %s"
+            self.logger.debug(_unicode(
+                "ACTIONS: verify; keyring category not specified, using default: %s")
                 % args.category)
         handler = SeedHandler(self.logger, self.config)
         keys = handler.load_category(args.category)
@@ -659,17 +703,18 @@ class Actions(object):
         key = handler.seeds.nick_search(args.nick)
         if not key:
             if args.nick:
-                messages.append("Failed to find.........: %s in category: %s"
+                messages.append(_unicode(
+                    "Failed to find.........: %s in category: %s")
                     % (args.category, args.nick))
             args.category = self.config.get_key('verify-keyring')
             args.nick = self.config.get_key('verify-nick')
-            messages.append("Using config defaults..: %s %s"
+            messages.append(_unicode("Using config defaults..: %s %s")
                 % (args.category, args.nick))
             return self.verify(args, messages)
 
         keyrings = self.config.get_key('keyring')
         catdir = os.path.join(keyrings, args.category)
-        self.logger.debug("ACTIONS: verify; catdir = %s" % catdir)
+        self.logger.debug(_unicode("ACTIONS: verify; catdir = %s") % catdir)
         self.gpg = GkeysGPG(self.config, catdir, self.logger)
         return self._verify(args, handler, key, messages)
 
@@ -688,8 +733,9 @@ class Actions(object):
             # with download file name
             if not filepath:
                 filepath = url.split('/')[-1]
-                self.logger.debug("ACTIONS: verify; destination filepath was "
-                    "not supplied, using current directory ./%s" % filepath)
+                self.logger.debug(_unicode(
+                    "ACTIONS: verify; destination filepath was "
+                    "not supplied, using current directory ./%s") % filepath)
         if args.timestamp:
             timestamp_path = filepath + ".timestamp"
         if isurl:
@@ -703,15 +749,19 @@ class Actions(object):
                  'kwargs-error': {},
             }
             fetcher = Connector(connector_output, None, "Gentoo Keys")
-            self.logger.debug("ACTIONS: verify; fetching %s signed file " % filepath)
-            self.logger.debug("ACTIONS: verify; timestamp path: %s" % timestamp_path)
-            success, signedfile, timestamp = fetcher.fetch_file(url, filepath, timestamp_path)
+            self.logger.debug(
+                _unicode("ACTIONS: verify; fetching %s signed file ") % filepath)
+            self.logger.debug(
+                _unicode("ACTIONS: verify; timestamp path: %s") % timestamp_path)
+            success, signedfile, timestamp = fetcher.fetch_file(
+                url, filepath, timestamp_path)
         else:
             filepath = os.path.abspath(filepath)
-            self.logger.debug("ACTIONS: verify; local file %s" % filepath)
+            self.logger.debug(
+                _unicode("ACTIONS: verify; local file %s") % filepath)
             success = os.path.isfile(filepath)
         if not success:
-            messages.append("File %s cannot be retrieved." % filepath)
+            messages.append(_unicode("File %s cannot be retrieved.") % filepath)
         else:
             if not signature:
                 EXTENSIONS = ['.sig', '.asc', 'gpg','.gpgsig']
@@ -720,12 +770,16 @@ class Actions(object):
                     sig_path = filepath + ext
                     if isurl:
                         signature = url + ext
-                        self.logger.debug("ACTIONS: verify; fetching %s signature " % signature)
+                        self.logger.debug(
+                            _unicode("ACTIONS: verify; fetching %s signature ")
+                            % signature)
                         success_fetch, sig, timestamp = fetcher.fetch_file(signature, sig_path)
                     else:
                         signature = filepath + ext
                         signature = os.path.abspath(signature)
-                        self.logger.debug("ACTIONS: verify; checking %s signature " % signature)
+                        self.logger.debug(
+                            _unicode("ACTIONS: verify; checking %s signature ")
+                            % signature)
                         success_fetch = os.path.isfile(signature)
                     if success_fetch:
                         break
@@ -738,17 +792,21 @@ class Actions(object):
             (valid, trust) = results.verified
             if valid:
                 verified = True
-                messages.extend(["Verification succeeded.: %s" % (filepath),
-                    "Key info...............: %s <%s>, %s"
+                messages.extend(
+                    [_unicode("Verification succeeded.: %s") % (filepath),
+                    _unicode("Key info...............: %s <%s>, %s")
                     % ( key.name, key.nick, keyid),
-                    "    category, nick.....: %s %s" % (args.category, args.nick)])
+                    _unicode("    category, nick.....: %s %s")
+                    % (args.category, args.nick)])
             else:
-                messages.extend(["Verification failed....: %s" % (filepath),
-                    "Key info...............: %s <%s>, %s"
+                messages.extend(
+                    [_unicode("Verification failed....: %s") % (filepath),
+                    _unicode("Key info...............: %s <%s>, %s")
                     % ( key.name, key.nick, keyid)])
                 has_no_pubkey, s_keyid = results.no_pubkey
                 if has_no_pubkey:
-                    messages.append("Auto-searching for key.: 0x%s" % s_keyid)
+                    messages.append(
+                        _unicode("Auto-searching for key.: 0x%s") % s_keyid)
                     # reset all but keyid and pass thru data
                     args.keyid = s_keyid
                     args.keydir = None
@@ -768,16 +826,16 @@ class Actions(object):
     def listcats(self, args):
         '''List seed file definitions found in the config'''
         seeds = list(self.config.get_key('seeds'))
-        return (True, {"Categories defined: %s\n"
-            % (",  ".join(seeds)): True})
+        return (True, {_unicode("Categories defined: %s\n")
+            % (_unicode(",  ").join(seeds)): True})
 
 
     def listseedfiles(self, args):
         '''List seed files found in the configured seed directory'''
         seedsdir = self.config.get_key('seedsdir')
         seedfile = [f for f in os.listdir(seedsdir) if f[-5:] == 'seeds']
-        return (True, {"Seed files found at path: %s\n  %s"
-            % (seedsdir, "\n  ".join(seedfile)): True})
+        return (True, {_unicode("Seed files found at path: %s\n  %s")
+            % (seedsdir, _unicode("\n  ").join(seedfile)): True})
 
 
     def sign(self, args):
@@ -803,7 +861,7 @@ class Actions(object):
 
         self.config.options['gpg_defaults'] = ['--status-fd', '2']
 
-        self.logger.debug("ACTIONS: sign; keydir = %s" % keydir)
+        self.logger.debug(_unicode("ACTIONS: sign; keydir = %s") % keydir)
 
         self.gpg = GkeysGPG(self.config, basedir, self.logger)
         self.gpg.set_keydir(keydir, task)
@@ -816,14 +874,16 @@ class Actions(object):
             verified, trust = results.verified
             if not results.verified[0]:
                 msgs.extend(
-                    ['Failed Signature for %s verified: %s, trust: %s'
-                        % (fname, verified, trust), 'GPG output:', "\n".join(results.stderr_out)]
+                    [_unicode('Failed Signature for %s verified: %s, trust: %s')
+                        % (fname, verified, trust),
+                        _unicode('GPG output:', "\n").join(results.stderr_out)]
                 )
                 success.append(False)
             else:
                 msgs.extend(
-                    ['Signature result for: %s -- verified: %s, trust: %s'
-                        % (fname, verified, trust)] #, 'GPG output:', "\n".join(results.stderr_out)]
+                    [_unicode(
+                    'Signature result for: %s -- verified: %s, trust: %s')
+                    % (fname, verified, trust)] #, 'GPG output:', "\n".join(results.stderr_out)]
                 )
                 success.append(True)
         return (False not in success, ['', msgs])
@@ -834,22 +894,26 @@ class Actions(object):
         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))
+        self.logger.debug(_unicode("ACTIONS: refreshkey; args: %s")
+            % _unicode(args))
         handler = SeedHandler(self.logger, self.config)
         seeds = handler.load_category(args.category, refresh=True)
         keyring = self.config.get_key('keyring')
         catdir = os.path.join(keyring, args.category)
-        self.logger.debug("ACTIONS: refreshkey; catdir = %s" % catdir)
+        self.logger.debug(_unicode("ACTIONS: refreshkey; catdir = %s") % catdir)
         self.gpg = GkeysGPG(self.config, catdir, self.logger)
         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.pub_keyid))
-            self.output('', "  %s: %s" % (gkey.name, ', '.join(gkey.pub_keyid)))
+            self.logger.info(_unicode("Refreshig key %s, %s")
+                % (gkey.nick, gkey.pub_keyid))
+            self.output('', _unicode("  %s: %s")
+                % (gkey.name, ', '.join(gkey.pub_keyid)))
             #self.output('', "  ===============")
-            self.logger.debug("ACTIONS: refreshkey; gkey = %s" % str(gkey))
+            self.logger.debug(_unicode("ACTIONS: refreshkey; gkey = %s")
+                % _unicode(gkey))
             results[gkey.keydir] = self.gpg.refresh_key(gkey)
         return (True, ['Completed'])
 
@@ -885,7 +949,7 @@ class Actions(object):
             return keys
         msgs = []
         for cat in list(keys):
-            msgs.append("Category.....: %s" % cat)
+            msgs.append(_unicode("Category.....: %s") % cat)
             msgs.append(keys[cat])
         del keys, cat
         return (True, msgs)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 8308df8..08bfe5f 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -324,7 +324,7 @@ class CliBase(object):
                 print('   ', msg)
             else:
                 try:
-                    print("\n".join([x.pretty_print for x in msg]))
+                    print(unicode("\n").join([x.pretty_print for x in msg]))
                 except AttributeError:
                     for x in msg:
                         print('    ', x)


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-09 21:07 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-09 21:07 UTC (permalink / raw
  To: gentoo-commits

commit:     622f59e420f92062cc093b6ba540a15f03e56358
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  9 05:57:34 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Jan  9 06:07:44 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=622f59e4

gkeys/actions.py: Partially update removekey()

The removal code is completely wrong if there are multiple keys installed in one keyring.
Everything below my comments needs a complete re-do.
Disabling the remove-key action until refactored.

---
 gkeys/gkeys/action_map.py |  2 +-
 gkeys/gkeys/actions.py    | 37 ++++++++++++++++++++++++++++---------
 2 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/gkeys/gkeys/action_map.py b/gkeys/gkeys/action_map.py
index fc5bfb0..b9224ea 100644
--- a/gkeys/gkeys/action_map.py
+++ b/gkeys/gkeys/action_map.py
@@ -18,7 +18,7 @@ Seed_Actions = ['----seeds----', 'add-seed', 'fetch-seed',
     'list-seed', 'list-seedfiles', 'remove-seed']
 
 Key_Actions = ['----keys-----', 'check-key', 'installed',
-    'install-key', 'list-key', 'refresh-key', 'remove-key',
+    'install-key', 'list-key', 'refresh-key',
     'search-key', 'spec-check']
 
 General_Actions = ['---general---', 'list-cats', 'sign','verify']

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 59929cd..23c71fc 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -491,21 +491,40 @@ class Actions(object):
         handler = SeedHandler(self.logger, self.config)
         kwargs = handler.build_gkeydict(args)
         self.logger.debug("ACTIONS: removekey; kwargs: %s" % str(kwargs))
-        success, 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']]
+        seeds = handler.load_category(args.category)
+        messages = []
+        if args.nick == '*':
+            self.output([''],'Remove All keys in category: %s' % args.category)
+            ans = py_input ("Do you really want to remove ALL of keys?[y/n]: ")
+            while ans not in ["yes", "y", "no", "n"]:
+                ans = py_input ("Do you really want to remove ALL keys?[y/n]: ")
+            if ans in ["no", "n"]:
+                messages.append("Key removal aborted... Nothing to be done.")
+                return (True, messages)
+            keyresults = seeds.seeds
+        else:
+            keyresults = seeds.list(**kwargs)
+        self.output('', '\n Removing keys...')
+        success = True
+        print(keyresults)
+        for gkey in sorted(keyresults):
+            if kwargs['nick'] != '*' and  kwargs['nick'] not in gkey.nick:
+                messages.append("%s does not seem to be a valid key." % kwargs['nick'])
                 success = False
             else:
                 self.output(['', [gkey]], '\n Found GKEY seed:')
                 ans = py_input ("Do you really want to remove %s?[y/n]: "
-                                % kwargs['nick']).lower()
+                                % kwargs['nick'].lower())
                 while ans not in ["yes", "y", "no", "n"]:
                     ans = py_input ("Do you really want to remove %s?[y/n]: "
-                                    % kwargs['nick']).lower()
+                                    % kwargs['nick'].lower())
                 if ans in ["no", "n"]:
-                    messages = ["Key removal aborted... Nothing to be done."]
+                    messages.append("Key removal aborted... Nothing to be done.")
                 else:
+                    ## This next code is total crap  now
+                    ## re-write it from scratch
+                    ## there could be multiple keys installed in one keyring
+                    ## this code just rm's everything.
                     keyring = self.config.get_key('keyring')
                     catdir = os.path.join(keyring, args.category)
                     rm_candidate = os.path.join(catdir, gkey.nick)
@@ -513,9 +532,9 @@ class Actions(object):
                     if args.category:
                         try:
                             rmtree(rm_candidate)
-                            messages = ["Done removing %s key." % kwargs['nick']]
+                            messages.append("Done removing %s key." % kwargs['nick'])
                         except OSError:
-                            messages = ["%s directory does not exist." % rm_candidate]
+                            messages.append("%s directory does not exist." % rm_candidate)
                             success = False
         return (success, messages)
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-09 21:07 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-09 21:07 UTC (permalink / raw
  To: gentoo-commits

commit:     4db4657c83e471e65ec60ee4a26a9b2d8eda2838
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  9 03:03:32 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Jan  9 06:07:44 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=4db4657c

gkeys/seed.py: Rename search() to regex_search()

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

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index f92d910..262ba57 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -173,7 +173,7 @@ class Seeds(object):
         return sorted(result.values())
 
 
-    def search(self, pattern):
+    def regex_search(self, pattern):
         '''Search for the keys matching the regular expression pattern'''
         pass
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-09 21:07 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-09 21:07 UTC (permalink / raw
  To: gentoo-commits

commit:     b547e16c7e047d9fd9ac7d9536678cf9102c2b16
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  8 20:42:20 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan  8 21:05:22 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=b547e16c

Revert "gkeys: Finally fix all the unicode printing errors"

This reverts commit b7f9364cb0952f2e06f94299400d2f23b629553d.
It totally broke py-3 comaptibility!

---
 gkeys/gkeys/actions.py | 20 +++++++++-----------
 gkeys/gkeys/base.py    | 10 +++++-----
 2 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 4db3757..9d57870 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -25,8 +25,6 @@ from collections import defaultdict
 from json import load
 from shutil import rmtree
 
-from pyGPG.status import _unicode_encode
-
 from gkeys.lib import GkeysGPG
 from gkeys.seedhandler import SeedHandler
 from gkeys.gkey import GKEY
@@ -243,15 +241,15 @@ class Actions(object):
         if self.config.options['print_results']:
             if print_key:
                 print()
-                print("Nick.....:", _unicode_encode(key.nick))
-                print("Name.....:", _unicode_encode(key.name))
-                print("Keydir...:", _unicode_encode(key.keydir))
+                print("Nick.....:", key.nick)
+                print("Name.....:", key.name)
+                print("Keydir...:", key.keydir)
             c = 0
             for line in result.split('\n'):
                 if c == 0:
-                    print("Gpg info.:", _unicode_encode(line))
+                    print("Gpg info.:", line)
                 else:
-                    print("          ", _unicode_encode(line))
+                    print("          ", line)
                 c += 1
             self.logger.debug("data output:\n" + str(result))
         return (True, result)
@@ -292,7 +290,7 @@ class Actions(object):
                                       str(result.failed))
                 if self.config.options['print_results']:
                     for result in results[key.name]:
-                        print("key desired:", _unicode_encode(key.name), ", key added:",
+                        print("key desired:", key.name, ", key added:",
                             result.username, ", succeeded:",
                             not result.failed, ", fingerprint:", result.fingerprint)
                         self.logger.debug("stderr_out: " + str(result.stderr_out))
@@ -383,7 +381,7 @@ class Actions(object):
                 for g in results:
                     pub_pass = {}
                     for key in results[g]:
-                        self.output('', _unicode_encode(key.pretty_print()))
+                        self.output('', key.pretty_print())
 
                         if key.key is "PUB":
                             pub_pass = {
@@ -542,7 +540,7 @@ class Actions(object):
                 results[gkey.name] = self.gpg.add_key(gkey)
                 if self.config.options['print_results']:
                     for result in results[gkey.name]:
-                        print("key desired:", _unicode_encode(gkey.name), ", key added:",
+                        print("key desired:", gkey.name, ", key added:",
                             result.username, ", succeeded:",
                             not result.failed, ", fingerprint:", result.fingerprint)
                         self.logger.debug("stderr_out: " + str(result.stderr_out))
@@ -550,7 +548,7 @@ class Actions(object):
                             self.logger.debug("ACTIONS: importkey; result.failed = " + str(result.failed))
                             failed.append(gkey)
                 if not results[gkey.name][0].failed:
-                    print("Importing: ", _unicode_encode(gkey.name))
+                    print("Importing: ", gkey.name)
                     self.logger.debug("ACTIONS: importkey; importing key: %s", gkey.name)
                     _keyring = os.path.join(catdir, args.keyring + '.gpg')
                     self.gpg.add_to_keyring(gkey, catdir, _keyring)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 1a80a03..46f8f2f 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -17,7 +17,7 @@ from __future__ import print_function
 import argparse
 import sys
 
-from pyGPG.status import _unicode_encode
+from pyGPG.status import _unicode_decode
 from gkeys import fileops
 from gkeys.log import log_levels, set_logger
 
@@ -315,16 +315,16 @@ class CliBase(object):
     def output_results(results, header=None):
         # super simple output for the time being
         if header:
-            print(_unicode_encode(header))
+            print(_unicode_decode(header))
         for msg in results:
             if type(msg) in [str, unicode]:
-                print('   ', _unicode_encode(msg))
+                print('   ', _unicode_decode(msg))
             else:
                 try:
-                    print("\n".join([_unicode_encode(x.pretty_print) for x in msg]))
+                    print("\n".join([_unicode_decode(x.pretty_print) for x in msg]))
                 except AttributeError:
                     for x in msg:
-                        print('    ', _unicode_encode(x))
+                        print('    ', _unicode_decode(x))
         print()
 
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-09 21:07 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-09 21:07 UTC (permalink / raw
  To: gentoo-commits

commit:     5c4b8d7eceee333f803941f40d2cc757ecf5f80b
Author:     Pavlos Ratis <dastergon <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  8 17:08:51 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan  8 17:08:51 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=5c4b8d7e

add checks to fetch-seed in case of missing category

Added a check about categories in fetch-seed
action because it failed when the command ran without a category

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index eef338e..4db3757 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -81,9 +81,10 @@ class Actions(object):
     def fetchseed(self, args):
         '''Download the selected seed file(s)'''
         self.logger.debug("ACTIONS: fetchseed; args: %s" % str(args))
+        if not args.category:
+            return (False, ["Please specify seeds category."])
         handler = SeedHandler(self.logger, self.config)
         success, messages = handler.fetch_seeds(args.category, args, self.verify)
-
         messages.append("")
         messages.append("Fetch operation completed")
         return (False not in success, messages)

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 600ac35..5f15222 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -142,10 +142,10 @@ class SeedHandler(object):
             for seed in [seeds]:
                 seedurl = self.config.get_key('seedurls', seed)
                 seedpath = self.config.get_key('seeds', seed)
-                if http_check.match(seedurl):
+                if seedurl and seedpath and http_check.match(seedurl):
                     urls.extend([(seed, seedurl, seedpath)])
                 else:
-                    self.logger.info("Wrong seed file URLs... Skipping: %s" % seed)
+                    self.logger.info("Wrong seed file URLs/seed path... Skipping: %s" % seed)
         except KeyError:
             pass
         succeeded = []


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-09 21:07 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-09 21:07 UTC (permalink / raw
  To: gentoo-commits

commit:     aa3b192bfc5cf981fde0cc1476367cba556796ec
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  9 03:02:58 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Jan  9 06:07:44 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=aa3b192b

gkeys/seed.py: Update field_search() docstring

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

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index 2f6e72a..f92d910 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -191,9 +191,11 @@ class Seeds(object):
 
 
     def field_search(self, field, value, exact=False):
-        '''Searches the seeds for a matching nick
+        '''Searches the seeds for a matching value
 
-        @param keyid: string
+        @param field: string
+        @param value: string
+        @param exact: Boolean
         @returns GKEY instance or None
         '''
         results = []


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-09 21:07 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-09 21:07 UTC (permalink / raw
  To: gentoo-commits

commit:     c4dfd5ac664f6afec52a77ab911c2130e028e402
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  8 21:51:52 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Fri Jan  9 06:07:29 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=c4dfd5ac

gkeys: Fix seed file loading, saving unicode issues

Fix unicode cli args issues.

---
 gkeys/gkeys/actions.py     | 36 +++++++++++++++++++++---------------
 gkeys/gkeys/seed.py        | 28 +++++++++++++++++++++-------
 gkeys/gkeys/seedhandler.py |  6 +++---
 3 files changed, 45 insertions(+), 25 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 9d57870..59929cd 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -241,15 +241,15 @@ class Actions(object):
         if self.config.options['print_results']:
             if print_key:
                 print()
-                print("Nick.....:", key.nick)
-                print("Name.....:", key.name)
-                print("Keydir...:", key.keydir)
+                print("Nick.....: %s" % key.nick)
+                print("Name.....: %s" % key.name)
+                print("Keydir...: %s" % key.keydir)
             c = 0
             for line in result.split('\n'):
                 if c == 0:
-                    print("Gpg info.:", line)
+                    print("Gpg info.: %s" % line)
                 else:
-                    print("          ", line)
+                    print("           %s" % line)
                 c += 1
             self.logger.debug("data output:\n" + str(result))
         return (True, result)
@@ -289,10 +289,12 @@ class Actions(object):
                     self.logger.debug("ACTIONS: installkey; result.failed = " +
                                       str(result.failed))
                 if self.config.options['print_results']:
+                    msg = "key desired: %(name)s, key added: %(key)s, succeeded:" +\
+                        " %(success)s, fingerprint: %(fpr)s"
                     for result in results[key.name]:
-                        print("key desired:", key.name, ", key added:",
-                            result.username, ", succeeded:",
-                            not result.failed, ", fingerprint:", result.fingerprint)
+                        print(msg % ({'name': key.name, 'key': result.username,
+                            'success': not result.failed,
+                            'fpr': result.fingerprint}))
                         self.logger.debug("stderr_out: " + str(result.stderr_out))
                         if result.failed:
                             failed.append(key)
@@ -488,7 +490,7 @@ class Actions(object):
             return (False, ["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))
+        self.logger.debug("ACTIONS: removekey; kwargs: %s" % str(kwargs))
         success, installed_keys = self.installed(args)[1]
         for gkey in installed_keys:
             if kwargs['nick'] not in gkey.nick:
@@ -539,17 +541,21 @@ class Actions(object):
                 self.logger.debug("ACTIONS: importkey; adding key: %s", gkey.name)
                 results[gkey.name] = self.gpg.add_key(gkey)
                 if self.config.options['print_results']:
+                    msg = "key desired: %(name)s, key added: %(key)s, " + \
+                        "succeeded: %(success)s, fingerprint: %(fpr)s"
                     for result in results[gkey.name]:
-                        print("key desired:", gkey.name, ", key added:",
-                            result.username, ", succeeded:",
-                            not result.failed, ", fingerprint:", result.fingerprint)
+                        print(msg % ({'name': gkey.name, 'key': result.username,
+                            'success': not result.failed,
+                            'fpr': result.fingerprint}))
                         self.logger.debug("stderr_out: " + str(result.stderr_out))
                         if result.failed:
-                            self.logger.debug("ACTIONS: importkey; result.failed = " + str(result.failed))
+                            self.logger.debug("ACTIONS: importkey; result.failed = "
+                                + str(result.failed))
                             failed.append(gkey)
                 if not results[gkey.name][0].failed:
-                    print("Importing: ", gkey.name)
-                    self.logger.debug("ACTIONS: importkey; importing key: %s", gkey.name)
+                    print("Importing: %s" % gkey.name)
+                    self.logger.debug("ACTIONS: importkey; importing key: %s"
+                        % gkey.name)
                     _keyring = os.path.join(catdir, args.keyring + '.gpg')
                     self.gpg.add_to_keyring(gkey, catdir, _keyring)
             if failed and self.output:

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index 40bdd46..2f6e72a 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -16,8 +16,10 @@ with gentoo-keys specific convienience functions.
 
 '''
 
+import codecs
 import json
 import os
+import sys
 
 from gkeys.exception import UpdateDbError
 from gkeys.log import logger
@@ -25,6 +27,14 @@ from gkeys.gkey import GKEY
 from gkeys.fileops import ensure_dirs
 
 
+if sys.version_info[0] >= 3:
+    def decoder(text, enc='utf_8'):
+        return text
+else:
+    def decoder(text, enc='utf_8'):
+        return codecs.decode(text, enc)
+
+
 class Seeds(object):
     '''Handles all seed key file operations'''
 
@@ -51,7 +61,7 @@ class Seeds(object):
         seedlines = None
         self.seeds = {}
         try:
-            with open(self.filename, "r+") as seedfile:
+            with codecs.open(self.filename, "r+", encoding='utf_8') as seedfile:
                 seedlines = json.load(seedfile)
         except IOError as err:
             self.logger.debug("Seed: load; IOError occurred while loading file")
@@ -94,7 +104,7 @@ class Seeds(object):
             fatal=True)
         os.umask(int(self.config.get_key("permissions", "files"),0))
         try:
-            with open(self.filename, 'w') as seedfile:
+            with codecs.open(self.filename, 'w', encoding='utf_8') as seedfile:
                 seedfile.write(self._seeds2json(self.seeds))
                 seedfile.write("\n")
         except IOError as err:
@@ -156,7 +166,10 @@ class Seeds(object):
                             break
                 result = res
             else:
-                result = {dev: gkey for dev, gkey in list(result.items()) if kwargs[key].lower() in getattr(gkey, key).lower()}
+                result = {dev: gkey for dev, gkey in list(result.items())
+                    if kwargs[key].lower()
+                    in getattr(gkey, key).lower()
+                    }
         return sorted(result.values())
 
 
@@ -193,10 +206,10 @@ class Seeds(object):
                 if  self._list_search(value, val, exact):
                     results.append(seed)
             elif exact:
-                if value in val:
+                if decoder(value) in val:
                     results.append(seed)
             else:
-                if value.lower() in val.lower():
+                if decoder(value).lower() in val.lower():
                     results.append(seed)
 
         return results
@@ -209,11 +222,12 @@ class Seeds(object):
                 found.append(self._list_search(f, values, exact))
             return True in found
         for val in values:
+            val = val
             if exact:
-                if find in val:
+                if decoder(find) in val:
                     return True
             else:
-                if find.lower() in val.lower():
+                if decoder(find).lower() in val.lower():
                     return True
         return False
 

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 5f15222..adf9507 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -16,7 +16,7 @@ from json import load
 
 from gkeys.exception import UpdateDbError
 from gkeys.gkey import GKEY
-from gkeys.seed import Seeds
+from gkeys.seed import Seeds, decoder
 from gkeys.fileops import ensure_dirs
 
 
@@ -51,10 +51,10 @@ class SeedHandler(object):
         for attr in GKEY._fields:
             try:
                 value = getattr(args, attr)
-                if attr == 'name' and value:
+                if attr == 'name' and isinstance(value, list):
                     value = " ".join(value)
                 if value is not None:
-                    keyinfo[attr] = value
+                    keyinfo[attr] = decoder(value)
             except AttributeError:
                 pass
         return keyinfo


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-09 21:07 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-09 21:07 UTC (permalink / raw
  To: gentoo-commits

commit:     e493576420d6396481cd5e74ddfc29d20946df32
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  8 21:07:47 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan  8 21:07:47 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=e4935764

Revert "gkeys/base.py: Wrap all output with _unicode_decode()"

This reverts commit d947f8fc4b5d91f1655e1f7770a0f94cbb6a52a9.

---
 gkeys/gkeys/base.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 46f8f2f..7e28b90 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -17,7 +17,6 @@ from __future__ import print_function
 import argparse
 import sys
 
-from pyGPG.status import _unicode_decode
 from gkeys import fileops
 from gkeys.log import log_levels, set_logger
 
@@ -315,16 +314,16 @@ class CliBase(object):
     def output_results(results, header=None):
         # super simple output for the time being
         if header:
-            print(_unicode_decode(header))
+            print(header)
         for msg in results:
             if type(msg) in [str, unicode]:
-                print('   ', _unicode_decode(msg))
+                print('   ', msg)
             else:
                 try:
-                    print("\n".join([_unicode_decode(x.pretty_print) for x in msg]))
+                    print("\n".join([x.pretty_print for x in msg]))
                 except AttributeError:
                     for x in msg:
-                        print('    ', _unicode_decode(x))
+                        print('    ', x)
         print()
 
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-08  4:13 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-08  4:13 UTC (permalink / raw
  To: gentoo-commits

commit:     b7f9364cb0952f2e06f94299400d2f23b629553d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  8 03:43:10 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan  8 03:43:10 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=b7f9364c

gkeys: Finally fix all the unicode printing errors

---
 gkeys/gkeys/actions.py | 20 +++++++++++---------
 gkeys/gkeys/base.py    | 10 +++++-----
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index de72000..eef338e 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -25,6 +25,8 @@ from collections import defaultdict
 from json import load
 from shutil import rmtree
 
+from pyGPG.status import _unicode_encode
+
 from gkeys.lib import GkeysGPG
 from gkeys.seedhandler import SeedHandler
 from gkeys.gkey import GKEY
@@ -240,15 +242,15 @@ class Actions(object):
         if self.config.options['print_results']:
             if print_key:
                 print()
-                print("Nick.....:", key.nick)
-                print("Name.....:", key.name)
-                print("Keydir...:", key.keydir)
+                print("Nick.....:", _unicode_encode(key.nick))
+                print("Name.....:", _unicode_encode(key.name))
+                print("Keydir...:", _unicode_encode(key.keydir))
             c = 0
             for line in result.split('\n'):
                 if c == 0:
-                    print("Gpg info.:", line)
+                    print("Gpg info.:", _unicode_encode(line))
                 else:
-                    print("          ", line)
+                    print("          ", _unicode_encode(line))
                 c += 1
             self.logger.debug("data output:\n" + str(result))
         return (True, result)
@@ -289,7 +291,7 @@ class Actions(object):
                                       str(result.failed))
                 if self.config.options['print_results']:
                     for result in results[key.name]:
-                        print("key desired:", key.name, ", key added:",
+                        print("key desired:", _unicode_encode(key.name), ", key added:",
                             result.username, ", succeeded:",
                             not result.failed, ", fingerprint:", result.fingerprint)
                         self.logger.debug("stderr_out: " + str(result.stderr_out))
@@ -380,7 +382,7 @@ class Actions(object):
                 for g in results:
                     pub_pass = {}
                     for key in results[g]:
-                        self.output('', key.pretty_print())
+                        self.output('', _unicode_encode(key.pretty_print()))
 
                         if key.key is "PUB":
                             pub_pass = {
@@ -539,7 +541,7 @@ class Actions(object):
                 results[gkey.name] = self.gpg.add_key(gkey)
                 if self.config.options['print_results']:
                     for result in results[gkey.name]:
-                        print("key desired:", gkey.name, ", key added:",
+                        print("key desired:", _unicode_encode(gkey.name), ", key added:",
                             result.username, ", succeeded:",
                             not result.failed, ", fingerprint:", result.fingerprint)
                         self.logger.debug("stderr_out: " + str(result.stderr_out))
@@ -547,7 +549,7 @@ class Actions(object):
                             self.logger.debug("ACTIONS: importkey; result.failed = " + str(result.failed))
                             failed.append(gkey)
                 if not results[gkey.name][0].failed:
-                    print("Importing: ", gkey.name)
+                    print("Importing: ", _unicode_encode(gkey.name))
                     self.logger.debug("ACTIONS: importkey; importing key: %s", gkey.name)
                     _keyring = os.path.join(catdir, args.keyring + '.gpg')
                     self.gpg.add_to_keyring(gkey, catdir, _keyring)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 46f8f2f..1a80a03 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -17,7 +17,7 @@ from __future__ import print_function
 import argparse
 import sys
 
-from pyGPG.status import _unicode_decode
+from pyGPG.status import _unicode_encode
 from gkeys import fileops
 from gkeys.log import log_levels, set_logger
 
@@ -315,16 +315,16 @@ class CliBase(object):
     def output_results(results, header=None):
         # super simple output for the time being
         if header:
-            print(_unicode_decode(header))
+            print(_unicode_encode(header))
         for msg in results:
             if type(msg) in [str, unicode]:
-                print('   ', _unicode_decode(msg))
+                print('   ', _unicode_encode(msg))
             else:
                 try:
-                    print("\n".join([_unicode_decode(x.pretty_print) for x in msg]))
+                    print("\n".join([_unicode_encode(x.pretty_print) for x in msg]))
                 except AttributeError:
                     for x in msg:
-                        print('    ', _unicode_decode(x))
+                        print('    ', _unicode_encode(x))
         print()
 
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-07 23:39 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-07 23:39 UTC (permalink / raw
  To: gentoo-commits

commit:     d947f8fc4b5d91f1655e1f7770a0f94cbb6a52a9
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Jan  7 23:33:54 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Jan  7 23:33:54 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=d947f8fc

gkeys/base.py: Wrap all output with _unicode_decode()

Kristian was still getting py-2.7 errors for some devs due to unicode.

---
 gkeys/gkeys/base.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 05946c2..65ad9cc 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -17,6 +17,7 @@ from __future__ import print_function
 import argparse
 import sys
 
+from pyGPG.status import _unicode_decode
 from gkeys import fileops
 from gkeys.log import log_levels, set_logger
 
@@ -311,16 +312,16 @@ class CliBase(object):
     def output_results(results, header=None):
         # super simple output for the time being
         if header:
-            print(header)
+            print(_unicode_decode(header))
         for msg in results:
             if type(msg) in [str, unicode]:
-                print('   ', msg)
+                print('   ', _unicode_decode(msg))
             else:
                 try:
-                    print("\n".join([x.pretty_print for x in msg]))
+                    print("\n".join([_unicode_decode(x.pretty_print) for x in msg]))
                 except AttributeError:
                     for x in msg:
-                        print('    ', x)
+                        print('    ', _unicode_decode(x))
         print()
 
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-05 23:12 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-05 23:12 UTC (permalink / raw
  To: gentoo-commits

commit:     37bdded9136d9417baaa89409ca1f606411932c6
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  5 06:37:31 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Jan  5 22:21:53 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=37bdded9

gkeys/seed.py: Fix logic errors in _seeds2json

The original code did not correctly handle a mix of dictionary and GKEY values.

---
 gkeys/gkeys/seed.py | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index a84003d..40bdd46 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -229,13 +229,10 @@ class Seeds(object):
 
 
     def _seeds2json(self, seeds):
-        is_gkey = False
         if not seeds:
             seeds = {}
-        elif isinstance(list(seeds.values())[0], GKEY):
-            is_gkey = True
         for dev, value in list(seeds.items()):
-            if is_gkey:
+            if isinstance(value, GKEY):
                 seeds[dev] = dict(value._asdict())
         return json.dumps(seeds, sort_keys=True, indent=4)
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-05 23:12 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-05 23:12 UTC (permalink / raw
  To: gentoo-commits

commit:     f1a04cad4ddbb944a1c8fba4084f12e64f2c4286
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  3 18:10:01 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Jan  5 22:14:35 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=f1a04cad

gkeys/__init__.py: Add Gkeys_Map for man page creation

---
 gkeys/gkeys/__init__.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/gkeys/gkeys/__init__.py b/gkeys/gkeys/__init__.py
index 7e8b64e..d5a659e 100644
--- a/gkeys/gkeys/__init__.py
+++ b/gkeys/gkeys/__init__.py
@@ -1,5 +1,27 @@
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
 
+
+
+from collections import OrderedDict
+
+from gkeys.actions import Action_Map, Available_Actions
+
+
 __version__ = 'Git'
 __license__ = 'GPLv2'
+
+
+subdata = OrderedDict()
+for cmd in Available_Actions:
+    subdata[cmd] = Action_Map[cmd]['desc']
+
+Gkeys_Map = {
+    'options': ['help', 'config', 'debug'],
+    'desc': 'OpenPGP/GPG key management tool',
+    'long_desc': '''Gentoo Keys (gkeys) is a Python based project that aims to manage
+the GPG keys used for validation on users and Gentoo's infrastracutre servers.
+Gentoo Keys is able to verify GPG keys used for Gentoo's release media,
+such as installation CD's, Live DVD's, packages and other GPG signed documents.''',
+    'sub-cmds': subdata,
+}


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-05 23:12 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-05 23:12 UTC (permalink / raw
  To: gentoo-commits

commit:     5217031811549514076e29f4e349fdec68042ad3
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  5 00:52:29 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Jan  5 22:15:18 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=52170318

gkeys/seed.py: Downgrade logger.error msgs to debug if trap_errors is set True

Go direct to logger.debug()
gkeys/lib.py: Silence error noise for a new key install

---
 gkeys/gkeys/lib.py  |  2 +-
 gkeys/gkeys/seed.py | 12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index 6020322..4ae534d 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -134,7 +134,7 @@ class GkeysGPG(GPG):
         self.logger.debug("LIB: add_key; ensure dirs: " + self.keydir)
         mode = int(self.config.get_key('permissions', 'directories'),0)
         ensure_dirs(str(self.keydir), mode=mode)
-        self.set_keyseedfile(trap_errors=False)
+        self.set_keyseedfile(trap_errors=True)
         results = []
         for fingerprint in gkey.keys:
             self.logger.debug("LIB: add_key; adding fingerprint " + fingerprint)

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index 7d9ae4e..a84003d 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -56,6 +56,8 @@ class Seeds(object):
         except IOError as err:
             self.logger.debug("Seed: load; IOError occurred while loading file")
             if trap_errors:
+                self.logger.debug("Seed: load; %s" % str(err))
+            else:
                 self._error(err)
             return False
         for seed in list(seedlines.items()):
@@ -216,10 +218,14 @@ class Seeds(object):
         return False
 
 
-    def _error(self, err):
+    def _error(self, err, debug=False):
         '''Class error logging function'''
-        self.logger.error("Seed: Error processing seed file %s" % self.filename)
-        self.logger.error("Seed: Error was: %s" % str(err))
+        if debug:
+            self.logger.debug("Seed: Error processing seed file %s" % self.filename)
+            self.logger.debug("Seed: Error was: %s" % str(err))
+        else:
+            self.logger.error("Seed: Error processing seed file %s" % self.filename)
+            self.logger.error("Seed: Error was: %s" % str(err))
 
 
     def _seeds2json(self, seeds):


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-05 23:12 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-05 23:12 UTC (permalink / raw
  To: gentoo-commits

commit:     5e145f0ca54de6547e797ef99093abd19116f592
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  5 00:58:12 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Jan  5 22:15:18 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=5e145f0c

gkeys/actions.py: moveseed() Fix SeedHandler intialization

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 9986adc..de72000 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -135,8 +135,8 @@ class Actions(object):
 
     def moveseed(self, args):
         '''Move keys between seed files'''
-        handler = SeedHandler(self.logger)
-        searchkey = handler.new(args, needkeyid=False, checkintegrity=False)
+        handler = SeedHandler(self.logger, self.config)
+        searchkey = handler.new(args, checkgkey=False)
         self.logger.debug("ACTIONS: moveseed; gkey: %s" % str(searchkey))
         if not self.seeds:
             self.seeds = self.load_seeds(args.category)


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-05 23:12 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-05 23:12 UTC (permalink / raw
  To: gentoo-commits

commit:     6c03a58c9d7563031c17eecada9c141f9dd88b72
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  3 23:16:55 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Jan  5 22:14:35 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=6c03a58c

gkeys/actions.py: Remove import-key from Available_actions

This functions is totally untested so far, especially with all hte changes since it was first roughed in.

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index e6a9bcd..6f8fa11 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -34,7 +34,7 @@ from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn
 Seed_Actions = ['----seeds----', 'add-seed', 'fetch-seed',
     'list-seed', 'list-seedfiles', 'move-seed', 'remove-seed']
 
-Key_Actions = ['----keys-----', 'check-key', 'import-key', 'installed',
+Key_Actions = ['----keys-----', 'check-key', 'installed',
     'install-key', 'list-key', 'move-key', 'refresh-key', 'remove-key',
     'search-key', 'spec-check']
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-05 23:12 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-05 23:12 UTC (permalink / raw
  To: gentoo-commits

commit:     f23732405a485b7a1863c3f644ae254d7c95dd2d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  3 18:08:19 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan  3 18:21:23 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=f2373240

gkeys/actions.py: Fix mis-sorted Key_Actions

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index c212609..e6a9bcd 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -35,8 +35,8 @@ Seed_Actions = ['----seeds----', 'add-seed', 'fetch-seed',
     'list-seed', 'list-seedfiles', 'move-seed', 'remove-seed']
 
 Key_Actions = ['----keys-----', 'check-key', 'import-key', 'installed',
-    'install-key', 'search-key', 'list-key', 'move-key', 'refresh-key', 'remove-key',
-    'spec-check']
+    'install-key', 'list-key', 'move-key', 'refresh-key', 'remove-key',
+    'search-key', 'spec-check']
 
 General_Actions = ['---general---', 'list-cats', 'sign','verify']
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-05 23:12 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-05 23:12 UTC (permalink / raw
  To: gentoo-commits

commit:     f5d3aca3ab6d36eebec84fcd2cd9af3ae8c2d4d2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  5 00:57:28 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Jan  5 22:15:18 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=f5d3aca3

gkeys/actions.py: Fix self.listseed() return assignments

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index cfcc038..9986adc 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -90,7 +90,7 @@ class Actions(object):
     def addseed(self, args):
         '''Add or replace a key in the selected seed file'''
         handler = SeedHandler(self.logger, self.config)
-        gkeys = self.listseed(args)[1]
+        success, gkeys = self.listseed(args)[1]
         if not args.nick or not args.name or not args.keys or not args.keydir:
             return (False, ["Provide a nickname, a name and a public key fingerprint (-K, --keys)."])
         if not args.fingerprint:
@@ -101,7 +101,7 @@ class Actions(object):
         if not gkey:
             return (False, ["Failed to create a valid GKEY instance.",
                 "Check for invalid data entries"])
-        if len(gkeys[1]) == 0:
+        if len(gkeys) == 0:
             self.logger.debug("ACTIONS: installkey; now adding gkey: %s" % str(gkey))
             success = self.seeds.add(getattr(gkey, 'nick'), gkey)
             if success:
@@ -116,7 +116,7 @@ class Actions(object):
 
     def removeseed(self, args):
         '''Remove a seed from the selected seed file'''
-        gkeys = self.listseed(args)[1]
+        success, gkeys = self.listseed(args)[1]
         if not gkeys:
             return (False, ["Failed to remove seed: No gkeys returned from listseed()",
                 []])


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-05 23:12 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-05 23:12 UTC (permalink / raw
  To: gentoo-commits

commit:     29500cb89afb2bb7b4b365c683c7d09fe05fc4dd
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  3 18:07:25 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jan  3 18:21:23 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=29500cb8

gkeys/actions.py: Move list-cats to General_Actions

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 4a1c831..c212609 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -31,14 +31,14 @@ from gkeys.gkey import GKEY
 from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn
 
 
-Seed_Actions = ['----seeds----', 'add-seed', 'fetch-seed', 'list-cats',
+Seed_Actions = ['----seeds----', 'add-seed', 'fetch-seed',
     'list-seed', 'list-seedfiles', 'move-seed', 'remove-seed']
 
 Key_Actions = ['----keys-----', 'check-key', 'import-key', 'installed',
     'install-key', 'search-key', 'list-key', 'move-key', 'refresh-key', 'remove-key',
     'spec-check']
 
-General_Actions = ['---general---', 'sign','verify']
+General_Actions = ['---general---', 'list-cats', 'sign','verify']
 
 Available_Actions = General_Actions + Key_Actions + Seed_Actions
 
@@ -50,6 +50,14 @@ Action_Map = OrderedDict({
         'long_desc': '''''',
         'example': '''''',
         },
+    'list-cats': {
+        'func': 'listcats',
+        'options': [],
+        'desc': '''List seed file definitions (category names) found in the config''',
+        'long_desc': '''List seed file definitions (category names) found in the config.
+    These category names are used throughout the seed and key action operations.''',
+        'example': '''''',
+        },
     'sign': {
         'func': 'sign',
         'options': ['nick', 'name', 'fingerprint', 'file', ],
@@ -69,14 +77,6 @@ Action_Map = OrderedDict({
     the verification''',
         'example': '''''',
         },
-    'list-cats': {
-        'func': 'listcats',
-        'options': [],
-        'desc': '''List seed file definitions (category names) found in the config''',
-        'long_desc': '''List seed file definitions (category names) found in the config.
-    These category names are used throughout the seed and key action operations.''',
-        'example': '''''',
-        },
     '----keys-----': {
         'func': 'KEY_COMMANDS',
         'options': [],


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-01 22:32 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-01 22:32 UTC (permalink / raw
  To: gentoo-commits

commit:     9bdb0b53e00a591dabf23faebaa95ae97d410830
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  1 22:31:28 2015 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan  1 22:31:28 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=9bdb0b53

gkeys/actions.py: Remove redundant (broken) verify_info code

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 178d16d..c1f5b34 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -140,10 +140,6 @@ class Actions(object):
     def fetchseed(self, args):
         '''Download the selected seed file(s)'''
         self.logger.debug("ACTIONS: fetchseed; args: %s" % str(args))
-        if not args.keyring:
-            verify_info = self.config.get_key('verify-seeds', args.category).split()
-            args.keyring = verify_info[0]
-            args.nick = verify_info[1]
         handler = SeedHandler(self.logger, self.config)
         success, messages = handler.fetch_seeds(args.category, args, self.verify)
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-01 17:44 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-01 17:44 UTC (permalink / raw
  To: gentoo-commits

commit:     51f847f29ddfb4af33df09eb495781850bdcb293
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 30 19:06:19 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan  1 02:39:37 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=51f847f2

gkeys: Remove the need to import gkeys seed.py and lib.py

Pass in the logger to GkeysGPG initialization.
Pass in logger to Seeds class initialization.
This removes the need to import and set the logger in base.py.
It can then be used in gkeys-gen and gkeys-ldap without those imports.
Remove no longer needed imports.

---
 gkeys/gkeys/actions.py     | 16 ++++-----
 gkeys/gkeys/base.py        | 26 +++++++--------
 gkeys/gkeys/lib.py         | 82 +++++++++++++++++++++++-----------------------
 gkeys/gkeys/seed.py        | 23 ++++++-------
 gkeys/gkeys/seedhandler.py |  4 +--
 5 files changed, 75 insertions(+), 76 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 9b44cc8..7682dd2 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -243,7 +243,7 @@ class Actions(object):
         keyring = self.config.get_key('keyring')
         catdir = os.path.join(keyring, args.category)
         self.logger.debug("ACTIONS: listkey; catdir = %s" % catdir)
-        self.gpg = GkeysGPG(self.config, catdir)
+        self.gpg = GkeysGPG(self.config, catdir, self.logger)
         handler = SeedHandler(self.logger, self.config)
         if args.keydir:
             self.gpg.set_keydir(args.keydir, "list-keys")
@@ -338,7 +338,7 @@ class Actions(object):
             keyring = self.config.get_key('keyring')
             catdir = os.path.join(keyring, args.category)
             self.logger.debug("ACTIONS: installkey; catdir = %s" % catdir)
-            self.gpg = GkeysGPG(self.config, catdir)
+            self.gpg = GkeysGPG(self.config, catdir, self.logger)
             results = {}
             failed = []
             for key in gkey:
@@ -374,7 +374,7 @@ class Actions(object):
         keyring = self.config.get_key('keyring')
         catdir = os.path.join(keyring, args.category)
         self.logger.debug("ACTIONS: checkkey; catdir = %s" % catdir)
-        self.gpg = GkeysGPG(self.config, catdir)
+        self.gpg = GkeysGPG(self.config, catdir, self.logger)
         results = {}
         failed = defaultdict(list)
         kwargs = handler.build_gkeydict(args)
@@ -422,7 +422,7 @@ class Actions(object):
         keyring = self.config.get_key('keyring')
         catdir = os.path.join(keyring, args.category)
         self.logger.debug("ACTIONS: speccheck; catdir = %s" % catdir)
-        self.gpg = GkeysGPG(self.config, catdir)
+        self.gpg = GkeysGPG(self.config, catdir, self.logger)
         results = {}
         failed = defaultdict(list)
         kwargs = handler.build_gkeydict(args)
@@ -588,7 +588,7 @@ class Actions(object):
             catdir = os.path.join(keyring, args.category)
             keyring_dir = self.config.get_key("keyring")
             self.logger.debug("ACTIONS: importkey; catdir = %s" % catdir)
-            self.gpg = GkeysGPG(self.config, catdir)
+            self.gpg = GkeysGPG(self.config, catdir, self.logger)
             success, gkeys = self.listseed(args)[1]
             results = {}
             failed = []
@@ -692,7 +692,7 @@ class Actions(object):
         keyrings = self.config.get_key('keyring')
         catdir = os.path.join(keyrings, args.category)
         self.logger.debug("ACTIONS: verify; catdir = %s" % catdir)
-        self.gpg = GkeysGPG(self.config, catdir)
+        self.gpg = GkeysGPG(self.config, catdir, self.logger)
         return self._verify(args, handler, key, messages)
 
 
@@ -827,7 +827,7 @@ class Actions(object):
 
         self.logger.debug("ACTIONS: sign; keydir = %s" % keydir)
 
-        self.gpg = GkeysGPG(self.config, basedir)
+        self.gpg = GkeysGPG(self.config, basedir, self.logger)
         self.gpg.set_keydir(keydir, task)
         if keyring not in ['', None]:
             self.gpg.set_keyring(keyring, task)
@@ -862,7 +862,7 @@ class Actions(object):
         keyring = self.config.get_key('keyring')
         catdir = os.path.join(keyring, args.category)
         self.logger.debug("ACTIONS: refreshkey; catdir = %s" % catdir)
-        self.gpg = GkeysGPG(self.config, catdir)
+        self.gpg = GkeysGPG(self.config, catdir, self.logger)
         results = {}
         kwargs = handler.build_gkeydict(args)
         keyresults = seeds.list(**kwargs)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index c9faf0e..d03efc4 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -17,7 +17,7 @@ from __future__ import print_function
 import argparse
 import sys
 
-from gkeys import fileops, seed, lib
+from gkeys import fileops
 from gkeys.log import log_levels, set_logger
 
 
@@ -43,6 +43,7 @@ class CliBase(object):
         self.args = None
         self.seeds = None
         self.actions = None
+        self.logger = None
 
 
     @staticmethod
@@ -190,7 +191,7 @@ class CliBase(object):
         @param args: list
         @returns argparse.Namespace object
         '''
-        #logger.debug('CliBase: parse_args; args: %s' % args)
+        #self.logger.debug('CliBase: parse_args; args: %s' % args)
         parser = argparse.ArgumentParser(
             prog=self.cli_config['prog'],
             description=self.cli_config['description'],
@@ -245,7 +246,6 @@ class CliBase(object):
 
         @param args: list or argparse.Namespace object
         '''
-        global logger
         message = None
         if not args:
             message = "Main: run; invalid args argument passed in"
@@ -257,20 +257,18 @@ class CliBase(object):
         self.config.read_config()
 
         # establish our logger and update it in the imported files
-        logger = set_logger(self.cli_config['prog'], self.config['logdir'], args.debug,
+        self.logger = set_logger(self.cli_config['prog'], self.config['logdir'], args.debug,
             dirmode=int(self.config.get_key('permissions', 'directories'),0),
             filemask=int(self.config.get_key('permissions', 'files'),0))
-        self.config.logger = logger
-        fileops.logger = logger
-        seed.logger = logger
-        lib.logger = logger
+        self.config.logger = self.logger
+        fileops.logger = self.logger
 
         if message:
-            logger.error(message)
+            self.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"
+            self.logger.debug("Main: run; Found alternate config request: %s"
                 % args.config)
 
         # check if a -C, --category was input
@@ -282,12 +280,12 @@ class CliBase(object):
             return False
 
         # establish our actions instance
-        self.actions = self.cli_config['Actions'](self.config, self.output_results, logger)
+        self.actions = self.cli_config['Actions'](self.config, self.output_results, self.logger)
 
         # run the action
         func = getattr(self.actions, '%s'
             % self.cli_config['Action_Map'][args.action])
-        logger.debug('Main: run; Found action: %s' % args.action)
+        self.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",
@@ -328,7 +326,7 @@ class CliBase(object):
         '''
         available_cats = list(self.config.defaults['seeds'])
         if category and category not in available_cats:
-            self.config.logger.error("Invalid category or seedfile entered: %s" % category)
-            self.config.logger.error("Available categories or seedfiles: %s" % ', '.join(sorted(available_cats)))
+            self.logger.error("Invalid category or seedfile entered: %s" % category)
+            self.logger.error("Available categories or seedfiles: %s" % ', '.join(sorted(available_cats)))
             return False
         return True

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index 724abfc..6bb3d5b 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -26,14 +26,13 @@ from os.path import join as pjoin
 from pyGPG.gpg import GPG
 from gkeys.checks import KeyChecks
 from gkeys.fileops import ensure_dirs
-from gkeys.log import logger
 from gkeys.seed import Seeds
 
 class GkeysGPG(GPG):
     '''Gentoo-keys primary gpg class'''
 
 
-    def __init__(self, config, basedir):
+    def __init__(self, config, basedir, logger):
         '''class init function
 
         @param config: GKeysConfig config instance to use
@@ -43,6 +42,7 @@ class GkeysGPG(GPG):
         GPG.__init__(self, config, logger)
         self.config = config
         self.basedir = basedir
+        self.logger = logger
         self.keydir = None
         self.server = None
 
@@ -54,10 +54,10 @@ class GkeysGPG(GPG):
             return
         self.server = server or self.config['keyserver']
         self.config.options['gpg_defaults'] = self.config.defaults['gpg_defaults'][:]
-        logger.debug("keyserver: %s" % (self.server))
+        self.logger.debug("keyserver: %s" % (self.server))
         server_value = ['--keyserver', self.server]
         self.config.options['gpg_defaults'].extend(server_value)
-        logger.debug("self.config.options['gpg_defaults']: %s"
+        self.logger.debug("self.config.options['gpg_defaults']: %s"
             % (self.config.options['gpg_defaults']))
         return
 
@@ -65,7 +65,7 @@ class GkeysGPG(GPG):
     def set_keyring(self, keyring, task, importkey=False, reset=True):
         '''Sets the keyring to use as well as related task options
         '''
-        logger.debug("keydir: %s, keyring: %s" % (self.keydir, keyring))
+        self.logger.debug("keydir: %s, keyring: %s" % (self.keydir, keyring))
         if reset:
             self.config.options['tasks'][task] =  self.config.defaults['tasks'][task][:]
         # --keyring file |  Note that this adds a keyring to the current list.
@@ -79,12 +79,12 @@ class GkeysGPG(GPG):
                 mode=int(self.config.get_key('permissions', 'directories'),0))
         task_value = ['--no-default-keyring', '--keyring', keyring]
         self.config.options['tasks'][task].extend(task_value)
-        logger.debug("set_keyring: New task options: %s" %str(self.config.options['tasks'][task]))
+        self.logger.debug("set_keyring: New task options: %s" %str(self.config.options['tasks'][task]))
         return
 
 
     def set_keydir(self, keydir, task, fingerprint=True, reset=True):
-        logger.debug("basedir: %s, keydir: %s" % (self.basedir, keydir))
+        self.logger.debug("basedir: %s, keydir: %s" % (self.basedir, keydir))
         self.keydir = pjoin(self.basedir, keydir)
         self.task = task
         if reset:
@@ -94,7 +94,7 @@ class GkeysGPG(GPG):
             task_value.append('--fingerprint')
         task_value.extend(['--homedir', self.keydir])
         self.config.options['tasks'][task].extend(task_value)
-        logger.debug("set_keydir: New task options: %s" %str(self.config.options['tasks'][task]))
+        self.logger.debug("set_keydir: New task options: %s" %str(self.config.options['tasks'][task]))
         return
 
 
@@ -109,13 +109,13 @@ class GkeysGPG(GPG):
         self.set_keydir(keydir, 'import', reset=True)
         self.set_keyring(keyring, 'import', importkey=True, reset=False)
         results = []
-        logger.debug("LIB: import_to_keyring; name: " + gkey.name)
-        logger.debug("** Calling runGPG with Running: gpg %s --import' for: %s"
+        self.logger.debug("LIB: import_to_keyring; name: " + gkey.name)
+        self.logger.debug("** Calling runGPG with Running: gpg %s --import' for: %s"
                      % (' '.join(self.config.get_key('tasks', 'import')),
                         gkey.name))
         pubring_path = pjoin(self.keydir, gkey.keydir, 'pubring.gpg')
         result = self.runGPG(task='import', inputfile=pubring_path)
-        logger.info('GPG return code: ' + str(result.returncode))
+        self.logger.info('GPG return code: ' + str(result.returncode))
         results.append(result)
         print(result.stderr_out)
         return results
@@ -131,32 +131,32 @@ class GkeysGPG(GPG):
         self.set_keyserver()
         self.set_keydir(gkey.keydir, 'recv-keys', reset=True)
         self.set_keyring('pubring.gpg', 'recv-keys', reset=False)
-        logger.debug("LIB: add_key; ensure dirs: " + self.keydir)
+        self.logger.debug("LIB: add_key; ensure dirs: " + self.keydir)
         mode = int(self.config.get_key('permissions', 'directories'),0)
         ensure_dirs(str(self.keydir), mode=mode)
         self.set_keyseedfile(trap_errors=False)
         results = []
         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"
+            self.logger.debug("LIB: add_key; adding fingerprint " + fingerprint)
+            self.logger.debug("** Calling runGPG with Running 'gpg %s --recv-keys %s' for: %s"
                 % (' '.join(self.config.get_key('tasks', 'recv-keys')),
                     fingerprint, gkey.name))
             result = self.runGPG(task='recv-keys', inputfile=fingerprint)
-            logger.info('GPG return code: ' + str(result.returncode))
+            self.logger.info('GPG return code: ' + str(result.returncode))
             if result.fingerprint in gkey.fingerprint:
                 result.failed = False
                 message = "Fingerprints match... Import successful: "
                 message += "%s, fingerprint: %s" % (gkey.nick, 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)
+                self.logger.info(message)
             else:
                 result.failed = True
                 message = "Fingerprints do not match... Import failed for "
                 message += "%s, fingerprint: %s" % (gkey.nick, fingerprint)
                 message += "\n result: %s" % (result.fingerprint)
                 message += "\n gkey..: %s" % (str(gkey.fingerprint))
-                logger.error(message)
+                self.logger.error(message)
             # Save the gkey seed to the installed db
             success = self.update_gkey(gkey, save=True)
             if not success:
@@ -190,11 +190,11 @@ class GkeysGPG(GPG):
         self.set_keydir(gkey.keydir, 'refresh-keys', reset=True)
         self.set_keyring('pubring.gpg', 'refresh-keys', reset=False)
         self.set_keyseedfile(refresh=True)
-        logger.debug("LIB: refresh_key, gkey: %s" % str(gkey))
-        logger.debug("** Calling runGPG with Running 'gpg %s --refresh-keys' for: %s"
+        self.logger.debug("LIB: refresh_key, gkey: %s" % str(gkey))
+        self.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))
+        self.logger.info('GPG return code: ' + str(result.returncode))
         self.update_gkey(gkey, save=True)
         return result
 
@@ -211,7 +211,7 @@ class GkeysGPG(GPG):
             lresults.append(self.list_keys(gkey.keydir, fpr, colons=True))
         self.seedfile.update(gkey.update(lresults))
         if save and not self.seedfile.save():
-            logger.error("GkeysGPG.refresh_key(); failed to save seed: " + gkey.nick)
+            self.logger.error("GkeysGPG.refresh_key(); failed to save seed: " + gkey.nick)
             return False
         return True
 
@@ -225,7 +225,7 @@ class GkeysGPG(GPG):
         @param colons: bool to enable colon listing
         '''
         if not keydir:
-            logger.debug("LIB: list_keys(), invalid keydir parameter: %s"
+            self.logger.debug("LIB: list_keys(), invalid keydir parameter: %s"
                 % str(keydir))
             return []
         if fingerprint:
@@ -239,11 +239,11 @@ class GkeysGPG(GPG):
         if colons:
             task_value = ['--with-colons']
             self.config.options['tasks'][task].extend(task_value)
-        logger.debug("** Calling runGPG with Running 'gpg %s --%s %s'"
+        self.logger.debug("** Calling runGPG with Running 'gpg %s --%s %s'"
             % (' '.join(self.config['tasks'][task]), task, keydir)
             )
         result = self.runGPG(task=task, inputfile=target)
-        logger.info('GPG return code: ' + str(result.returncode))
+        self.logger.info('GPG return code: ' + str(result.returncode))
         return result
 
 
@@ -257,7 +257,7 @@ class GkeysGPG(GPG):
         '''
         if not result:
             result = self.list_keys(keydir, fingerprint=keyid, colons=True)
-        checker = KeyChecks(logger, qualified_id_check=True)
+        checker = KeyChecks(self.logger, qualified_id_check=True)
         return checker.validity_checks(keydir, keyid, result)
 
 
@@ -272,7 +272,7 @@ class GkeysGPG(GPG):
         '''
         if not result:
             result = self.list_keys(keydir, fingerprint=keyid, colons=True)
-        checker = KeyChecks(logger, qualified_id_check=True)
+        checker = KeyChecks(self.logger, qualified_id_check=True)
         specchecks = checker.spec_check(keydir, keyid, result)
         return specchecks
 
@@ -306,29 +306,29 @@ class GkeysGPG(GPG):
         '''
         if signature:
             self.set_keydir(gkey.keydir, 'verify', reset=True)
-            logger.debug("** Calling runGPG with Running 'gpg %s --verify %s and %s'"
+            self.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'"
+            self.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" % (gkey.name, keyid))
-            logger.info("\tSignature result:" + str(results.verified))
+            self.logger.info("GPG verification succeeded. Name: %s / Key: %s" % (gkey.name, keyid))
+            self.logger.info("\tSignature result:" + str(results.verified))
         else:
-            logger.debug("GPG verification failed. Name: %s / Key: %s" % (gkey.name, keyid))
-            logger.debug("\t Signature result:"+ str(results.verified))
-            logger.debug("LIB: verify; stderr_out:" + str(results.stderr_out))
+            self.logger.debug("GPG verification failed. Name: %s / Key: %s" % (gkey.name, keyid))
+            self.logger.debug("\t Signature result:"+ str(results.verified))
+            self.logger.debug("LIB: verify; stderr_out:" + str(results.stderr_out))
         return results
 
 
     def set_keyseedfile(self, trap_errors=True, refresh=False):
         if not self.keydir:
-            logger.debug("GkeysGPG.set_keyseedfile(); self.keydir error")
-        self.seedfile = Seeds(pjoin(self.keydir, 'gkey.seeds'), self.config)
+            self.logger.debug("GkeysGPG.set_keyseedfile(); self.keydir error")
+        self.seedfile = Seeds(pjoin(self.keydir, 'gkey.seeds'), self.config, self.logger)
         self.seedfile.load(trap_errors=trap_errors, refresh=refresh)
 
 
@@ -342,15 +342,15 @@ class GkeysGPG(GPG):
         '''
         keyid = gkey.keyid[0]
         self.set_keydir(gkey.keydir, mode, reset=True)
-        logger.debug("** Calling runGPG with Running 'gpg %s --%s %s %s'"
+        self.logger.debug("** Calling runGPG with Running 'gpg %s --%s %s %s'"
                 % (' '.join(self.config['tasks'][mode]), mode, fingerprint, filepath))
         results = self.runGPG(task=mode, inputfile=filepath)
 
         if results.verified[0]:
-            logger.info("GPG signing succeeded. Name: %s / Key: %s" % (str(gkey.name), str(keyid)))
-            logger.info("\tSignature result:" + str(results.verified))
+            self.logger.info("GPG signing succeeded. Name: %s / Key: %s" % (str(gkey.name), str(keyid)))
+            self.logger.info("\tSignature result:" + str(results.verified))
         else:
-            logger.debug("GPG signing failed. Name: %s / Key: %s" % (str(gkey.name), str(keyid)))
-            logger.debug("\t Signature result:"+ str(results.verified))
-            logger.debug("LIB: sign; stderr_out:" + str(results.stderr_out))
+            self.logger.debug("GPG signing failed. Name: %s / Key: %s" % (str(gkey.name), str(keyid)))
+            self.logger.debug("\t Signature result:"+ str(results.verified))
+            self.logger.debug("LIB: sign; stderr_out:" + str(results.stderr_out))
         return results

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index 1a2bae2..15c9e2c 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -29,13 +29,14 @@ class Seeds(object):
     '''Handles all seed key file operations'''
 
 
-    def __init__(self, filepath=None, config=None):
+    def __init__(self, filepath=None, config=None, _logger=None):
         '''Seeds class init function
 
         @param filepath: string of the file to load
         '''
         self.filename = filepath
         self.config = config
+        self.logger = _logger or logger
         self.seeds = {}
 
 
@@ -44,16 +45,16 @@ class Seeds(object):
         if filename:
             self.filename = filename
         if not self.filename:
-            logger.debug("Seed: load; Not a valid filename: '%s'" % str(self.filename))
+            self.logger.debug("Seed: load; Not a valid filename: '%s'" % str(self.filename))
             return False
-        logger.debug("Seeds: load; Begin loading seed file %s" % self.filename)
+        self.logger.debug("Seeds: load; Begin loading seed file %s" % self.filename)
         seedlines = None
         self.seeds = {}
         try:
             with open(self.filename, "r+") as seedfile:
                 seedlines = json.load(seedfile)
         except IOError as err:
-            logger.debug("Seed: load; IOError occurred while loading file")
+            self.logger.debug("Seed: load; IOError occurred while loading file")
             if trap_errors:
                 self._error(err)
             return False
@@ -71,10 +72,10 @@ class Seeds(object):
             #try:
             self.seeds[seed[0]] = GKEY(**seed[1])
             #except Exception as err:
-                #logger.debug("Seed: load; Error splitting seed: %s" % seed)
-                #logger.debug("Seed: load; ...............parts: %s" % str(parts))
+                #self.logger.debug("Seed: load; Error splitting seed: %s" % seed)
+                #self.logger.debug("Seed: load; ...............parts: %s" % str(parts))
                 #self._error(err)
-        logger.debug("Seed: load; Completed loading seed file %s" % self.filename)
+        self.logger.debug("Seed: load; Completed loading seed file %s" % self.filename)
         return True
 
 
@@ -83,9 +84,9 @@ class Seeds(object):
         if filename:
             self.filename = filename
         if not self.filename:
-            logger.debug("Seed: save; Not a valid filename: '%s'" % str(self.filename))
+            self.logger.debug("Seed: save; Not a valid filename: '%s'" % str(self.filename))
             return False
-        logger.debug("Seed: save; Begin saving seed file %s" % self.filename)
+        self.logger.debug("Seed: save; Begin saving seed file %s" % self.filename)
         ensure_dirs(os.path.split(self.filename)[0],
             mode=int(self.config.get_key('permissions', "directories"),0),
             fatal=True)
@@ -217,8 +218,8 @@ class Seeds(object):
 
     def _error(self, err):
         '''Class error logging function'''
-        logger.error("Seed: Error processing seed file %s" % self.filename)
-        logger.error("Seed: Error was: %s" % str(err))
+        self.logger.error("Seed: Error processing seed file %s" % self.filename)
+        self.logger.error("Seed: Error was: %s" % str(err))
 
 
     def _seeds2json(self, seeds):

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 5ddccbe..9540ee0 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -77,7 +77,7 @@ class SeedHandler(object):
             self.logger.error("SeedHandler: load_seeds; No filepath to load")
         self.logger.debug("SeedHandler: load_seeds; seeds filepath to load: "
             "%s" % filepath)
-        seeds = Seeds(config=self.config)
+        seeds = Seeds(config=self.config, _logger=self.logger)
         seeds.load(filepath, refresh=refresh)
         self.seeds = seeds
         return seeds
@@ -89,7 +89,7 @@ class SeedHandler(object):
         @param nicks: list of string nick ids to load
         @return Seeds class object
         '''
-        seeds = Seeds(config=self.config)
+        seeds = Seeds(config=self.config, _logger=self.logger)
         if category == 'sign':
             catdir = self.config.get_key('sign-keydir')
         else:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-01 17:44 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-01 17:44 UTC (permalink / raw
  To: gentoo-commits

commit:     091d066f082851d852b3ecfa6fca655dc486ef29
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 31 21:23:32 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan  1 02:39:52 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=091d066f

gkeys/actions.py: Update docstrings and action options

This in preparation for man pages during wiki help page editing.

---
 gkeys/gkeys/actions.py | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 7682dd2..178d16d 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -48,7 +48,7 @@ Action_Options = {
     'add-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'uid'],
     'remove-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category'],
     'move-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'dest'],
-    'fetch-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring'],
+    'fetch-seed': ['nick', '1file', 'category', 'dest', 'signature', 'timestamp'],
     'list-seedfiles': [],
     'list-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'gpgsearch', 'keyid'],
     'install-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', '1file'],
@@ -59,7 +59,7 @@ Action_Options = {
     'search-key': ['nick', '1name', 'keydir', 'keys', 'fingerprint', 'keyid', 'uid', 'category', 'exact', 'all'],
     'verify': ['dest', 'nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', '1file', 'signature', 'timestamp'],
     'check-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'keyid'],
-    'sign': ['nick', 'name', 'keydir', 'fingerprint', 'file', 'keyring'],
+    'sign': ['nick', 'name', 'fingerprint', 'file', ],
     'spec-check': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'keyid'],
     'refresh-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'keyid'],
     '---general---': [],
@@ -176,7 +176,7 @@ class Actions(object):
 
 
     def removeseed(self, args):
-        '''Remove a key from the selected seed file(s)'''
+        '''Remove a seed from the selected seed file'''
         gkeys = self.listseed(args)[1]
         if not gkeys:
             return (False, ["Failed to remove seed: No gkeys returned from listseed()",
@@ -365,7 +365,9 @@ class Actions(object):
 
 
     def checkkey(self, args):
-        '''Check keys actions'''
+        '''Check keys actions
+        Performs basic validity checks on the key(s), checks expiry,
+        and presence of a signing sub-key'''
         if not args.category:
             return (False, ["Please specify seeds category."])
         self.logger.debug("ACTIONS: checkkey; args: %s" % str(args))
@@ -413,7 +415,7 @@ class Actions(object):
 
 
     def speccheck(self, args):
-        '''Check keys actions'''
+        '''Check if keys meet specifications requirements'''
         if not args.category:
             return (False, ["Please specify seeds category."])
         self.logger.debug("ACTIONS: speccheck; args: %s" % str(args))
@@ -660,9 +662,13 @@ class Actions(object):
 
 
     def verify(self, args, messages=None):
-        '''File verification action
+        '''File verification action.
+        Note: If the specified key/keyring to verify against does not contain
+        the key used to sign the file.  It will Auto-search for the correct key
+        in the installed keys db. And verify against the matching key.'''
 
-        @ param args: argparse.parse_args instance
+        '''
+        @param args: argparse.parse_args instance
         @param messages: list, private internal option used for recursion only
         '''
         if messages == None:
@@ -877,7 +883,7 @@ class Actions(object):
 
 
     def key_search(self, args, data_only=False):
-        '''Search for a key's seed field in the installed keys db'''
+        '''Search for a key's seed in the installed keys db'''
         handler = SeedHandler(self.logger, self.config)
         results = {}
         search_args = [x for x in


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-01 17:44 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-01 17:44 UTC (permalink / raw
  To: gentoo-commits

commit:     d97ffd3d5aab2429c5256448b7f8c9571791490c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 30 22:27:04 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan  1 02:39:51 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=d97ffd3d

gkeys/config.py: Move default config file setting to a function

Make homedir initialzation part of the defaults options for consistency.
Move the default user config file into a ~/.gkeys/ sub-directory

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

diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py
index 5d3923f..fdc1cee 100644
--- a/gkeys/gkeys/config.py
+++ b/gkeys/gkeys/config.py
@@ -48,18 +48,21 @@ class GKeysConfig(GPGConfig):
             self.defaults['config'] = config
             self.defaults['configdir'] = os.path.dirname(config)
         else:
-            self.homedir = os.path.expanduser('~')
-            self.defaults['configdir'] = self.homedir
-            self.defaults['config']= os.path.join(self.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._set_default_config()
         self.configparser = None
         self._add_gkey_defaults()
         if read_configfile:
             self.read_config()
 
 
+    def _set_default_config(self):
+            self.defaults['homedir'] = os.path.join(os.path.expanduser('~'), '.gkeys')
+            self.defaults['configdir'] = self.defaults['homedir']
+            self.defaults['config']= os.path.join(self.defaults['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'
+
     def _add_gkey_defaults(self):
         self.defaults['gkeysdir'] = path([self.root, EPREFIX, '/var/lib/gentoo/gkeys'])
         self.defaults['keyring'] = '%(gkeysdir)s/keyring'


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-01 17:44 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-01 17:44 UTC (permalink / raw
  To: gentoo-commits

commit:     3ea4ac8ff20626008d02a44c09211e2a67c54fcd
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 30 19:38:23 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan  1 02:39:51 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=3ea4ac8f

gkeys/config.py: Make it possible to read more than one config file

Save homedir to the config class for re-use in gkeys-gen
multiple configs fix

---
 gkeys/gkeys/base.py   | 19 ++++++++++++-------
 gkeys/gkeys/cli.py    | 12 +++++++++---
 gkeys/gkeys/config.py | 25 +++++++++++++++----------
 3 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index d03efc4..052d45f 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -185,10 +185,10 @@ class CliBase(object):
             help='The user ID, gpg key uid')
 
 
-    def parse_args(self, args):
+    def parse_args(self, argv):
         '''Parse a list of aruments
 
-        @param args: list
+        @param argv: list
         @returns argparse.Namespace object
         '''
         #self.logger.debug('CliBase: parse_args; args: %s' % args)
@@ -225,7 +225,7 @@ class CliBase(object):
             action_parser.set_defaults(action=name)
             self._add_options(action_parser, self.cli_config['Action_Options'][name])
 
-        parsed_args = parser.parse_args(args)
+        parsed_args = parser.parse_args(argv)
         action = getattr(parsed_args, 'action', None)
         if not action:
             parser.print_usage()
@@ -241,10 +241,11 @@ class CliBase(object):
             getattr(self, '_option_%s' % opt)(parser)
 
 
-    def run(self, args):
-        '''Run the args passed in
+    def setup(self, args, configs):
+        '''Set up the args and configs passed in
 
         @param args: list or argparse.Namespace object
+        @param configs: list
         '''
         message = None
         if not args:
@@ -253,8 +254,9 @@ class CliBase(object):
             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()
+            self.config.read_config()
+        else:
+            self.config.read_config(configs)
 
         # establish our logger and update it in the imported files
         self.logger = set_logger(self.cli_config['prog'], self.config['logdir'], args.debug,
@@ -278,7 +280,10 @@ class CliBase(object):
             cat = args.category
         if not self._check_category(cat):
             return False
+        return True
 
+
+    def run(self, args):
         # establish our actions instance
         self.actions = self.cli_config['Actions'](self.config, self.output_results, self.logger)
 

diff --git a/gkeys/gkeys/cli.py b/gkeys/gkeys/cli.py
index df81882..31457e0 100644
--- a/gkeys/gkeys/cli.py
+++ b/gkeys/gkeys/cli.py
@@ -13,6 +13,7 @@
 from __future__ import print_function
 
 
+import os
 import sys
 
 from gkeys.base import CliBase
@@ -52,7 +53,12 @@ class Main(CliBase):
                      Defaults to sys.argv[1:]
         """
         if args:
-            return self.run(self.parse_args(args))
+            ok = self.setup(args)
+            if ok:
+                return self.run(self.parse_args(args))
         else:
-            return self.run(self.parse_args(sys.argv[1:]))
-
+            args = self.parse_args(sys.argv[1:])
+            ok = self.setup(args, os.path.join(self.config['configdir'],'gkeys.conf'))
+            if ok:
+                return self.run(args)
+        return False

diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py
index 8fa4c1b..5d3923f 100644
--- a/gkeys/gkeys/config.py
+++ b/gkeys/gkeys/config.py
@@ -48,9 +48,9 @@ class GKeysConfig(GPGConfig):
             self.defaults['config'] = config
             self.defaults['configdir'] = os.path.dirname(config)
         else:
-            homedir = os.path.expanduser('~')
-            self.defaults['configdir'] = homedir
-            self.defaults['config']= os.path.join(homedir, '.gkeys.conf')
+            self.homedir = os.path.expanduser('~')
+            self.defaults['configdir'] = self.homedir
+            self.defaults['config']= os.path.join(self.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'
@@ -83,7 +83,7 @@ class GKeysConfig(GPGConfig):
         self.defaults['verify-seeds'] = {}
 
 
-    def read_config(self):
+    def read_config(self, filename=None):
         '''Reads the config file into memory
         '''
         if "%(configdir)s" in self.defaults['config']:
@@ -97,18 +97,23 @@ class GKeysConfig(GPGConfig):
         for key in ['gkeysdir', 'keyring', 'sign-keydir', 'logdir', 'seedsdir',
             'keyserver']:
             defaults[key] = self.defaults[key]
+        if filename == None:
+            filename = self.defaults['config']
         self.configparser = SaneConfigParser(defaults)
-        self.configparser.read(self.defaults['config'])
-        # I consider this hacky, but due to shortcomings of ConfigParser
-        # we need to reset the defaults redefined in the 'base' section
-        for key in self.configparser.options('base'):
-            self.defaults[key] = self.configparser.get('base', key)
-            defaults[key] = self.defaults[key]
+        self.configparser.read(filename)
+        if self.configparser.has_section('base'):
+            # I consider this hacky, but due to shortcomings of ConfigParser
+            # we need to reset the defaults redefined in the 'base' section
+            for key in self.configparser.options('base'):
+                self.defaults[key] = self.configparser.get('base', key)
+                defaults[key] = self.defaults[key]
         self.configparser._defaults = defaults
         for section in self.configparser.sections():
             if section == 'base':
                 continue
             for key in self.configparser.options(section):
+                if section not in self.defaults:
+                    self.defaults[section] = {}
                 self.defaults[section][key] = self.configparser.get(section, key)
 
     def get_key(self, key, subkey=None):


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2015-01-01 17:44 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2015-01-01 17:44 UTC (permalink / raw
  To: gentoo-commits

commit:     7813ed25a711a2e13d3f9dcf0896e5b45db69501
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 30 18:42:40 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 22:07:04 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=7813ed25

gkeys/base.py: Sort the _option_* functions

---
 gkeys/gkeys/base.py | 101 +++++++++++++++++++++++++++-------------------------
 1 file changed, 53 insertions(+), 48 deletions(-)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 2ec4375..c9faf0e 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -46,15 +46,40 @@ class CliBase(object):
 
 
     @staticmethod
+    def _option_status(parser=None):
+        parser.add_argument('-A', '--status', action='store_true',
+            default=False,
+            help='The active status of the member')
+
+    @staticmethod
     def _option_all(parser=None):
         parser.add_argument('-a', '--all', dest='all',
             action='store_true', default=False,
             help='Match all inputs arguments in searches')
 
     @staticmethod
+    def _option_category(parser=None):
+        parser.add_argument('-C', '--category',
+            dest='category', default=None,
+            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_dest(parser=None):
         parser.add_argument('-d', '--dest', dest='destination', default=None,
-            help='The destination seed file or keydir for move, copy operations')
+            help='The destination for move, copy, create operations')
 
     @staticmethod
     def _option_exact(parser=None):
@@ -63,6 +88,17 @@ class CliBase(object):
             help='Use CASE matching in searches')
 
     @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_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_fingerprint(parser=None):
         parser.add_argument('-f', '--fingerprint', dest='fingerprint',
             default=None, nargs='+',
@@ -74,12 +110,23 @@ class CliBase(object):
             help='Do a gpg search operations, rather than a gkey search')
 
     @staticmethod
+    def _option_homedir(parser=None):
+        parser.add_argument('-H', '--homedir', dest='homedir', default=None,
+                            help='The destination for the generated key')
+
+    @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_justdoit(parser=None):
+        parser.add_argument('--justdoit', dest='justdoit',
+            action='store_true', default=False,
+            help='Just Do It')
+
+    @staticmethod
     def _option_keyring(parser=None):
         parser.add_argument('-k', '--keyring', dest='keyring', default=None,
             help='The name of the keyring to use for verification, etc.')
@@ -91,6 +138,11 @@ class CliBase(object):
             help='The name of the keyring to use for verification, etc.')
 
     @staticmethod
+    def _option_mail(parser=None):
+        parser.add_argument('-m', '--mail', dest='mail', default=None,
+            help='The email address to search for')
+
+    @staticmethod
     def _option_nick(parser=None):
         parser.add_argument('-n', '--nick', dest='nick', default=None,
             help='The nick associated with the the key')
@@ -106,25 +158,6 @@ class CliBase(object):
             default=None, help='The name of the the key')
 
     @staticmethod
-    def _option_category(parser=None):
-        parser.add_argument('-C', '--category',
-            dest='category', default=None,
-            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')
@@ -135,17 +168,6 @@ class CliBase(object):
             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_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')
@@ -157,23 +179,6 @@ class CliBase(object):
             help='Turn on timestamp use')
 
     @staticmethod
-    def _option_mail(parser=None):
-        parser.add_argument('-m', '--mail', dest='mail', default=None,
-            help='The email address to search for')
-
-    @staticmethod
-    def _option_status(parser=None):
-        parser.add_argument('-A', '--status', action='store_true',
-            default=False,
-            help='The active status of the member')
-
-    @staticmethod
-    def _option_justdoit(parser=None):
-        parser.add_argument('--justdoit', dest='justdoit',
-            action='store_true', default=False,
-            help='Just Do It')
-
-    @staticmethod
     def _option_uid(parser=None):
         parser.add_argument('-u', '--uid', dest='uid', nargs='*', default=None,
             help='The user ID, gpg key uid')


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-31 21:34 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-31 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     3a59f3c4f95e5136d03805049c9af638de96dde4
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 28 17:03:35 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=3a59f3c4

gkeys: Add UpdateDbError exception usage

---
 gkeys/gkeys/actions.py     |  2 +-
 gkeys/gkeys/lib.py         |  6 +++---
 gkeys/gkeys/seed.py        |  7 ++++++-
 gkeys/gkeys/seedhandler.py | 11 ++++++++---
 4 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 0dbdf24..2a68739 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -858,7 +858,7 @@ class Actions(object):
             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)
+        seeds = handler.load_category(args.category, refresh=True)
         keyring = self.config.get_key('keyring')
         catdir = os.path.join(keyring, args.category)
         self.logger.debug("ACTIONS: refreshkey; catdir = %s" % catdir)

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index f8e6615..724abfc 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -189,7 +189,7 @@ class GkeysGPG(GPG):
         self.set_keyserver()
         self.set_keydir(gkey.keydir, 'refresh-keys', reset=True)
         self.set_keyring('pubring.gpg', 'refresh-keys', reset=False)
-        self.set_keyseedfile()
+        self.set_keyseedfile(refresh=True)
         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)))
@@ -325,11 +325,11 @@ class GkeysGPG(GPG):
         return results
 
 
-    def set_keyseedfile(self, trap_errors=True):
+    def set_keyseedfile(self, trap_errors=True, refresh=False):
         if not self.keydir:
             logger.debug("GkeysGPG.set_keyseedfile(); self.keydir error")
         self.seedfile = Seeds(pjoin(self.keydir, 'gkey.seeds'), self.config)
-        self.seedfile.load(trap_errors=trap_errors)
+        self.seedfile.load(trap_errors=trap_errors, refresh=refresh)
 
 
     def sign_file(self, gkey, mode, fingerprint, filepath):

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index 67354f3..1a2bae2 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -19,6 +19,7 @@ with gentoo-keys specific convienience functions.
 import json
 import os
 
+from gkeys.exception import UpdateDbError
 from gkeys.log import logger
 from gkeys.gkey import GKEY
 from gkeys.fileops import ensure_dirs
@@ -38,7 +39,7 @@ class Seeds(object):
         self.seeds = {}
 
 
-    def load(self, filename=None, trap_errors=True):
+    def load(self, filename=None, trap_errors=True, refresh=False):
         '''Load the seed file into memory'''
         if filename:
             self.filename = filename
@@ -59,8 +60,12 @@ class Seeds(object):
         for seed in list(seedlines.items()):
             # GKEY class change auto-update
             if not 'uid' in list(seed[1]):
+                if not refresh:
+                    raise UpdateDbError(filename)
                 seed[1]['uid'] = []
             if not 'keys' in list(seed[1]):
+                if not refresh:
+                    raise UpdateDbError(filename)
                 seed[1]['keys'] = seed[1]['fingerprint'][:]
 
             #try:

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index a9fb720..5ddccbe 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -14,6 +14,7 @@ import os
 import re
 from json import load
 
+from gkeys.exception import UpdateDbError
 from gkeys.gkey import GKEY
 from gkeys.seed import Seeds
 from gkeys.fileops import ensure_dirs
@@ -58,7 +59,7 @@ class SeedHandler(object):
                 pass
         return keyinfo
 
-    def load_seeds(self, seedfile=None, filepath=None):
+    def load_seeds(self, seedfile=None, filepath=None, refresh=False):
         '''Load seed file
 
         @param seeds: string of the short name seed file
@@ -77,11 +78,11 @@ class SeedHandler(object):
         self.logger.debug("SeedHandler: load_seeds; seeds filepath to load: "
             "%s" % filepath)
         seeds = Seeds(config=self.config)
-        seeds.load(filepath)
+        seeds.load(filepath, refresh=refresh)
         self.seeds = seeds
         return seeds
 
-    def load_category(self, category, nicks=None):
+    def load_category(self, category, nicks=None, refresh=False):
         '''Loads the designated key directories
 
         @param category: string
@@ -113,8 +114,12 @@ class SeedHandler(object):
                         key = seed[nick]
                         # GKEY class change auto-update
                         if not 'uid' in list(key):
+                            if not refresh:
+                                raise UpdateDbError(category)
                             key['uid'] = []
                         if not 'keys' in list(key):
+                            if not refresh:
+                                raise UpdateDbError(category)
                             key['keys'] = key['fingerprint'][:]
                         seeds.add(nick, GKEY(**key))
         except OSError as error:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-31 21:34 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-31 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     7878398cdf5743d138987d5e6230b2a4d5c095a4
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 28 08:38:40 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=7878398c

gkeys/actions.py: Add uid search support

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 03789fa..391d478 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -56,7 +56,7 @@ Action_Options = {
     'move-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'dest'],
     'installed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring'],
     'import-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring'],
-    'key-search': ['nick', '1name', 'keydir', 'keys', 'fingerprint', 'keyid', 'category', 'exact', 'all'],
+    'key-search': ['nick', '1name', 'keydir', 'keys', 'fingerprint', 'keyid', 'uid', 'category', 'exact', 'all'],
     'verify': ['dest', 'nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', '1file', 'signature', 'timestamp'],
     'check-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'keyid'],
     'sign': ['nick', 'name', 'keydir', 'fingerprint', 'file', 'keyring'],
@@ -881,7 +881,7 @@ class Actions(object):
         handler = SeedHandler(self.logger, self.config)
         results = {}
         search_args = [x for x in
-            ['nick', 'name', 'keydir', 'fingerprint', 'keyid']
+            ['nick', 'name', 'keydir', 'fingerprint', 'keyid', 'uid']
             if getattr(args, x)]
         if args.category:
             handler.load_category(args.category)
@@ -909,6 +909,6 @@ class Actions(object):
         for cat in list(keys):
             msgs.append("Category: %s" % cat)
             msgs.append(keys[cat])
-        del keys, found, cat, result, handler
+        del keys, cat, handler
         return (True, msgs)
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-31 21:34 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-31 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     6933a2cc528c124aeb8f1b6d59ac636b9819b167
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 28 08:44:06 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=6933a2cc

gkeys/actions.py: Alignment tweak for key-search message

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 391d478..0dbdf24 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -907,7 +907,7 @@ class Actions(object):
             return keys
         msgs = []
         for cat in list(keys):
-            msgs.append("Category: %s" % cat)
+            msgs.append("Category.....: %s" % cat)
             msgs.append(keys[cat])
         del keys, cat, handler
         return (True, msgs)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 2c0e114..2ec4375 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -300,7 +300,7 @@ class CliBase(object):
             print(header)
         for msg in results:
             if type(msg) in [str, unicode]:
-                print('    ', msg)
+                print('   ', msg)
             else:
                 try:
                     print("\n".join([x.pretty_print for x in msg]))


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-31 21:34 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-31 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     d1c8f1bcf372055636628ae9b219d4c73f91a0d2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 28 08:23:36 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=d1c8f1bc

gkeys/actions.py: Fix broken key-search printing

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 1d3a927..03789fa 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -908,8 +908,7 @@ class Actions(object):
         msgs = []
         for cat in list(keys):
             msgs.append("Category: %s" % cat)
-            for result in keys[cat]:
-                msgs.append(result)
+            msgs.append(keys[cat])
         del keys, found, cat, result, handler
         return (True, msgs)
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-31 21:34 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-31 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     b738dd11378cb4229fa2db3632f815627c2d746b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 28 00:56:25 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=b738dd11

gkeys/actions.py: Improve verification messages and info

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index b92f3a2..1d3a927 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -680,10 +680,13 @@ class Actions(object):
             return (False, ['No installed keys found, try installkey action.'])
         key = handler.seeds.nick_search(args.nick)
         if not key:
-            messages.append("Failed to find nick: %s in %s category"
-                % (args.nick, args.category))
+            if args.nick:
+                messages.append("Failed to find.........: %s in category: %s"
+                    % (args.category, args.nick))
             args.category = self.config.get_key('verify-keyring')
             args.nick = self.config.get_key('verify-nick')
+            messages.append("Using config defaults..: %s %s"
+                % (args.category, args.nick))
             return self.verify(args, messages)
 
         keyrings = self.config.get_key('keyring')
@@ -759,14 +762,15 @@ class Actions(object):
                 verified = True
                 messages.extend(["Verification succeeded.: %s" % (filepath),
                     "Key info...............: %s <%s>, %s"
-                    % ( key.name, key.nick, keyid)])
+                    % ( key.name, key.nick, keyid),
+                    "    category, nick.....: %s %s" % (args.category, args.nick)])
             else:
                 messages.extend(["Verification failed....: %s" % (filepath),
                     "Key info...............: %s <%s>, %s"
                     % ( key.name, key.nick, keyid)])
                 has_no_pubkey, s_keyid = results.no_pubkey
                 if has_no_pubkey:
-                    messages.append("Auto-searching for key.: %s" % s_keyid)
+                    messages.append("Auto-searching for key.: 0x%s" % s_keyid)
                     # reset all but keyid and pass thru data
                     args.keyid = s_keyid
                     args.keydir = None


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-31 21:34 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-31 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     c9fbd425cd4637972aa951f7b159ec3bae9655cf
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 28 17:38:19 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:27 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=c9fbd425

gkeys/actions.py: Rename key-search action to search-key for consistency

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 2a68739..9b44cc8 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -35,7 +35,7 @@ Seed_Actions = ['----seeds----', 'add-seed', 'fetch-seed', 'list-cats',
     'list-seed', 'list-seedfiles', 'move-seed', 'remove-seed']
 
 Key_Actions = ['----keys-----', 'check-key', 'import-key', 'installed',
-    'install-key', 'key-search', 'list-key', 'move-key', 'refresh-key', 'remove-key',
+    'install-key', 'search-key', 'list-key', 'move-key', 'refresh-key', 'remove-key',
     'spec-check']
 
 General_Actions = ['---general---', 'sign','verify']
@@ -56,7 +56,7 @@ Action_Options = {
     'move-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'dest'],
     'installed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring'],
     'import-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring'],
-    'key-search': ['nick', '1name', 'keydir', 'keys', 'fingerprint', 'keyid', 'uid', 'category', 'exact', 'all'],
+    'search-key': ['nick', '1name', 'keydir', 'keys', 'fingerprint', 'keyid', 'uid', 'category', 'exact', 'all'],
     'verify': ['dest', 'nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', '1file', 'signature', 'timestamp'],
     'check-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'keyid'],
     'sign': ['nick', 'name', 'keydir', 'fingerprint', 'file', 'keyring'],
@@ -81,7 +81,7 @@ Action_Map = {
     'move-key': 'movekey',
     'installed': 'installed',
     'import-key': 'importkey',
-    'key-search': 'key_search',
+    'search-key': 'key_search',
     'verify': 'verify',
     'check-key': 'checkkey',
     'sign': 'sign',


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-31 21:34 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-31 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     eef89beeb23c6c539944b9f09d038fa821912667
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 28 16:54:10 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=eef89bee

gkeys/exception.py: Initial creation of GkeyException classes

Mostly copied, modified from PortageException code.

---
 gkeys/gkeys/exception.py | 78 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

diff --git a/gkeys/gkeys/exception.py b/gkeys/gkeys/exception.py
new file mode 100644
index 0000000..21a2e97
--- /dev/null
+++ b/gkeys/gkeys/exception.py
@@ -0,0 +1,78 @@
+# Copyright 1998-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+
+import sys
+
+
+if sys.version_info[0] >= 3:
+    # pylint: disable=W0622
+    basestring = str
+
+    def _unicode_encode(s, encoding='utf_8', errors='backslashreplace'):
+        if isinstance(s, str):
+            s = s.encode(encoding, errors)
+        return s
+
+    def _unicode_decode(s, encoding='utf_8', errors='replace'):
+        if isinstance(s, bytes):
+            s = str(s, encoding=encoding, errors=errors)
+        return s
+
+else:
+
+    def _unicode_encode(s, encoding='utf_8', errors='backslashreplace'):
+        if isinstance(s, unicode):
+            s = s.encode(encoding, errors)
+        return s
+
+    def _unicode_decode(s, encoding='utf_8', errors='replace'):
+        if isinstance(s, bytes):
+            s = unicode(s, encoding=encoding, errors=errors)
+        return s
+
+
+class GkeysException(Exception):
+    if sys.version_info[0] >= 3:
+        def __init__(self, value):
+            self.value = value[:]
+
+        def __str__(self):
+            if isinstance(self.value, str):
+                return self.value
+            else:
+                return repr(self.value)
+    else:
+        def __init__(self, value):
+            self.value = value[:]
+            if isinstance(self.value, basestring):
+                self.value = _unicode_decode(self.value,
+                    encoding='utf_8', errors='replace')
+
+        def __unicode__(self):
+            if isinstance(self.value, unicode):
+                return self.value
+            else:
+                return _unicode_decode(repr(self.value),
+                    encoding='utf_8', errors='replace')
+
+        def __str__(self):
+            if isinstance(self.value, unicode):
+                return _unicode_encode(self.value,
+                    encoding='utf_8', errors='backslashreplace')
+            else:
+                return repr(self.value)
+
+
+class UpdateDbError(GkeysException):
+    '''%s
+
+    Please Run: 'gkeys refresh-key -C {foo}'
+    on all installed keyring categories
+    Then continue with normal gkey operations.'''
+    def __init__(self, value):
+        doc = self.__doc__ % (value)
+        GkeysException.__init__(self, doc)
+
+
+


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-31 21:34 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-31 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     1626d81d20474cb55620bf19aa12924b28a795e9
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 27 21:56:14 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=1626d81d

gkeys/lib.py: Add the new GKEY.update() to add_key and refresh_key

This updates our installed gkey.seed with all fingerprints including sub-keys and uid's.  This way searches for keys used to sign files can be found if the key used to sign the file was not a primary key.

---
 gkeys/gkeys/lib.py | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index 67c94ae..f8e6615 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -158,9 +158,8 @@ class GkeysGPG(GPG):
                 message += "\n gkey..: %s" % (str(gkey.fingerprint))
                 logger.error(message)
             # Save the gkey seed to the installed db
-            self.seedfile.update(gkey)
-            if not self.seedfile.save():
-                logger.error("GkeysGPG.add_key(); failed to save seed: " + gkey.nick)
+            success = self.update_gkey(gkey, save=True)
+            if not success:
                 return []
             results.append(result)
         return results
@@ -190,21 +189,32 @@ class GkeysGPG(GPG):
         self.set_keyserver()
         self.set_keydir(gkey.keydir, 'refresh-keys', reset=True)
         self.set_keyring('pubring.gpg', 'refresh-keys', reset=False)
+        self.set_keyseedfile()
         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))
+        self.update_gkey(gkey, save=True)
         return result
 
 
-    def update_key(self, gkey, keydir):
+    def update_gkey(self, gkey, save=False):
         '''Update the specified key in the specified keydir
 
         @param key: tuple of (name, nick, keydir, fingerprint)
         @param keydir: the keydir to add the key to
         '''
-        return []
+        # Update the gkey seed and save it to the installed db
+        lresults = []
+        for fpr in gkey.keys:
+            lresults.append(self.list_keys(gkey.keydir, fpr, colons=True))
+        self.seedfile.update(gkey.update(lresults))
+        if save and not self.seedfile.save():
+            logger.error("GkeysGPG.refresh_key(); failed to save seed: " + gkey.nick)
+            return False
+        return True
+
 
 
     def list_keys(self, keydir, fingerprint=None, colons=False):
@@ -225,7 +235,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', '--with-fingerprint'])
+        self.config.options['tasks'][task].extend(['--keyid-format', 'long', '--fingerprint', '--fingerprint'])
         if colons:
             task_value = ['--with-colons']
             self.config.options['tasks'][task].extend(task_value)
@@ -315,7 +325,7 @@ class GkeysGPG(GPG):
         return results
 
 
-    def set_keyseedfile(self, trap_errors):
+    def set_keyseedfile(self, trap_errors=True):
         if not self.keydir:
             logger.debug("GkeysGPG.set_keyseedfile(); self.keydir error")
         self.seedfile = Seeds(pjoin(self.keydir, 'gkey.seeds'), self.config)


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-31 21:34 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-31 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     6d02096f1b8afbf3ed2126def65cfbe2d65d0237
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 28 08:24:22 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=6d02096f

gkeys/gkey.py: Separate uid string printing for list type output

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

diff --git a/gkeys/gkeys/gkey.py b/gkeys/gkeys/gkey.py
index 463f007..130a5d5 100644
--- a/gkeys/gkeys/gkey.py
+++ b/gkeys/gkeys/gkey.py
@@ -18,7 +18,10 @@ GKEY_STRING = '''    ----------
     Name.........: %(name)s
     Nick.........: %(nick)s
     Keydir.......: %(keydir)s
-    UID..........: %(uid)s
+'''
+
+GKEY_UID = \
+'''    UID..........: %(uid)s
 '''
 
 GKEY_FINGERPRINTS = \
@@ -48,9 +51,10 @@ class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'keys', 'fingerprint',
             'name': self.name,
             'nick': self.nick,
             'keydir': self.keydir,
-            'uid': self.uid,
             }
         output = GKEY_STRING % gkey
+        for uid in self.uid:
+            output += GKEY_UID % {'uid': uid}
         for f in self.fingerprint:
             fingerprint = {'fingerprint': f, 'keyid': '0x' + f[-16:]}
             output += GKEY_FINGERPRINTS % fingerprint


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-31 21:34 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-31 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     9ee49f508de378f6b7a366d8c9dba062e2be3f24
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 28 00:25:24 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=9ee49f50

gkeys/actions.py: Add auto-search capability to verify

If verification fails with NO_PUBKEY, it then does a search for the correct verification keyring to verify with.

---
 gkeys/gkeys/actions.py | 86 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 59 insertions(+), 27 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 4a4f0eb..b92f3a2 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -659,14 +659,15 @@ 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': {},
-        }
+    def verify(self, args, messages=None):
+        '''File verification action
+
+        @ param args: argparse.parse_args instance
+        @param messages: list, private internal option used for recursion only
+        '''
+        if messages == None:
+            messages = []
+
         if not args.filename:
             return (False, ['Please provide a signed file.'])
         if not args.category:
@@ -677,10 +678,24 @@ class Actions(object):
         keys = handler.load_category(args.category)
         if not keys:
             return (False, ['No installed keys found, try installkey action.'])
+        key = handler.seeds.nick_search(args.nick)
+        if not key:
+            messages.append("Failed to find nick: %s in %s category"
+                % (args.nick, args.category))
+            args.category = self.config.get_key('verify-keyring')
+            args.nick = self.config.get_key('verify-nick')
+            return self.verify(args, messages)
+
         keyrings = self.config.get_key('keyring')
         catdir = os.path.join(keyrings, args.category)
         self.logger.debug("ACTIONS: verify; catdir = %s" % catdir)
         self.gpg = GkeysGPG(self.config, catdir)
+        return self._verify(args, handler, key, messages)
+
+
+    def _verify(self, args, handler, key, messages=None):
+        if messages == None:
+            messages = []
         filepath, signature  = args.filename, args.signature
         timestamp_path = None
         isurl = success = verified = False
@@ -715,7 +730,7 @@ class Actions(object):
             self.logger.debug("ACTIONS: verify; local file %s" % filepath)
             success = os.path.isfile(filepath)
         if not success:
-            messages = ["File %s cannot be retrieved." % filepath]
+            messages.append("File %s cannot be retrieved." % filepath)
         else:
             if not signature:
                 EXTENSIONS = ['.sig', '.asc', 'gpg','.gpgsig']
@@ -735,26 +750,36 @@ class Actions(object):
                         break
             else:
                 sig_path = signature
-            messages = []
             self.logger.info("Verifying file...")
             verified = False
-            key = keys.nick_search(args.nick)
-            if not key:
-                messages.append("Failed to find nick: %s in %s category"
-                    % (args.nick, args.category))
-                return (False, messages)
             results = self.gpg.verify_file(key, sig_path, filepath)
             keyid = key.keyid[0]
             (valid, trust) = results.verified
             if valid:
                 verified = True
-                messages = ["Verification succeeded.: %s" % (filepath),
+                messages.extend(["Verification succeeded.: %s" % (filepath),
                     "Key info...............: %s <%s>, %s"
-                    % ( key.name, key.nick, keyid)]
+                    % ( key.name, key.nick, keyid)])
             else:
-                messages = ["Verification failed..... %s:" % (filepath),
-                    "Key info................: %s <%s>, %s"
-                    % ( key.name, key.nick, keyid)]
+                messages.extend(["Verification failed....: %s" % (filepath),
+                    "Key info...............: %s <%s>, %s"
+                    % ( key.name, key.nick, keyid)])
+                has_no_pubkey, s_keyid = results.no_pubkey
+                if has_no_pubkey:
+                    messages.append("Auto-searching for key.: %s" % s_keyid)
+                    # reset all but keyid and pass thru data
+                    args.keyid = s_keyid
+                    args.keydir = None
+                    args.fingerprint = None
+                    args.exact = False
+                    args.category = None
+                    args.nick = None
+                    args.name = None
+                    args.all = False
+                    keys = self.key_search(args, data_only=True)
+                    args.category = list(keys)[0]
+                    args.nick = keys[args.category][0].nick
+                    return self.verify(args, messages)
         return (verified, messages)
 
 
@@ -847,7 +872,7 @@ class Actions(object):
         return (True, ['Completed'])
 
 
-    def key_search(self, args):
+    def key_search(self, args, data_only=False):
         '''Search for a key's seed field in the installed keys db'''
         handler = SeedHandler(self.logger, self.config)
         results = {}
@@ -866,14 +891,21 @@ class Actions(object):
                         results[cat].extend(found)
                     else:
                         results[cat] = found
-        msgs = []
+        keys = {}
         for cat in results:
-            msgs.append("Category: %s" % cat)
-            seen = []
+            keys[cat] = []
             for result in results[cat]:
-                if result and result.nick not in seen:
+                if result and result.nick not in keys[cat]:
                     if isinstance(result, GKEY):
-                        seen.append(result)
-            msgs.append(seen)
+                        keys[cat].append(result)
+        if data_only:
+            del found, cat, result, handler
+            return keys
+        msgs = []
+        for cat in list(keys):
+            msgs.append("Category: %s" % cat)
+            for result in keys[cat]:
+                msgs.append(result)
+        del keys, found, cat, result, handler
         return (True, msgs)
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-31 21:34 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-31 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     244ace4fee1054945eb97aad31919dba71374b0b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 26 21:15:22 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:25 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=244ace4f

gkeys: Add key-search action

Add _list_search() sub function.
Add category output and grouping.
Fix arg as a list searching as well as seed values as a list.
Use recursion to get to single value searches.
Make nick search to be partial unless --exact specified.
Move main key_search code to SeedHandler class, it is much better suited to this class.
Add 1name subparser option for single name entries only
Add seen tracking in key_search to eliminate duplicates
Add --all option to key-search
If --all is specified, it filters out search results to match a seed for all criteria specified.

---
 gkeys/gkeys/actions.py     | 34 ++++++++++++++++++++++++++++++++--
 gkeys/gkeys/base.py        | 17 +++++++++++++++++
 gkeys/gkeys/seed.py        | 43 ++++++++++++++++++++++++++++++++++++++++++-
 gkeys/gkeys/seedhandler.py | 25 +++++++++++++++++++++++++
 4 files changed, 116 insertions(+), 3 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index ded3df7..be1823f 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -35,7 +35,7 @@ Seed_Actions = ['----seeds----', 'add-seed', 'fetch-seed', 'list-cats',
     'list-seed', 'list-seedfiles', 'move-seed', 'remove-seed']
 
 Key_Actions = ['----keys-----', 'check-key', 'import-key', 'installed',
-    'install-key', 'list-key', 'move-key', 'refresh-key', 'remove-key',
+    'install-key', 'key-search', 'list-key', 'move-key', 'refresh-key', 'remove-key',
     'spec-check']
 
 General_Actions = ['---general---', 'sign','verify']
@@ -56,6 +56,7 @@ Action_Options = {
     'move-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'dest'],
     'installed': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
     'import-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
+    'key-search': ['nick', '1name', 'keydir', 'fingerprint', 'keyid', 'category', 'exact', 'all'],
     'verify': ['dest', 'nick', 'name', 'keydir', 'fingerprint', 'category', '1file', 'signature', 'timestamp'],
     'check-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
     'sign': ['nick', 'name', 'keydir', 'fingerprint', 'file', 'keyring'],
@@ -80,6 +81,7 @@ Action_Map = {
     'move-key': 'movekey',
     'installed': 'installed',
     'import-key': 'importkey',
+    'key-search': 'key_search',
     'verify': 'verify',
     'check-key': 'checkkey',
     'sign': 'sign',
@@ -845,5 +847,33 @@ class Actions(object):
         return (True, ['Completed'])
 
 
-
+    def key_search(self, args):
+        '''Search for a key's seed field in the installed keys db'''
+        handler = SeedHandler(self.logger, self.config)
+        results = {}
+        search_args = [x for x in
+            ['nick', 'name', 'keydir', 'fingerprint', 'keyid']
+            if getattr(args, x)]
+        if args.category:
+            handler.load_category(args.category)
+            results[args.category] = handler.key_search(args, search_args)
+        else:
+            for cat in list(self.config.get_key('seeds')):
+                handler.load_category(cat)
+                found = handler.key_search(args, search_args)
+                if found:
+                    if cat in results:
+                        results[cat].extend(found)
+                    else:
+                        results[cat] = found
+        msgs = []
+        for cat in results:
+            msgs.append("Category: %s" % cat)
+            seen = []
+            for result in results[cat]:
+                if result and result.nick not in seen:
+                    if isinstance(result, GKEY):
+                        seen.append(result)
+            msgs.append(seen)
+        return (True, msgs)
 

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 499c291..541a12c 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -46,11 +46,23 @@ class CliBase(object):
 
 
     @staticmethod
+    def _option_all(parser=None):
+        parser.add_argument('-a', '--all', dest='all',
+            action='store_true', default=False,
+            help='Match all inputs arguments in searches')
+
+    @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_exact(parser=None):
+        parser.add_argument('-e', '--exact', dest='exact',
+            action='store_true', default=False,
+            help='Use CASE matching in searches')
+
+    @staticmethod
     def _option_fingerprint(parser=None):
         parser.add_argument('-f', '--fingerprint', dest='fingerprint',
             default=None, nargs='+',
@@ -83,6 +95,11 @@ class CliBase(object):
             default=None, help='The name of the the key')
 
     @staticmethod
+    def _option_1name(parser=None):
+        parser.add_argument('-N', '--name', dest='name',
+            default=None, help='The name of the the key')
+
+    @staticmethod
     def _option_category(parser=None):
         parser.add_argument('-C', '--category',
             dest='category', default=None,

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index f0cb019..2406c1a 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -160,7 +160,48 @@ class Seeds(object):
         try:
             return self.seeds[nick]
         except KeyError:
-            return None
+            return []
+
+
+    def field_search(self, field, value, exact=False):
+        '''Searches the seeds for a matching nick
+
+        @param keyid: string
+        @returns GKEY instance or None
+        '''
+        results = []
+        if field == 'nick' and exact:
+            return self.nick_search(value)
+        for nick in self.seeds:
+            seed = self.seeds[nick]
+            val = getattr(seed, field)
+            if isinstance(val, list) or isinstance(value, list):
+                if  self._list_search(value, val, exact):
+                    results.append(seed)
+            elif exact:
+                if value in val:
+                    results.append(seed)
+            else:
+                if value.lower() in val.lower():
+                    results.append(seed)
+
+        return results
+
+
+    def _list_search(self, find, values, exact):
+        if isinstance(find, list):
+            found = []
+            for f in find:
+                found.append(self._list_search(f, values, exact))
+            return True in found
+        for val in values:
+            if exact:
+                if find in val:
+                    return True
+            else:
+                if find.lower() in val.lower():
+                    return True
+        return False
 
 
     def _error(self, err):

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index bb233f9..2222bd2 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -26,6 +26,7 @@ class SeedHandler(object):
         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}')
+        self.seeds = None
 
 
     def new(self, args, checkgkey=False):
@@ -77,6 +78,7 @@ class SeedHandler(object):
             "%s" % filepath)
         seeds = Seeds(config=self.config)
         seeds.load(filepath)
+        self.seeds = seeds
         return seeds
 
     def load_category(self, category, nicks=None):
@@ -113,6 +115,7 @@ class SeedHandler(object):
         except OSError as error:
             self.logger.debug("SeedHandler: load_category; OSError for %s" % catdir)
             self.logger.debug("Error was: %s" % str(error))
+        self.seeds = seeds
         return seeds
 
     def fetch_seeds(self, seeds, args, verified_dl=None):
@@ -188,3 +191,25 @@ class SeedHandler(object):
             self.logger.error('  GPGKey: Non hexadecimal digits in ' + 'fingerprint for fingerprint: ' + fingerprint)
             is_good = False
         return is_good, fingerprint
+
+    def key_search(self, args, search_args):
+        '''Performs a search for all listed args in the seeds'''
+        results = []
+        self.logger.debug("_field_search search_args: %s" % str(search_args))
+        found = {}
+        search_args.sort()
+        for arg in search_args:
+            seeds = self.seeds.field_search(arg, getattr(args, arg), args.exact)
+            for seed in seeds:
+                if seed.nick in found:
+                    found[seed.nick]['args'].append(arg)
+                else:
+                    found[seed.nick] = {'args': [arg], 'seed': seed}
+        if args.all:
+            for possible in sorted(found):
+                if search_args == found[possible]['args']:
+                    results.append(found[possible]['seed'])
+        else:
+            for nick in sorted(found):
+                results.append(found[nick]['seed'])
+        return results


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-31 21:34 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-31 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     4a7e7e54a6b6ce280a221a0b039bebafd9d49701
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 27 21:51:17 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=4a7e7e54

gkeys: Add keys and uid options to actions and seed handling

Add code to auto-update existing installed gkey.seeds files with the additional data.

---
 gkeys/gkeys/actions.py     | 32 ++++++++++++++++----------------
 gkeys/gkeys/base.py        | 11 +++++++++++
 gkeys/gkeys/seed.py        |  6 ++++++
 gkeys/gkeys/seedhandler.py |  5 +++++
 4 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 9baecaa..4a4f0eb 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -44,24 +44,24 @@ Available_Actions = General_Actions + Key_Actions + Seed_Actions
 
 Action_Options = {
     'list-cats': [],
-    'list-seed': ['nick', 'name', 'keydir', 'fingerprint', 'category', '1file'],
-    'add-seed': ['nick', 'name', 'keydir', 'fingerprint', 'category'],
-    'remove-seed': ['nick', 'name', 'keydir', 'fingerprint', 'category'],
-    'move-seed': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'dest'],
-    'fetch-seed': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
+    'list-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', '1file'],
+    'add-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'uid'],
+    'remove-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category'],
+    'move-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'dest'],
+    'fetch-seed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring'],
     'list-seedfiles': [],
-    'list-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'gpgsearch', 'keyid'],
-    'install-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', '1file'],
-    'remove-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
-    'move-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'dest'],
-    'installed': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
-    'import-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
-    'key-search': ['nick', '1name', 'keydir', 'fingerprint', 'keyid', 'category', 'exact', 'all'],
-    'verify': ['dest', 'nick', 'name', 'keydir', 'fingerprint', 'category', '1file', 'signature', 'timestamp'],
-    'check-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
+    'list-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'gpgsearch', 'keyid'],
+    'install-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', '1file'],
+    'remove-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring'],
+    'move-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'dest'],
+    'installed': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring'],
+    'import-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring'],
+    'key-search': ['nick', '1name', 'keydir', 'keys', 'fingerprint', 'keyid', 'category', 'exact', 'all'],
+    'verify': ['dest', 'nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', '1file', 'signature', 'timestamp'],
+    'check-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'keyid'],
     'sign': ['nick', 'name', 'keydir', 'fingerprint', 'file', 'keyring'],
-    'spec-check': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
-    'refresh-key': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
+    'spec-check': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'keyid'],
+    'refresh-key': ['nick', 'name', 'keydir', 'keys', 'fingerprint', 'category', 'keyring', 'keyid'],
     '---general---': [],
     '----seeds----': [],
     '----keys-----': [],

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 541a12c..2c0e114 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -85,6 +85,12 @@ class CliBase(object):
             help='The name of the keyring to use for verification, etc.')
 
     @staticmethod
+    def _option_keys(parser=None):
+        parser.add_argument('-K', '--keys', dest='keys', nargs='*',
+            default=None,
+            help='The name of the keyring to use for verification, etc.')
+
+    @staticmethod
     def _option_nick(parser=None):
         parser.add_argument('-n', '--nick', dest='nick', default=None,
             help='The nick associated with the the key')
@@ -167,6 +173,11 @@ class CliBase(object):
             action='store_true', default=False,
             help='Just Do It')
 
+    @staticmethod
+    def _option_uid(parser=None):
+        parser.add_argument('-u', '--uid', dest='uid', nargs='*', default=None,
+            help='The user ID, gpg key uid')
+
 
     def parse_args(self, args):
         '''Parse a list of aruments

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index 16fe0fd..67354f3 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -57,6 +57,12 @@ class Seeds(object):
                 self._error(err)
             return False
         for seed in list(seedlines.items()):
+            # GKEY class change auto-update
+            if not 'uid' in list(seed[1]):
+                seed[1]['uid'] = []
+            if not 'keys' in list(seed[1]):
+                seed[1]['keys'] = seed[1]['fingerprint'][:]
+
             #try:
             self.seeds[seed[0]] = GKEY(**seed[1])
             #except Exception as err:

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 33ed787..a9fb720 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -111,6 +111,11 @@ class SeedHandler(object):
                 if seed:
                     for nick in sorted(seed):
                         key = seed[nick]
+                        # GKEY class change auto-update
+                        if not 'uid' in list(key):
+                            key['uid'] = []
+                        if not 'keys' in list(key):
+                            key['keys'] = key['fingerprint'][:]
                         seeds.add(nick, GKEY(**key))
         except OSError as error:
             self.logger.debug("SeedHandler: load_category; OSError for %s" % catdir)


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-31 21:34 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-31 21:34 UTC (permalink / raw
  To: gentoo-commits

commit:     ffb2d93b1085c600cee9bd6fa2cf17c098c3bc2c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 27 21:33:07 2014 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Dec 30 21:42:26 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=ffb2d93b

gkeys: Move all GKEYS definitions to it's own file

Fix imports in other files.

---
 gkeys/gkeys/actions.py     |  2 +-
 gkeys/gkeys/checks.py      |  2 +-
 gkeys/gkeys/config.py      | 41 +---------------------------------
 gkeys/gkeys/gkey.py        | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 gkeys/gkeys/seed.py        |  2 +-
 gkeys/gkeys/seedhandler.py |  2 +-
 6 files changed, 60 insertions(+), 44 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index be1823f..9baecaa 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -27,7 +27,7 @@ from shutil import rmtree
 
 from gkeys.lib import GkeysGPG
 from gkeys.seedhandler import SeedHandler
-from gkeys.config import GKEY
+from gkeys.gkey import GKEY
 from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn
 
 

diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py
index 69df9c4..bddad5f 100644
--- a/gkeys/gkeys/checks.py
+++ b/gkeys/gkeys/checks.py
@@ -12,7 +12,7 @@
 import time
 from collections import namedtuple, OrderedDict
 
-from gkeys.config import GKEY_CHECK
+from gkeys.gkey import GKEY_CHECK
 
 from pyGPG.mappings import (ALGORITHM_CODES, CAPABILITY_MAP,
     KEY_VERSION_FPR_LEN, VALIDITY_MAP, VALID_LIST)

diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py
index 6eba2b3..8fa4c1b 100644
--- a/gkeys/gkeys/config.py
+++ b/gkeys/gkeys/config.py
@@ -6,14 +6,13 @@
 
     Holds configuration keys and values
 
-    @copyright: 2012 by Brian Dolbec <dol-sen@gentoo.org>
+    @copyright: 2012-2015 by Brian Dolbec <dol-sen@gentoo.org>
     @license: GNU GNU GPL2, see COPYING for details.
 """
 
 import os
 
 from collections import OrderedDict
-from collections import namedtuple
 
 from pyGPG.config import GPGConfig
 
@@ -30,16 +29,6 @@ EPREFIX = "@GENTOO_PORTAGE_EPREFIX@"
 if "GENTOO_PORTAGE_EPREFIX" in EPREFIX:
     EPREFIX = ''
 
-GKEY_STRING = '''    ----------
-    Name.........: %(name)s
-    Nick.........: %(nick)s
-    Keydir.......: %(keydir)s
-'''
-
-GKEY_FINGERPRINTS = \
-'''    Keyid........: %(keyid)s
-      Fingerprint: %(fingerprint)s
-'''
 
 MAPSEEDS = { 'dev' : 'gentoodevs.seeds', 'rel': 'gentoo.seeds' }
 
@@ -137,31 +126,3 @@ class GKeysConfig(GPGConfig):
         else:
             return super(GKeysConfig, self)._get_(key, subkey)
 
-
-class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
-    '''Class to hold the relavent info about a key'''
-
-    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]
-
-
-    @property
-    def pretty_print(self):
-        '''Pretty printing a GKEY'''
-        gkey = {'name': self.name, 'nick': self.nick, 'keydir': self.keydir}
-        output = GKEY_STRING % gkey
-        for f in self.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__ = ()

diff --git a/gkeys/gkeys/gkey.py b/gkeys/gkeys/gkey.py
new file mode 100644
index 0000000..41c6d8b
--- /dev/null
+++ b/gkeys/gkeys/gkey.py
@@ -0,0 +1,55 @@
+#
+#-*- coding:utf-8 -*-
+
+"""
+    Gentoo-keys - gkey.py
+
+    Holds GKEY class and related values
+
+    @copyright: 2012-2015 by Brian Dolbec <dol-sen@gentoo.org>
+    @license: GNU GNU GPL2, see COPYING for details.
+"""
+
+
+from collections import namedtuple
+
+
+GKEY_STRING = '''    ----------
+    Name.........: %(name)s
+    Nick.........: %(nick)s
+    Keydir.......: %(keydir)s
+'''
+
+GKEY_FINGERPRINTS = \
+'''    Keyid........: %(keyid)s
+      Fingerprint: %(fingerprint)s
+'''
+
+
+class GKEY(namedtuple('GKEY', ['nick', 'name', 'keydir', 'fingerprint'])):
+    '''Class to hold the relavent info about a key'''
+
+    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]
+
+
+    @property
+    def pretty_print(self):
+        '''Pretty printing a GKEY'''
+        gkey = {'name': self.name, 'nick': self.nick, 'keydir': self.keydir}
+        output = GKEY_STRING % gkey
+        for f in self.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__ = ()

diff --git a/gkeys/gkeys/seed.py b/gkeys/gkeys/seed.py
index 2406c1a..16fe0fd 100644
--- a/gkeys/gkeys/seed.py
+++ b/gkeys/gkeys/seed.py
@@ -20,7 +20,7 @@ import json
 import os
 
 from gkeys.log import logger
-from gkeys.config import GKEY
+from gkeys.gkey import GKEY
 from gkeys.fileops import ensure_dirs
 
 

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index 2222bd2..33ed787 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -14,7 +14,7 @@ import os
 import re
 from json import load
 
-from gkeys.config import GKEY
+from gkeys.gkey import GKEY
 from gkeys.seed import Seeds
 from gkeys.fileops import ensure_dirs
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-26 18:37 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-26 18:37 UTC (permalink / raw
  To: gentoo-commits

commit:     aa706673eb76355bedfd714f5b4966ab87d1d7d6
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 26 09:41:38 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 26 09:41:38 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=aa706673

gkeys: Separate and sort the avaialbe actions into groups

Create false actions for the 3 groups to help improve the argparse help output.
These stubb functions can be used later to organize and print the group specific actions only.

---
 gkeys/gkeys/actions.py | 35 +++++++++++++++++++++++++++++++----
 gkeys/gkeys/base.py    |  3 +++
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 4814389..ea42b6d 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -30,10 +30,16 @@ from gkeys.seedhandler import SeedHandler
 from gkeys.config import GKEY
 from gkeys.checks import SPECCHECK_SUMMARY, convert_pf, convert_yn
 
-Available_Actions = ['listcats', 'listseed', 'addseed', 'removeseed', 'moveseed', 'fetchseed',
-            'listseedfiles', 'listkey', 'installkey', 'removekey', 'movekey',
-            'installed', 'importkey', 'verify', 'checkkey', 'sign', 'speccheck',
-            'refreshkey']
+
+Seed_Actions = ['SEED_COMMANDS', 'addseed', 'fetchseed', 'listcats', 'listseed', 'listseedfiles',
+    'moveseed', 'removeseed']
+
+Key_Actions = ['KEY_COMMANDS', 'checkkey', 'importkey', 'installed', 'installkey', 'listkey',
+    'movekey', 'refreshkey', 'removekey']
+
+General_Actions = ['GENERAL_COMMANDS', 'sign','verify']
+
+Available_Actions = Seed_Actions + Key_Actions + General_Actions
 
 Action_Options = {
     'listcats': [],
@@ -54,6 +60,9 @@ Action_Options = {
     'sign': ['nick', 'name', 'keydir', 'fingerprint', 'file', 'keyring'],
     'speccheck': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
     'refreshkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'keyid'],
+    'GENERAL_COMMANDS': [],
+    'SEED_COMMANDS': [],
+    'KEY_COMMANDS': [],
 }
 
 
@@ -67,6 +76,24 @@ class Actions(object):
         self.seeds = None
 
 
+    @staticmethod
+    def SEED_COMMANDS(args):
+        '''------< seed actions >-------'''
+        pass
+
+
+    @staticmethod
+    def KEY_COMMANDS(args):
+        '''-------< key actions >--------'''
+        pass
+
+
+    @staticmethod
+    def GENERAL_COMMANDS(args):
+        '''-----< general actions >------'''
+        pass
+
+
     def listseed(self, args):
         '''Pretty-print the selected seed file(s)'''
         handler = SeedHandler(self.logger, self.config)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index f9a019f..c37d536 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -187,6 +187,9 @@ class CliBase(object):
         if not action:
             parser.print_usage()
             sys.exit(1)
+        elif action in ['GENERAL_COMMANDS', 'KEY_COMMANDS', 'SEED_COMMANDS']:
+            parser.print_help()
+            sys.exit(1)
         return parsed_args
 
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-26 18:37 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-26 18:37 UTC (permalink / raw
  To: gentoo-commits

commit:     c3a16fa68f5f85de440f5e8526800ac69090a4c9
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 26 09:46:44 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 26 09:46:44 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=c3a16fa6

gkeys/base.py: Add a justdoit option, fix boolean options

---
 gkeys/gkeys/base.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index c37d536..201f31c 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -128,8 +128,8 @@ class CliBase(object):
 
     @staticmethod
     def _option_timestamp(parser=None):
-        parser.add_argument('-t', '--timestamp', dest='timestamp', type=bool,
-            default=False,
+        parser.add_argument('-t', '--timestamp', dest='timestamp',
+            action='store_true', default=False,
             help='Turn on timestamp use')
 
     @staticmethod
@@ -139,9 +139,16 @@ class CliBase(object):
 
     @staticmethod
     def _option_status(parser=None):
-        parser.add_argument('-A', '--status', default=False,
+        parser.add_argument('-A', '--status', action='store_true',
+            default=False,
             help='The active status of the member')
 
+    @staticmethod
+    def _option_justdoit(parser=None):
+        parser.add_argument('--justdoit', dest='justdoit',
+            action='store_true', default=False,
+            help='Just Do It')
+
 
     def parse_args(self, args):
         '''Parse a list of aruments


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-26 18:37 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-26 18:37 UTC (permalink / raw
  To: gentoo-commits

commit:     9f1d92c2e9c48af8a39dfcf1bdc044595ee3180c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 26 09:29:17 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 26 09:29:17 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=9f1d92c2

gkeys/base.py: Improve help layout, unify no action help with py2.7

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

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 2b32908..b09082f 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -164,7 +164,10 @@ class CliBase(object):
             help='The logging level to set for the logfile')
 
 
-        subparsers = parser.add_subparsers(help='actions')
+        subparsers = parser.add_subparsers(
+            title='Subcommands',
+            description='Valid subcommands',
+            help='Additional help')
         for name in self.cli_config['Available_Actions']:
             action_method = getattr(self.cli_config['Actions'], name)
             actiondoc = action_method.__doc__
@@ -183,7 +186,7 @@ class CliBase(object):
         parsed_args = parser.parse_args(args)
         action = getattr(parsed_args, 'action', None)
         if not action:
-            parser.print_help()
+            parser.print_usage()
             sys.exit(1)
         return parsed_args
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-26  5:02 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-26  5:02 UTC (permalink / raw
  To: gentoo-commits

commit:     8c2c8fb37f5ad311e18b94f3ea3960ea4405376f
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 26 04:59:32 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 26 04:59:32 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=8c2c8fb3

gkeys/actions.py: Verification output formatting tweaks

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index aa1aa08..4814389 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -697,11 +697,11 @@ class Actions(object):
                 verified = True
                 messages = ["Verification succeeded.: %s" % (filepath),
                     "Key info...............: %s <%s>, %s"
-                    % ( key.name, key.nick,keyid)]
+                    % ( key.name, key.nick, keyid)]
             else:
-                messages = ["Verification failed.....:" % (filepath),
+                messages = ["Verification failed..... %s:" % (filepath),
                     "Key info................: %s <%s>, %s"
-                    % ( key.name, key.nick,keyid)]
+                    % ( key.name, key.nick, keyid)]
         return (verified, messages)
 
 


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-26  5:02 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-26  5:02 UTC (permalink / raw
  To: gentoo-commits

commit:     9403b0561283b504880e5808dd9efada2c89eeb8
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 26 04:58:56 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 26 04:58:56 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=9403b056

gkeys/actions.py: py2/py3 fixes for input/raw_input

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index dddd48a..aa1aa08 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -13,6 +13,13 @@
 from __future__ import print_function
 
 import os
+import sys
+
+if sys.version_info[0] >= 3:
+    py_input = input
+else:
+    py_input = raw_input
+
 
 from collections import defaultdict
 from json import load
@@ -494,10 +501,10 @@ class Actions(object):
                 success = False
             else:
                 self.output(['', [gkey]], '\n Found GKEY seed:')
-                ans = raw_input("Do you really want to remove %s?[y/n]: "
+                ans = py_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]: "
+                    ans = py_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."]


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-26  5:02 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-26  5:02 UTC (permalink / raw
  To: gentoo-commits

commit:     4f703027bb652c69c5328bc9745efcff2e6ed31c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 26 05:00:09 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Dec 26 05:00:09 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=4f703027

gkeys/base.py: Tweak -k, --keyring help message

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

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 4184cfc..2b32908 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -69,8 +69,8 @@ class CliBase(object):
 
     @staticmethod
     def _option_keyring(parser=None):
-        parser.add_argument('-k', '--keyring', dest='keyring', default='trusted_keyring',
-            help='The name of the keyring to use')
+        parser.add_argument('-k', '--keyring', dest='keyring', default=None,
+            help='The name of the keyring to use for verification, etc.')
 
     @staticmethod
     def _option_nick(parser=None):


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-25 22:07 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-25 22:07 UTC (permalink / raw
  To: gentoo-commits

commit:     4f03ed0fc2f6f7b076758f35ca83334cecd407eb
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 25 22:04:07 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 25 22:04:07 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=4f03ed0f

gkeys/base.py: Fix >=py3.3 argparse regression handling subparsers

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

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 5ad92e7..4184cfc 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -180,7 +180,12 @@ class CliBase(object):
             action_parser.set_defaults(action=name)
             self._add_options(action_parser, self.cli_config['Action_Options'][name])
 
-        return parser.parse_args(args)
+        parsed_args = parser.parse_args(args)
+        action = getattr(parsed_args, 'action', None)
+        if not action:
+            parser.print_help()
+            sys.exit(1)
+        return parsed_args
 
 
     def _add_options(self, parser, options):


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-25 22:07 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-25 22:07 UTC (permalink / raw
  To: gentoo-commits

commit:     8fb33b3e010e36ae3c669494eccb5fac79ffcc4e
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 25 20:51:21 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 25 20:51:21 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=8fb33b3e

gkeys.actions.py: Remove global ssl-fetch import in favor of the embedded import

For server installations (currently vulture.g.o) it may not need ssl-fetch nor have dev-python/requests installed.

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 172b43e..de8446d 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -17,7 +17,6 @@ import os
 from collections import defaultdict
 from json import load
 from shutil import rmtree
-from sslfetch.connections import Connector
 
 from gkeys.lib import GkeysGPG
 from gkeys.seedhandler import SeedHandler


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-25 20:43 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-25 20:43 UTC (permalink / raw
  To: gentoo-commits

commit:     26352316808100b05b5504b69ed8d1b22053ddb2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 25 20:38:17 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 25 20:38:17 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=26352316

gkeys/base.py: Py3 compatibility fix

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

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index e7dd710..5ad92e7 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -15,11 +15,16 @@ from __future__ import print_function
 
 
 import argparse
+import sys
 
 from gkeys import config, fileops, seed, lib
 from gkeys.log import log_levels, set_logger
 
 
+if sys.version_info[0] >= 3:
+    unicode = str
+
+
 class CliBase(object):
     '''Common cli and argsparse options class'''
 
@@ -246,7 +251,7 @@ class CliBase(object):
         if header:
             print(header)
         for msg in results:
-            if isinstance(msg, str) or isinstance(msg, unicode):
+            if type(msg) in [str, unicode]:
                 print('    ', msg)
             else:
                 try:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-25 20:43 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-25 20:43 UTC (permalink / raw
  To: gentoo-commits

commit:     5cbb4cb9100dc4451d359e7a711d2bd84837c64c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 25 20:31:35 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 25 20:31:35 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=5cbb4cb9

gkeys/SaneConfigParser: Fix py3 imports

---
 gkeys/gkeys/SaneConfigParser.py | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/gkeys/gkeys/SaneConfigParser.py b/gkeys/gkeys/SaneConfigParser.py
index 3bb69b5..0616335 100644
--- a/gkeys/gkeys/SaneConfigParser.py
+++ b/gkeys/gkeys/SaneConfigParser.py
@@ -1,14 +1,11 @@
 
 import sys
 
-# py3.2
-if sys.hexversion >= 0x30200f0:
-    from configparser import configparser as ConfigParser
+try:
+    from configparser import ConfigParser
     from configparser import NoSectionError
-    py3 = True
-else:
+except:
     from ConfigParser import ConfigParser, NoSectionError
-    py3 = False
 
 
 class SaneConfigParser(ConfigParser):


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-25 20:43 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-25 20:43 UTC (permalink / raw
  To: gentoo-commits

commit:     3bc9f57e8a2f2abe668b496803a5cd35f8ae2dd1
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 25 18:38:41 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 25 18:38:41 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=3bc9f57e

gkeys/base.py: Pass the cli_config['prog'] to the logger initialization

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

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index cadafc7..e7dd710 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -200,7 +200,7 @@ class CliBase(object):
         self.config.read_config()
 
         # establish our logger and update it in the imported files
-        logger = set_logger('gkeys', self.config['logdir'], args.debug,
+        logger = set_logger(self.cli_config['prog'], self.config['logdir'], args.debug,
             dirmode=int(self.config.get_key('permissions', 'directories'),0),
             filemask=int(self.config.get_key('permissions', 'files'),0))
         self.config.logger = logger


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

commit:     9287582dbc97699f80f5bbe4c52819b378510d89
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 23 21:18:08 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 23 21:18:08 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=9287582d

gkeys/actions.py: Improve category error message

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 92dbb70..cba2c1c 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -304,7 +304,7 @@ class Actions(object):
     def checkkey(self, args):
         '''Check keys actions'''
         if not args.category:
-            return (False, ["Please specify seeds type."])
+            return (False, ["Please specify seeds category."])
         self.logger.debug("ACTIONS: checkkey; args: %s" % str(args))
         handler = SeedHandler(self.logger, self.config)
         seeds = handler.load_category(args.category)
@@ -352,7 +352,7 @@ class Actions(object):
     def speccheck(self, args):
         '''Check keys actions'''
         if not args.category:
-            return (False, ["Please specify seeds type."])
+            return (False, ["Please specify seeds category."])
         self.logger.debug("ACTIONS: speccheck; args: %s" % str(args))
         handler = SeedHandler(self.logger, self.config)
         seeds = handler.load_category(args.category)


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

commit:     ffab5352db1f82250f57c234f2bc296abe413eaa
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 23 21:17:16 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 23 21:17:16 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=ffab5352

gkeys/actions.py: Add a listcats action 

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 82d608d..92dbb70 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -24,12 +24,13 @@ 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',
+Available_Actions = ['listcats', 'listseed', 'addseed', 'removeseed', 'moveseed', 'fetchseed',
             'listseedfiles', 'listkey', 'installkey', 'removekey', 'movekey',
             'installed', 'importkey', 'verify', 'checkkey', 'sign', 'speccheck',
             'refreshkey']
 
 Action_Options = {
+    'listcats': [],
     'listseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile', '1file'],
     'addseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile'],
     'removeseed': ['nick', 'name', 'keydir', 'fingerprint', 'seedfile'],
@@ -692,6 +693,13 @@ class Actions(object):
         return (verified, messages)
 
 
+    def listcats(self, args):
+        '''List seed file definitions found in the config'''
+        seeds = list(self.config.get_key('seeds'))
+        return (True, {"Categories/Seedfiles defined: %s\n"
+            % (",  ".join(seeds)): True})
+
+
     def listseedfiles(self, args):
         '''List seed files found in the configured seed directory'''
         seedsdir = self.config.get_key('seedsdir')


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

commit:     ec872348954a8850c071d0a56d502731389b03ea
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 23 23:52:48 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 23 23:52:48 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=ec872348

gkeys: Use -C, --category exclusivley for consistency

No longer use -S, --seedfile for seed file operations.
With the new dynamic category handling, it was redundant.

---
 gkeys/gkeys/actions.py | 20 ++++++++++----------
 gkeys/gkeys/base.py    |  2 --
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index 094ea71..172b43e 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -31,14 +31,14 @@ Available_Actions = ['listcats', 'listseed', 'addseed', 'removeseed', 'moveseed'
 
 Action_Options = {
     'listcats': [],
-    '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'],
+    'listseed': ['nick', 'name', 'keydir', 'fingerprint', 'category', '1file'],
+    'addseed': ['nick', 'name', 'keydir', 'fingerprint', 'category'],
+    'removeseed': ['nick', 'name', 'keydir', 'fingerprint', 'category'],
+    'moveseed': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'dest'],
+    'fetchseed': ['nick', 'name', 'keydir', 'fingerprint', 'category'],
     'listseedfiles': [],
     'listkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'gpgsearch', 'keyid'],
-    'installkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'seedfile', '1file'],
+    'installkey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', '1file'],
     'removekey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
     'movekey': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring', 'dest'],
     'installed': ['nick', 'name', 'keydir', 'fingerprint', 'category', 'keyring'],
@@ -68,7 +68,7 @@ class Actions(object):
         self.logger.debug("ACTIONS: listseed; kwargs: %s" % str(kwargs))
         if not self.seeds:
             try:
-                self.seeds = handler.load_seeds(args.seedfile, args.nick)
+                self.seeds = handler.load_seeds(args.category, args.nick)
             except ValueError:
                 return (False, ["Failed to load seed file. Consider fetching seedfiles."])
         if self.seeds:
@@ -82,7 +82,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.seedfile, args, self.verify)
+        success, messages = handler.fetch_seeds(args.category, args, self.verify)
 
         messages.append("")
         messages.append("Fetch operation completed")
@@ -273,7 +273,7 @@ class Actions(object):
             # get confirmation
             # fill in code here
             keyring = self.config.get_key('keyring')
-            catdir = os.path.join(keyring, args.seedfile)
+            catdir = os.path.join(keyring, args.category)
             self.logger.debug("ACTIONS: installkey; catdir = %s" % catdir)
             self.gpg = GkeysGPG(self.config, catdir)
             results = {}
@@ -696,7 +696,7 @@ class Actions(object):
     def listcats(self, args):
         '''List seed file definitions found in the config'''
         seeds = list(self.config.get_key('seeds'))
-        return (True, {"Categories/Seedfiles defined: %s\n"
+        return (True, {"Categories defined: %s\n"
             % (",  ".join(seeds)): True})
 
 

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index af66ff3..cadafc7 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -221,8 +221,6 @@ class CliBase(object):
         cat = None
         if 'category' in args:
             cat = args.category
-        elif 'seedfile' in args:
-            cat = args.seedfile
         if not self._check_category(cat):
             return False
 


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

commit:     3456ab0d1b163cda2ab6449ef5e5fe16be5e1793
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 23 21:18:57 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 23 21:18:57 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=3456ab0d

gkeys/actions.py: Fix listseed action for the new category/seedfile handling

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index cba2c1c..094ea71 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -68,7 +68,7 @@ class Actions(object):
         self.logger.debug("ACTIONS: listseed; kwargs: %s" % str(kwargs))
         if not self.seeds:
             try:
-                self.seeds = handler.load_seeds(args.seedfile, args.filename)
+                self.seeds = handler.load_seeds(args.seedfile, args.nick)
             except ValueError:
                 return (False, ["Failed to load seed file. Consider fetching seedfiles."])
         if self.seeds:


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

commit:     2e6471b039548e303519f2253fbe2645b8c84812
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 23 21:12:49 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 23 21:12:49 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=2e6471b0

gkeys/lib.py: fix a missed mode setting for an ensure_dirs() call

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

diff --git a/gkeys/gkeys/lib.py b/gkeys/gkeys/lib.py
index 50ed63e..67c94ae 100644
--- a/gkeys/gkeys/lib.py
+++ b/gkeys/gkeys/lib.py
@@ -132,7 +132,8 @@ class GkeysGPG(GPG):
         self.set_keydir(gkey.keydir, 'recv-keys', reset=True)
         self.set_keyring('pubring.gpg', 'recv-keys', reset=False)
         logger.debug("LIB: add_key; ensure dirs: " + self.keydir)
-        ensure_dirs(str(self.keydir))
+        mode = int(self.config.get_key('permissions', 'directories'),0)
+        ensure_dirs(str(self.keydir), mode=mode)
         self.set_keyseedfile(trap_errors=False)
         results = []
         for fingerprint in gkey.fingerprint:


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

commit:     316554e0b6875e86e4ecd96a9eca48fa1966140f
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 23 21:11:57 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 23 21:11:57 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=316554e0

gkeys/base.py: Make the category/seedfile choices dynamic

---
 gkeys/gkeys/base.py | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index a5e3bfa..af66ff3 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -80,7 +80,7 @@ class CliBase(object):
     @staticmethod
     def _option_category(parser=None):
         parser.add_argument('-C', '--category',
-            choices=['rel', 'dev', 'overlays', 'sign'], dest='category', default=None,
+            dest='category', default=None,
             help='The key or seed directory category to use or update')
 
     @staticmethod
@@ -216,6 +216,16 @@ class CliBase(object):
             logger.debug("Main: run; Found alternate config request: %s"
                 % args.config)
 
+        # check if a -C, --category was input
+        # if it was, check if the category is listed in the [seeds]
+        cat = None
+        if 'category' in args:
+            cat = args.category
+        elif 'seedfile' in args:
+            cat = args.seedfile
+        if not self._check_category(cat):
+            return False
+
         # establish our actions instance
         self.actions = self.cli_config['Actions'](self.config, self.output_results, logger)
 
@@ -251,3 +261,18 @@ class CliBase(object):
 
     def output_failed(self, failed):
         pass
+
+
+    def _check_category(self, category=None):
+        '''Checks that the category (seedfile) is listed
+        in the [seeds] config or defaults['seeds'] section
+
+        @param args: configparser instance
+        @return boolean
+        '''
+        available_cats = list(self.config.defaults['seeds'])
+        if category and category not in available_cats:
+            self.config.logger.error("Invalid category or seedfile entered: %s" % category)
+            self.config.logger.error("Available categories or seedfiles: %s" % ', '.join(sorted(available_cats)))
+            return False
+        return True


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

commit:     6ccce1de425884f2279435381b756a50cec5b34b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 23 21:10:47 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 23 21:10:47 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=6ccce1de

gkeys/config.py: Subclass ConfigParser to be able to set defaults in the config

Allow some base defaults to be set in the [base] section of the config.
Reset our defaults from those changes.
Resave the new defaults back to the configparser for interpolation when retrieving the values.

---
 gkeys/gkeys/SaneConfigParser.py | 27 ++++++++++++++++++
 gkeys/gkeys/config.py           | 63 ++++++++++++++---------------------------
 2 files changed, 48 insertions(+), 42 deletions(-)

diff --git a/gkeys/gkeys/SaneConfigParser.py b/gkeys/gkeys/SaneConfigParser.py
new file mode 100644
index 0000000..3bb69b5
--- /dev/null
+++ b/gkeys/gkeys/SaneConfigParser.py
@@ -0,0 +1,27 @@
+
+import sys
+
+# py3.2
+if sys.hexversion >= 0x30200f0:
+    from configparser import configparser as ConfigParser
+    from configparser import NoSectionError
+    py3 = True
+else:
+    from ConfigParser import ConfigParser, NoSectionError
+    py3 = False
+
+
+class SaneConfigParser(ConfigParser):
+    '''This class overrides what I consider a buggy RawConfigParser.options()'''
+
+
+    def options(self, section):
+        """Return a list of option names for the given section name."""
+        try:
+            opts = self._sections[section].copy()
+        except KeyError:
+            raise NoSectionError(section)
+        if '__name__' in opts:
+            del opts['__name__']
+        return list(opts.keys())
+

diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py
index e6789ff..7e31909 100644
--- a/gkeys/gkeys/config.py
+++ b/gkeys/gkeys/config.py
@@ -11,22 +11,13 @@
 """
 
 import os
-import sys
 
 from collections import OrderedDict
-
-# py3.2
-if sys.hexversion >= 0x30200f0:
-    import configparser as ConfigParser
-else:
-    import ConfigParser
-
 from collections import namedtuple
 
-
 from pyGPG.config import GPGConfig
 
-from gkeys import log
+from gkeys.SaneConfigParser import SaneConfigParser
 from gkeys.utils import path
 
 
@@ -82,27 +73,17 @@ class GKeysConfig(GPGConfig):
 
     def _add_gkey_defaults(self):
         self.defaults['gkeysdir'] = path([self.root, EPREFIX, '/var/lib/gentoo/gkeys'])
-        self.defaults['dev-keydir'] = '%(gkeysdir)s/devs'
-        self.defaults['rel-keydir'] = '%(gkeysdir)s/release'
         self.defaults['keyring'] = '%(gkeysdir)s/keyring'
-        self.defaults['overlays-keydir'] = '%(gkeysdir)s/overlays'
         self.defaults['sign-keydir'] = '%(gkeysdir)s/sign',
         self.defaults['logdir'] = '/var/log/gkeys'
         # local directory to scan for seed files installed via ebuild, layman
         # or manual install.
         self.defaults['seedsdir'] = '%(gkeysdir)s/seeds'
-        self.defaults['seeds'] = {
-            'gentoo': '%(seedsdir)s/gentoo.seeds',
-            'gentoodevs': '%(seedsdir)s/gentoodevs.seeds',
-        }
+        self.defaults['seeds'] = {}
         self.defaults['keyserver'] = 'pool.sks-keyservers.net'
         # NOTE: files is umask mode in octal, directories is chmod mode in octal
         self.defaults['permissions'] = {'files': '0o002', 'directories': '0o775',}
-        self.defaults['seedurls'] = {
-            'gentoo': 'https://api.gentoo.org/gentoo-keys/seeds/gentoo.seeds',
-            'gentoodevs': 'https://api.gentoo.org/gentoo-keys/seeds/gentoodevs.seeds',
-            'gkey': 'gkeys',
-        }
+        self.defaults['seedurls'] = {}
         self.defaults['sign'] = {
             'key': 'fingerprint',
             'keydir': '~/.gkeys',
@@ -120,13 +101,24 @@ class GKeysConfig(GPGConfig):
                 % {'configdir': self.defaults['configdir']}
         for key in self.defaults:
             self.defaults[key] = self._sub_(self.defaults[key])
-        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.read(defaults['config'])
-
+        defaults = OrderedDict()
+        # Add only the defaults we want in the configparser
+        for key in ['gkeysdir', 'keyring', 'sign-keydir', 'logdir', 'seedsdir',
+            'keyserver']:
+            defaults[key] = self.defaults[key]
+        self.configparser = SaneConfigParser(defaults)
+        self.configparser.read(self.defaults['config'])
+        # I consider this hacky, but due to shortcomings of ConfigParser
+        # we need to reset the defaults redefined in the 'base' section
+        for key in self.configparser.options('base'):
+            self.defaults[key] = self.configparser.get('base', key)
+            defaults[key] = self.defaults[key]
+        self.configparser._defaults = defaults
+        for section in self.configparser.sections():
+            if section == 'base':
+                continue
+            for key in self.configparser.options(section):
+                self.defaults[section][key] = self.configparser.get(section, key)
 
     def get_key(self, key, subkey=None):
         return self._get_(key, subkey)
@@ -134,25 +126,12 @@ class GKeysConfig(GPGConfig):
 
     def _get_(self, key, subkey=None):
         if subkey:
-            if self.configparser and self.configparser.has_option(key, subkey):
-                if self.logger:
-                    self.logger.debug("Found %s in configparser... %s"
-                        % (key, str(self.configparser.get(key, subkey))))
-                return self._sub_(self.configparser.get(key, subkey))
-            #print("CONFIG: key, subkey", key, subkey)
             if key in self.options and subkey in self.options[key]:
                 return self._sub_(self.options[key][subkey])
             elif key in self.defaults and subkey in self.defaults[key]:
                 return self._sub_(self.defaults[key][subkey])
             else:
                 return super(GKeysConfig, self)._get_(key, subkey)
-        elif self.configparser and self.configparser.has_option('DEFAULT', key):
-            if self.logger:
-                self.logger.debug("Found %s in configparser... %s"
-                    % (key, str(self.configparser.get('DEFAULT', key))))
-                #self.logger.debug("type(key)= %s"
-                #    % str(type(self.configparser.get('DEFAULT', key))))
-            return self.configparser.get('DEFAULT', key)
         else:
             return super(GKeysConfig, self)._get_(key, subkey)
 


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

commit:     16cc8210932e1f34b5faa6f9984bf14acfb9ea42
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 23 21:16:17 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 23 21:16:17 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=16cc8210

gkeys: Use the new category handling system

---
 gkeys/gkeys/actions.py     | 39 +++++++++++++++++++++++++--------------
 gkeys/gkeys/seedhandler.py |  8 ++++----
 2 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index be59fb3..82d608d 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -175,8 +175,9 @@ class Actions(object):
         # get confirmation
         # fill in code here
         if not args.category:
-            args.category = 'rel'
-        catdir = self.config.get_key(args.category + "-category")
+            args.category = 'gentoo'
+        keyring = self.config.get_key('keyring')
+        catdir = os.path.join(keyring, args.category)
         self.logger.debug("ACTIONS: listkey; catdir = %s" % catdir)
         self.gpg = GkeysGPG(self.config, catdir)
         handler = SeedHandler(self.logger, self.config)
@@ -270,7 +271,8 @@ class Actions(object):
                     return (False, ["Search failed for search term"])
             # get confirmation
             # fill in code here
-            catdir = self.config.get_key(args.category + "-category")
+            keyring = self.config.get_key('keyring')
+            catdir = os.path.join(keyring, args.seedfile)
             self.logger.debug("ACTIONS: installkey; catdir = %s" % catdir)
             self.gpg = GkeysGPG(self.config, catdir)
             results = {}
@@ -305,7 +307,8 @@ class Actions(object):
         self.logger.debug("ACTIONS: checkkey; args: %s" % str(args))
         handler = SeedHandler(self.logger, self.config)
         seeds = handler.load_category(args.category)
-        catdir = self.config.get_key(args.category + "-category")
+        keyring = self.config.get_key('keyring')
+        catdir = os.path.join(keyring, args.category)
         self.logger.debug("ACTIONS: checkkey; catdir = %s" % catdir)
         self.gpg = GkeysGPG(self.config, catdir)
         results = {}
@@ -352,7 +355,8 @@ class Actions(object):
         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")
+        keyring = self.config.get_key('keyring')
+        catdir = os.path.join(keyring, args.category)
         self.logger.debug("ACTIONS: speccheck; catdir = %s" % catdir)
         self.gpg = GkeysGPG(self.config, catdir)
         results = {}
@@ -494,7 +498,8 @@ class Actions(object):
                 if ans in ["no", "n"]:
                     messages = ["Key removal aborted... Nothing to be done."]
                 else:
-                    catdir = self.config.get_key(args.category + "-category")
+                    keyring = self.config.get_key('keyring')
+                    catdir = os.path.join(keyring, args.category)
                     rm_candidate = os.path.join(catdir, gkey.nick)
                     self.logger.debug("ACTIONS: removekey; catdir = %s" % catdir)
                     if args.category:
@@ -515,7 +520,8 @@ class Actions(object):
     def importkey(self, args):
         '''Add a specified key to a specified keyring'''
         if args.category:
-            catdir = self.config.get_key(args.category + "-category")
+            keyring = self.config.get_key('keyring')
+            catdir = os.path.join(keyring, args.category)
             keyring_dir = self.config.get_key("keyring")
             self.logger.debug("ACTIONS: importkey; catdir = %s" % catdir)
             self.gpg = GkeysGPG(self.config, catdir)
@@ -538,8 +544,8 @@ class Actions(object):
                 if not results[gkey.name][0].failed:
                     print("Importing: ", gkey.name)
                     self.logger.debug("ACTIONS: importkey; importing key: %s", gkey.name)
-                    keyring = os.path.join(keyring_dir,args.keyring + '.gpg')
-                    self.gpg.add_to_keyring(gkey, catdir, keyring)
+                    _keyring = os.path.join(catdir, args.keyring + '.gpg')
+                    self.gpg.add_to_keyring(gkey, catdir, _keyring)
             if failed and self.output:
                 self.output([failed], "\n Failed to install:")
             if len(failed):
@@ -552,7 +558,8 @@ class Actions(object):
     def installed(self, args):
         '''Lists the installed key directories'''
         if args.category:
-            catdir = self.config.get_key(args.category + "-category")
+            keyring = self.config.get_key('keyring')
+            catdir = os.path.join(keyring, args.category)
         else:
             return (False, ["Please specify a category."])
         self.logger.debug("ACTIONS: installed; catdir = %s" % catdir)
@@ -599,12 +606,13 @@ class Actions(object):
         if not args.filename:
             return (False, ['Please provide a signed file.'])
         if not args.category:
-            args.category = 'rel'
+            args.category = 'gentoo'
         (success, data) = self.installed(args)
         keys = data[1]
         if not keys:
             return (False, ['No installed keys found, try installkey action.'])
-        catdir = self.config.get_key(args.category + "-category")
+        keyring = self.config.get_key('keyring')
+        catdir = os.path.join(keyring, args.category)
         self.logger.debug("ACTIONS: verify; catdir = %s" % catdir)
         self.gpg = GkeysGPG(self.config, catdir)
         filepath, signature  = args.filename, args.signature
@@ -697,6 +705,8 @@ class Actions(object):
         if not args.filename:
             return (False, ['Please provide a file to sign.'])
 
+        if not args.nick:
+            args.nick = self.config.get_key("sign", "nick")
         if isinstance(args.nick, str):
             nicks = [args.nick]
         else:
@@ -706,7 +716,7 @@ class Actions(object):
         self.seeds = handler.load_category('sign', nicks)
         if not self.seeds.seeds:
             return (False, ['No installed keys, try installkey action.', ''])
-        basedir = self.config.get_key("sign-category")
+        basedir = self.config.get_key("sign-keydir")
         keydir  = self.config.get_key("sign", "keydir")
         task = self.config.get_key("sign", "type")
         keyring = self.config.get_key("sign", "keyring")
@@ -747,7 +757,8 @@ class Actions(object):
         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")
+        keyring = self.config.get_key('keyring')
+        catdir = os.path.join(keyring, args.category)
         self.logger.debug("ACTIONS: refreshkey; catdir = %s" % catdir)
         self.gpg = GkeysGPG(self.config, catdir)
         results = {}

diff --git a/gkeys/gkeys/seedhandler.py b/gkeys/gkeys/seedhandler.py
index cc797b9..0e66b69 100644
--- a/gkeys/gkeys/seedhandler.py
+++ b/gkeys/gkeys/seedhandler.py
@@ -87,11 +87,11 @@ class SeedHandler(object):
         @return Seeds class object
         '''
         seeds = Seeds(config=self.config)
-        if category:
-            catdir = self.config.get_key(category + "-category")
+        if category == 'sign':
+            catdir = self.config.get_key('sign-keydir')
         else:
-            self.logger.debug("SeedHandler: load_category; Error invalid category: %s." % (str(category)))
-            return seeds
+            keyrings = self.config.get_key('keyring')
+            catdir = os.path.join(keyrings, category)
         self.logger.debug("SeedHandler: load_category; catdir = %s" % catdir)
         try:
             if not nicks:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-23  2:50 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-23  2:50 UTC (permalink / raw
  To: gentoo-commits

commit:     d2092c5d6d32265f237544616e4d46d88f009eeb
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 22 22:27:30 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 23 02:48:33 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=d2092c5d

gkeys/checks.py: Correctly set the exiry to 5 years (glep 63)

---
 gkeys/gkeys/checks.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py
index db3d59f..b66165b 100644
--- a/gkeys/gkeys/checks.py
+++ b/gkeys/gkeys/checks.py
@@ -54,15 +54,15 @@ TEST_SPEC = {
         'DSA': 2048,
         'RSA': 2048,
         },
-    'expire': 3 * 365,      # in days
+    'expire': 5 * 365,      # in days
     'subkeys': {        # warning/error mode
         'encrypt': {
             'mode': 'notice',
-            'expire': 3 * 365,
+            'expire': 5 * 365,
             },
         'sign': {
             'mode': 'error',
-            'expire': 365,
+            'expire': 5 * 365,
             },
         },
     'algorithms': ['DSA', 'RSA', '1', '2', '3', '17'],


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-23  2:50 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-23  2:50 UTC (permalink / raw
  To: gentoo-commits

commit:     d0530210fad7fefead404d07c0af4b57c8f35fca
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 23 02:40:01 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 23 02:48:33 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=d0530210

gkeys/config.py: Fix the config defaults to do % substitution for the defaults

If it did not find and loada valid config file, the defaults did not have the % subtitution applied.
The logger calls were not using the logger setting in the config. So I changed that

---
 gkeys/gkeys/base.py   |  2 +-
 gkeys/gkeys/config.py | 17 +++++++++++------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/gkeys/gkeys/base.py b/gkeys/gkeys/base.py
index 95142f9..a5e3bfa 100644
--- a/gkeys/gkeys/base.py
+++ b/gkeys/gkeys/base.py
@@ -203,7 +203,7 @@ class CliBase(object):
         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
+        self.config.logger = logger
         fileops.logger = logger
         seed.logger = logger
         lib.logger = logger

diff --git a/gkeys/gkeys/config.py b/gkeys/gkeys/config.py
index 775ea1f..e6789ff 100644
--- a/gkeys/gkeys/config.py
+++ b/gkeys/gkeys/config.py
@@ -13,6 +13,8 @@
 import os
 import sys
 
+from collections import OrderedDict
+
 # py3.2
 if sys.hexversion >= 0x30200f0:
     import configparser as ConfigParser
@@ -27,7 +29,6 @@ from pyGPG.config import GPGConfig
 from gkeys import log
 from gkeys.utils import path
 
-logger = log.logger
 
 
 # establish the eprefix, initially set so eprefixify can
@@ -60,7 +61,9 @@ class GKeysConfig(GPGConfig):
         """ Class initialiser """
         GPGConfig.__init__(self)
 
+        self.logger = None
         self.root = root or ''
+        self.defaults = OrderedDict(self.defaults)
         if config:
             self.defaults['config'] = config
             self.defaults['configdir'] = os.path.dirname(config)
@@ -115,6 +118,8 @@ class GKeysConfig(GPGConfig):
             # fix the config path
             self.defaults['config'] = self.defaults['config'] \
                 % {'configdir': self.defaults['configdir']}
+        for key in self.defaults:
+            self.defaults[key] = self._sub_(self.defaults[key])
         defaults = self.get_defaults()
         # remove some defaults from being entered into the configparser
         for key in ['gpg_defaults', 'only_usable', 'refetch', 'tasks']:
@@ -130,8 +135,8 @@ class GKeysConfig(GPGConfig):
     def _get_(self, key, subkey=None):
         if subkey:
             if self.configparser and self.configparser.has_option(key, subkey):
-                if logger:
-                    logger.debug("Found %s in configparser... %s"
+                if self.logger:
+                    self.logger.debug("Found %s in configparser... %s"
                         % (key, str(self.configparser.get(key, subkey))))
                 return self._sub_(self.configparser.get(key, subkey))
             #print("CONFIG: key, subkey", key, subkey)
@@ -142,10 +147,10 @@ class GKeysConfig(GPGConfig):
             else:
                 return super(GKeysConfig, self)._get_(key, subkey)
         elif self.configparser and self.configparser.has_option('DEFAULT', key):
-            if logger:
-                logger.debug("Found %s in configparser... %s"
+            if self.logger:
+                self.logger.debug("Found %s in configparser... %s"
                     % (key, str(self.configparser.get('DEFAULT', key))))
-                #logger.debug("type(key)= %s"
+                #self.logger.debug("type(key)= %s"
                 #    % str(type(self.configparser.get('DEFAULT', key))))
             return self.configparser.get('DEFAULT', key)
         else:


^ permalink raw reply related	[flat|nested] 144+ messages in thread
* [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/
@ 2014-12-23  0:13 Brian Dolbec
  0 siblings, 0 replies; 144+ messages in thread
From: Brian Dolbec @ 2014-12-23  0:13 UTC (permalink / raw
  To: gentoo-commits

commit:     7e2f8e8ca345ee38fd5814ec7d151f6bfed56574
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 22 22:27:30 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Dec 23 00:11:33 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=7e2f8e8c

gkeys/checks.py: Correctly set the exiry to 5 years (glep 63)

---
 gkeys/gkeys/checks.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py
index db3d59f..b66165b 100644
--- a/gkeys/gkeys/checks.py
+++ b/gkeys/gkeys/checks.py
@@ -54,15 +54,15 @@ TEST_SPEC = {
         'DSA': 2048,
         'RSA': 2048,
         },
-    'expire': 3 * 365,      # in days
+    'expire': 5 * 365,      # in days
     'subkeys': {        # warning/error mode
         'encrypt': {
             'mode': 'notice',
-            'expire': 3 * 365,
+            'expire': 5 * 365,
             },
         'sign': {
             'mode': 'error',
-            'expire': 365,
+            'expire': 5 * 365,
             },
         },
     'algorithms': ['DSA', 'RSA', '1', '2', '3', '17'],


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

commit:     62c2253da57fe8fdbbc52ee0066c260ed24d9a8d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 22 22:27:30 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Dec 22 22:58:09 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=62c2253d

gkeys/checks.py: Correctly set the exiry to 5 years (glep 63)

---
 gkeys/gkeys/checks.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gkeys/gkeys/checks.py b/gkeys/gkeys/checks.py
index db3d59f..b66165b 100644
--- a/gkeys/gkeys/checks.py
+++ b/gkeys/gkeys/checks.py
@@ -54,15 +54,15 @@ TEST_SPEC = {
         'DSA': 2048,
         'RSA': 2048,
         },
-    'expire': 3 * 365,      # in days
+    'expire': 5 * 365,      # in days
     'subkeys': {        # warning/error mode
         'encrypt': {
             'mode': 'notice',
-            'expire': 3 * 365,
+            'expire': 5 * 365,
             },
         'sign': {
             'mode': 'error',
-            'expire': 365,
+            'expire': 5 * 365,
             },
         },
     'algorithms': ['DSA', 'RSA', '1', '2', '3', '17'],


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

commit:     64596f0e270fa7642c95fc227343e651a55cbb50
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 21 00:26:25 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Dec 22 22:58:09 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoo-keys.git;a=commit;h=64596f0e

gkeys/actions.py: fix rebase error in Available_Actions

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

diff --git a/gkeys/gkeys/actions.py b/gkeys/gkeys/actions.py
index a224372..be59fb3 100644
--- a/gkeys/gkeys/actions.py
+++ b/gkeys/gkeys/actions.py
@@ -26,7 +26,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']
+            'installed', 'importkey', 'verify', 'checkkey', 'sign', 'speccheck',
             'refreshkey']
 
 Action_Options = {


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

end of thread, other threads:[~2018-08-15 16:15 UTC | newest]

Thread overview: 144+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-31 21:34 [gentoo-commits] proj/gentoo-keys:master commit in: gkeys/gkeys/ Brian Dolbec
  -- strict thread matches above, loose matches on Subject: below --
2018-08-15 16:15 Brian Dolbec
2018-08-15  1:51 Brian Dolbec
2018-08-15  1:05 Brian Dolbec
2018-07-07 15:10 Brian Dolbec
2018-07-07 15:10 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2018-07-07  5:23 Brian Dolbec
2016-12-24  9:13 [gentoo-commits] proj/gentoo-keys:gsoc-2016 " Brian Dolbec
2016-12-24  0:38 ` [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
2016-12-24  9:13 [gentoo-commits] proj/gentoo-keys:gsoc-2016 " Brian Dolbec
2016-12-24  0:38 ` [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
2016-12-24  9:13 [gentoo-commits] proj/gentoo-keys:gsoc-2016 " Brian Dolbec
2016-10-27 21:49 ` [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
2016-12-24  9:13 [gentoo-commits] proj/gentoo-keys:gsoc-2016 " Brian Dolbec
2016-10-27 18:41 ` [gentoo-commits] proj/gentoo-keys:master " Brian Dolbec
2016-12-24  4:52 Brian Dolbec
2016-06-01 15:16 Brian Dolbec
2016-06-01 15:16 Brian Dolbec
2016-01-23 23:33 Brian Dolbec
2016-01-23 23:33 Brian Dolbec
2016-01-23 19:04 Brian Dolbec
2015-12-25 17:03 Brian Dolbec
2015-12-13  0:51 Brian Dolbec
2015-08-25 14:10 Brian Dolbec
2015-08-25 14:10 Brian Dolbec
2015-08-09 22:52 Brian Dolbec
2015-08-09  1:09 Brian Dolbec
2015-08-09  1:09 Brian Dolbec
2015-08-09  1:09 Brian Dolbec
2015-08-09  1:09 Brian Dolbec
2015-08-09  1:09 Brian Dolbec
2015-08-09  1:09 Brian Dolbec
2015-08-09  1:09 Brian Dolbec
2015-08-09  1:09 Brian Dolbec
2015-08-09  1:09 Brian Dolbec
2015-08-09  1:09 Brian Dolbec
2015-08-09  1:09 Brian Dolbec
2015-07-25 16:45 Brian Dolbec
2015-07-25 16:45 Brian Dolbec
2015-07-25 16:45 Brian Dolbec
2015-06-22 13:41 Brian Dolbec
2015-06-01  1:56 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-05-31  5:03 Brian Dolbec
2015-03-18 15:32 Brian Dolbec
2015-03-17 19:51 Brian Dolbec
2015-03-08 15:09 Brian Dolbec
2015-03-06 21:04 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-02-11 17:37 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-09 21:07 Brian Dolbec
2015-01-08  4:13 Brian Dolbec
2015-01-07 23:39 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-05 23:12 Brian Dolbec
2015-01-01 22:32 Brian Dolbec
2015-01-01 17:44 Brian Dolbec
2015-01-01 17:44 Brian Dolbec
2015-01-01 17:44 Brian Dolbec
2015-01-01 17:44 Brian Dolbec
2015-01-01 17:44 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-31 21:34 Brian Dolbec
2014-12-26 18:37 Brian Dolbec
2014-12-26 18:37 Brian Dolbec
2014-12-26 18:37 Brian Dolbec
2014-12-26  5:02 Brian Dolbec
2014-12-26  5:02 Brian Dolbec
2014-12-26  5:02 Brian Dolbec
2014-12-25 22:07 Brian Dolbec
2014-12-25 22:07 Brian Dolbec
2014-12-25 20:43 Brian Dolbec
2014-12-25 20:43 Brian Dolbec
2014-12-25 20:43 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-24 19:59 Brian Dolbec
2014-12-23  2:50 Brian Dolbec
2014-12-23  2:50 Brian Dolbec
2014-12-23  0:13 Brian Dolbec
2014-12-22 23:11 Brian Dolbec
2014-12-22 23:11 Brian Dolbec

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