~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2007-06-07 22:31:44 UTC
  • mfrom: (2517 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2518.
  • Revision ID: john@arbash-meinel.com-20070607223144-u4oljlajcvq6by2n
[merge] bzr.dev 2517

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
import getpass
36
36
 
37
37
from bzrlib import (
 
38
    osutils,
38
39
    progress,
39
40
    trace,
40
41
    )
111
112
            current_format_name,
112
113
            basedir)
113
114
 
114
 
            
 
115
 
115
116
class CLIUIFactory(UIFactory):
116
117
    """Common behaviour for command line UI factories."""
117
118
 
131
132
                return False
132
133
 
133
134
    def get_non_echoed_password(self, prompt):
134
 
        return getpass.getpass(prompt)
 
135
        encoding = osutils.get_terminal_encoding()
 
136
        return getpass.getpass(prompt.encode(encoding, 'replace'))
135
137
 
136
138
    def get_password(self, prompt='', **kwargs):
137
139
        """Prompt the user for a password.
144
146
                 canceled the request.
145
147
        """
146
148
        prompt += ': '
147
 
        prompt = (prompt % kwargs).encode(sys.stdout.encoding, 'replace')
 
149
        prompt = (prompt % kwargs)
148
150
        # There's currently no way to say 'i decline to enter a password'
149
151
        # as opposed to 'my password is empty' -- does it matter?
150
152
        return self.get_non_echoed_password(prompt)