本文整理汇总了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