From timur@oilspace.com Sun Nov 18 16:15:38 2007 From: timur@oilspace.com (Timur Izhbulatov) Date: Sun, 18 Nov 2007 19:15:38 +0300 Subject: [Infrastructures] ISconf patch Message-ID: <4740652A.3050401@oilspace.com> This is a multi-part message in MIME format. --------------030201020806080109060302 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, I've been playing with ISconf.GPG and this resulted in a small patch (attached). It allows to avoid writing debugging messages to stdout. One can use the verbose argument of the constructor to pass a callable object which will be used to write debugging messages somehere else. I pesonally use it like this: gpg = isconf.GPG.GPG(GPG, verbose=lambda arg: log.debug(str(arg))) , where log is a Logger instance from the standard logging module. Also, the patch adds few methods to fix AttributeError exceptions which I got with my version of GnuPG (1.4.6). Best Regards, --------------030201020806080109060302 Content-Type: text/x-patch; name="trunk.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="trunk.diff" Index: GPG.py =================================================================== --- GPG.py (revision 233) +++ GPG.py (working copy) @@ -91,7 +91,9 @@ cmd.extend(args) cmd = ' '.join(cmd) - if self.verbose: + if callable(self.verbose): + self.verbose(cmd) + elif self.verbose: print cmd child_stdout, child_stdin, child_stderr, child_pass = \ @@ -111,8 +113,14 @@ while 1: line = child_stderr.readline() response.stderr += line - if self.verbose: print line - if line == "": break + + if callable(self.verbose): + self.verbose(line) + elif self.verbose: + print cmd + + if not line: + break line = line.rstrip() if line[0:9] == '[GNUPG:] ': # Chop off the prefix @@ -538,6 +546,7 @@ # these showed up in gpg 1.4.1 def PLAINTEXT(self,value): pass def PLAINTEXT_LENGTH(self,value): pass + def ERRSIG(self,value): pass def is_valid(self): return self.valid @@ -734,6 +743,7 @@ def NEED_PASSPHRASE(self, value): pass def BAD_PASSPHRASE(self, value): pass def GOOD_PASSPHRASE(self, value): pass + def BEGIN_SIGNING(self, value): pass # SIG_CREATED def SIG_CREATED(self, value): --------------030201020806080109060302--