本文整理匯總了Python中twisted.python.util.getPassword方法的典型用法代碼示例。如果您正苦於以下問題:Python util.getPassword方法的具體用法?Python util.getPassword怎麽用?Python util.getPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類twisted.python.util
的用法示例。
在下文中一共展示了util.getPassword方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from twisted.python import util [as 別名]
# 或者: from twisted.python.util import getPassword [as 別名]
def main():
hostname = raw_input('IMAP4 Server Hostname: ')
port = raw_input('IMAP4 Server Port (the default is 143): ')
username = raw_input('IMAP4 Username: ')
password = util.getPassword('IMAP4 Password: ')
onConn = defer.Deferred(
).addCallback(cbServerGreeting, username, password
).addErrback(ebConnection
).addBoth(cbClose)
factory = SimpleIMAP4ClientFactory(username, onConn)
from twisted.internet import reactor
conn = reactor.connectTCP(hostname, int(port), factory)
reactor.run()
示例2: getSavePassphrase
# 需要導入模塊: from twisted.python import util [as 別名]
# 或者: from twisted.python.util import getPassword [as 別名]
def getSavePassphrase(needed):
if needed:
return util.getPassword("Encryption passphrase: ")
else:
return None
示例3: getSavePassphrase
# 需要導入模塊: from twisted.python import util [as 別名]
# 或者: from twisted.python.util import getPassword [as 別名]
def getSavePassphrase(needed):
if needed:
passphrase = util.getPassword("Encryption passphrase: ")
else:
return None
示例4: opt_password
# 需要導入模塊: from twisted.python import util [as 別名]
# 或者: from twisted.python.util import getPassword [as 別名]
def opt_password(self, password):
"""Required. '-' will prompt or read a password from stdin.
"""
# If standard input is a terminal, I prompt for a password and
# confirm it. Otherwise, I use the first line from standard
# input, stripping off a trailing newline if there is one.
if password in ('', '-'):
self['password'] = util.getPassword(confirm=1)
else:
self['password'] = password
示例5: reversePassword
# 需要導入模塊: from twisted.python import util [as 別名]
# 或者: from twisted.python.util import getPassword [as 別名]
def reversePassword():
password = util.getPassword()
return reverseString(password)
示例6: testStdIn
# 需要導入模塊: from twisted.python import util [as 別名]
# 或者: from twisted.python.util import getPassword [as 別名]
def testStdIn(self):
"""Making sure getPassword accepts a password from standard input.
"""
from os import path
import twisted
# Fun path games because for my sub-process, 'import twisted'
# doesn't always point to the package containing this test
# module.
script = """\
import sys
sys.path.insert(0, \"%(dir)s\")
from twisted.test import test_util
print test_util.util.__version__
print test_util.reversePassword()
""" % {'dir': path.dirname(path.dirname(twisted.__file__))}
cmd_in, cmd_out, cmd_err = os.popen3("%(python)s -c '%(script)s'" %
{'python': sys.executable,
'script': script})
cmd_in.write("secret\n")
cmd_in.close()
try:
errors = cmd_err.read()
except IOError, e:
# XXX: Improper kludge to appease buildbot! I'm not really sure
# why this happens, and without that knowledge, I SHOULDN'T be
# just catching and discarding this error.
import errno
if e.errno == errno.EINTR:
errors = ''
else:
raise