~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/gpg.py

  • Committer: Martin Pool
  • Date: 2006-01-13 09:57:13 UTC
  • mto: This revision was merged to the branch mainline in revision 1611.
  • Revision ID: mbp@sourcefrog.net-20060113095713-1fa5912229a3898e
Review updates of pycurl transport

Split them out into 

  bzrlib.transport.http             common base
  bzrlib.transport.http._urllib     pure python
  bzrlib.transport.http._pycurl     calls pycurl

Update to work with robert's nice transport test multiplexer.

Add PyCurlTransport.has() which does just a HEAD request; should be faster.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
"""GPG signing and checking logic."""
19
19
 
20
20
import errno
21
 
import os
22
21
import subprocess
23
22
 
24
 
from bzrlib import (
25
 
    errors,
26
 
    trace,
27
 
    )
28
 
 
 
23
import bzrlib.errors as errors
29
24
 
30
25
class DisabledGPGStrategy(object):
31
26
    """A GPG Strategy that makes everything fail."""
47
42
        return content
48
43
 
49
44
 
50
 
def _set_gpg_tty():
51
 
    tty = os.environ.get('TTY')
52
 
    if tty is not None:
53
 
        os.environ['GPG_TTY'] = tty
54
 
        trace.mutter('setting GPG_TTY=%s', tty)
55
 
    else:
56
 
        # This is not quite worthy of a warning, because some people
57
 
        # don't need GPG_TTY to be set. But it is worthy of a big mark
58
 
        # in ~/.bzr.log, so that people can debug it if it happens to them
59
 
        trace.mutter('** Env var TTY empty, cannot set GPG_TTY.'
60
 
                     '  Is TTY exported?')
61
 
 
62
 
 
63
45
class GPGStrategy(object):
64
46
    """GPG Signing and checking facilities."""
65
47
        
73
55
        try:
74
56
            process = subprocess.Popen(self._command_line(),
75
57
                                       stdin=subprocess.PIPE,
76
 
                                       stdout=subprocess.PIPE,
77
 
                                       preexec_fn=_set_gpg_tty)
 
58
                                       stdout=subprocess.PIPE)
78
59
            try:
79
60
                result = process.communicate(content)[0]
80
61
                if process.returncode is None: