aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2015-07-28 22:59:39 -0700
committerBrian Dolbec <dolsen@gentoo.org>2015-08-02 20:59:36 -0700
commit3fd82a0c97b291da10ca116fb80f24c0d3bcef90 (patch)
tree17d6ad56356aee3ce2adee717a98596021f4b795 /gkeys/gkeys/lib.py
parentgkeys: Fix the user config location and operation (diff)
downloadgentoo-keys-3fd82a0c97b291da10ca116fb80f24c0d3bcef90.tar.gz
gentoo-keys-3fd82a0c97b291da10ca116fb80f24c0d3bcef90.tar.bz2
gentoo-keys-3fd82a0c97b291da10ca116fb80f24c0d3bcef90.zip
gkeys/lib.py: Split out _log_result()
Split out common code to be used for all veritf_* functions.
Diffstat (limited to 'gkeys/gkeys/lib.py')
-rw-r--r--gkeys/gkeys/lib.py25
1 files 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))
+
+