SF.net SVN: jython:[7162] trunk/jython
[email protected] Fri, 22 Oct 2010 01:13:48 +0000
| Newsgroups | gmane.comp.lang.jython.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 7162
http://jython.svn.sourceforge.net/jython/?rev=7162&view=rev
Author: zyasoft
Date: 2010-10-22 01:13:48 +0000 (Fri, 22 Oct 2010)
Log Message:
-----------
Uses JLine support, when available, to turn off echoing in
getpass.getpass. Fixes #1628.
Modified Paths:
--------------
trunk/jython/Lib/getpass.py
trunk/jython/NEWS
Modified: trunk/jython/Lib/getpass.py
===================================================================
--- trunk/jython/Lib/getpass.py 2010-10-19 03:02:51 UTC (rev 7161)
+++ trunk/jython/Lib/getpass.py 2010-10-22 01:13:48 UTC (rev 7162)
@@ -14,10 +14,37 @@
# Authors: Piers Lauder (original)
# Guido van Rossum (Windows support and cleanup)
+import os
import sys
__all__ = ["getpass","getuser"]
+def jython_getpass(prompt='Password: ', stream=None):
+ """Prompt for a password, with echo turned off.
+ The prompt is written on stream, by default stdout.
+
+ Restore terminal settings at end.
+ """
+ if stream is None:
+ stream = sys.stdout
+
+ try:
+ terminal = sys._jy_interpreter.reader.terminal
+ except:
+ return default_getpass(prompt)
+
+ echoed = terminal.getEcho()
+ terminal.disableEcho()
+ try:
+ passwd = _raw_input(prompt, stream)
+ finally:
+ if echoed:
+ terminal.enableEcho()
+
+ stream.write('\n')
+ return passwd
+
+
def unix_getpass(prompt='Password: ', stream=None):
"""Prompt for a password, with echo turned off.
The prompt is written on stream, by default stdout.
@@ -99,8 +126,6 @@
"""
- import os
-
for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
user = os.environ.get(name)
if user:
@@ -123,7 +148,10 @@
try:
from EasyDialogs import AskPassword
except ImportError:
- getpass = default_getpass
+ if os.name == 'java':
+ getpass = jython_getpass
+ else:
+ getpass = default_getpass
else:
getpass = AskPassword
else:
Modified: trunk/jython/NEWS
===================================================================
--- trunk/jython/NEWS 2010-10-19 03:02:51 UTC (rev 7161)
+++ trunk/jython/NEWS 2010-10-22 01:13:48 UTC (rev 7162)
@@ -1,5 +1,9 @@
Jython NEWS
+Jython 2.5.2rc2
+ Bugs Fixed
+ - [ 1628 ] getpass.getpass echoes input
+
Jython 2.5.2rc1
Bugs Fixed
- [ 1133 ] Support ipython and other completers with readline emulation
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev