~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/gpg.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-08-17 07:52:09 UTC
  • mfrom: (1910.3.4 trivial)
  • Revision ID: pqm@pqm.ubuntu.com-20060817075209-e85a1f9e05ff8b87
(andrew) Trivial fixes to NotImplemented errors.

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
17
17
 
18
18
"""GPG signing and checking logic."""
19
19
 
 
20
import errno
20
21
import os
21
 
import sys
22
 
 
23
 
from bzrlib.lazy_import import lazy_import
24
 
lazy_import(globals(), """
25
 
import errno
26
22
import subprocess
27
23
 
28
24
from bzrlib import (
29
25
    errors,
30
26
    trace,
31
 
    ui,
32
27
    )
33
 
""")
34
28
 
35
29
 
36
30
class DisabledGPGStrategy(object):
50
44
        """Real strategies take a configuration."""
51
45
 
52
46
    def sign(self, content):
53
 
        return ("-----BEGIN PSEUDO-SIGNED CONTENT-----\n" + content +
54
 
                "-----END PSEUDO-SIGNED CONTENT-----\n")
 
47
        return content
55
48
 
56
49
 
57
50
def _set_gpg_tty():
77
70
        self._config = config
78
71
 
79
72
    def sign(self, content):
80
 
        if isinstance(content, unicode):
81
 
            raise errors.BzrBadParameterUnicode('content')
82
 
        ui.ui_factory.clear_term()
83
 
 
84
 
        preexec_fn = _set_gpg_tty
85
 
        if sys.platform == 'win32':
86
 
            # Win32 doesn't support preexec_fn, but wouldn't support TTY anyway.
87
 
            preexec_fn = None
88
73
        try:
89
74
            process = subprocess.Popen(self._command_line(),
90
75
                                       stdin=subprocess.PIPE,
91
76
                                       stdout=subprocess.PIPE,
92
 
                                       preexec_fn=preexec_fn)
 
77
                                       preexec_fn=_set_gpg_tty)
93
78
            try:
94
79
                result = process.communicate(content)[0]
95
80
                if process.returncode is None: