~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/gpg.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-12 19:37:02 UTC
  • mto: This revision was merged to the branch mainline in revision 2004.
  • Revision ID: john@arbash-meinel.com-20060912193702-22c752299731a663
HACKING and NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005 by Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
18
"""GPG signing and checking logic."""
19
19
 
 
20
import errno
20
21
import os
 
22
import subprocess
21
23
import sys
22
24
 
23
 
from bzrlib.lazy_import import lazy_import
24
 
lazy_import(globals(), """
25
 
import errno
26
 
import subprocess
27
 
 
28
25
from bzrlib import (
29
26
    errors,
30
27
    trace,
31
28
    ui,
32
29
    )
33
 
""")
34
30
 
35
31
 
36
32
class DisabledGPGStrategy(object):
50
46
        """Real strategies take a configuration."""
51
47
 
52
48
    def sign(self, content):
53
 
        return ("-----BEGIN PSEUDO-SIGNED CONTENT-----\n" + content +
54
 
                "-----END PSEUDO-SIGNED CONTENT-----\n")
 
49
        return content
55
50
 
56
51
 
57
52
def _set_gpg_tty():
69
64
 
70
65
class GPGStrategy(object):
71
66
    """GPG Signing and checking facilities."""
72
 
 
 
67
        
73
68
    def _command_line(self):
74
69
        return [self._config.gpg_signing_command(), '--clearsign']
75
70
 
77
72
        self._config = config
78
73
 
79
74
    def sign(self, content):
80
 
        if isinstance(content, unicode):
81
 
            raise errors.BzrBadParameterUnicode('content')
82
75
        ui.ui_factory.clear_term()
83
76
 
84
77
        preexec_fn = _set_gpg_tty