~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/gpg.py

  • Committer: Jonathan Riddell
  • Date: 2011-06-14 15:10:50 UTC
  • mto: (5971.2.3 bzr-gpgme)
  • mto: This revision was merged to the branch mainline in revision 6003.
  • Revision ID: jriddell@canonical.com-20110614151050-pf5681b8lrwc70rv
catch errors from gpgme, implement verify in dummy gpg strategies

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
    def sign(self, content):
50
50
        raise errors.SigningFailed('Signing is disabled.')
51
51
 
 
52
    def verification(self, content):
 
53
        return SIGNATURE_VALID
52
54
 
53
55
class LoopbackGPGStrategy(object):
54
56
    """A GPG Strategy that acts like 'cat' - data is just passed through."""
60
62
        return ("-----BEGIN PSEUDO-SIGNED CONTENT-----\n" + content +
61
63
                "-----END PSEUDO-SIGNED CONTENT-----\n")
62
64
 
 
65
    def verification(self, content):
 
66
        raise errors.VerifyFailed('Signature verification is disabled.')
 
67
 
63
68
 
64
69
def _set_gpg_tty():
65
70
    tty = os.environ.get('TTY')
129
134
        signature = StringIO(content)
130
135
        plain_output = StringIO()
131
136
        
132
 
        result = context.verify(signature, None, plain_output)
 
137
        try:
 
138
            result = context.verify(signature, None, plain_output)
 
139
        except gpgme.GpgmeError,error:
 
140
            raise errors.VerifyFailed(error[2])
133
141
 
134
142
        if result[0].summary & gpgme.SIGSUM_VALID:
135
143
            return SIGNATURE_VALID