~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/ui/__init__.py

  • Committer: Alexander Belchenko
  • Date: 2008-03-11 22:15:16 UTC
  • mto: This revision was merged to the branch mainline in revision 3295.
  • Revision ID: bialix@ukr.net-20080311221516-pmu5dnoehqujl1u8
Don't ask a password if there is no real terminal. (#69851)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
 
18
 
 
19
17
"""UI abstraction.
20
18
 
21
19
This tells the library how to display things to the user.  Through this
35
33
import getpass
36
34
 
37
35
from bzrlib import (
 
36
    errors,
38
37
    osutils,
39
38
    progress,
40
39
    trace,
125
124
                return False
126
125
 
127
126
    def get_non_echoed_password(self, prompt):
 
127
        if not sys.stdin.isatty():
 
128
            raise errors.NotATerminal()
128
129
        encoding = osutils.get_terminal_encoding()
129
130
        return getpass.getpass(prompt.encode(encoding, 'replace'))
130
131