本文整理汇总了Python中poplib.error_proto方法的典型用法代码示例。如果您正苦于以下问题:Python poplib.error_proto方法的具体用法?Python poplib.error_proto怎么用?Python poplib.error_proto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poplib
的用法示例。
在下文中一共展示了poplib.error_proto方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def check(email, password):
try:
email = email
password = password
pop3_server = "pop.163.com"
server = poplib.POP3(pop3_server)
#ssl加密后使用
#server = poplib.POP3_SSL('pop.163.com', '995')
print(server.set_debuglevel(1)) #打印与服务器交互信息
print(server.getwelcome()) #pop有欢迎信息
server.user(email)
server.pass_(password)
print('Messages: %s. Size: %s' % server.stat())
print(email+": successful")
except poplib.error_proto as e:
print(email+":fail")
print(e)
示例2: main
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def main(hostname,port,user,password):
mailbox = poplib.POP3_SSL(hostname,port)
try:
mailbox.user(user)
mailbox.pass_(password)
response, listings, octet_count = mailbox.list()
for listing in listings:
number, size = listing.decode('ascii').split()
print("Message %s has %s bytes" % (number, size))
except poplib.error_proto as exception:
print("Login failed:", exception)
finally:
mailbox.quit()
开发者ID:PacktPublishing,项目名称:Learning-Python-Networking-Second-Edition,代码行数:19,代码来源:mailbox_basic_params.py
示例3: run
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def run(self):
value = getword()
try:
print "-"*12
print "User:",user[:-1],"Password:",value
pop = poplib.POP3(ip)
pop.user(user[:-1])
pop.pass_(value)
print "\t\nLogin successful:",value, user
print pop.stat()
pop.quit()
work.join()
sys.exit(2)
except(poplib.error_proto), msg:
#print "An error occurred:", msg
pass
示例4: run
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def run(self):
value, user = getword()
user = user.replace("\n","")
value = value.replace("\n","")
try:
print "-"*12
print "[+] User:",user,"Password:",value
pop = poplib.POP3_SSL(server, 995)
pop.user(user)
pop.pass_(value)
print "\t\t\n\nLogin successful:",user, value
print "\t\tMail:",pop.stat()[0],"emails"
print "\t\tSize:",pop.stat()[1],"bytes\n\n"
success.append(user)
success.append(value)
success.append(pop.stat()[0])
success.append(pop.stat()[1])
pop.quit()
except (poplib.error_proto), msg:
#print "An error occurred:", msg
pass
示例5: run
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def run(self):
value = getword()
try:
print "-"*12
print "User:",user[:-1],"Password:",value
pop = poplib.POP3(ipaddr[0])
pop.user(user[:-1])
pop.pass_(value)
print "\t\nLogin successful:",value, user
print pop.stat()
pop.quit()
work.join()
sys.exit(2)
except(poplib.error_proto, socket.gaierror, socket.error, socket.herror), msg:
#print "An error occurred:", msg
pass
示例6: run
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def run(self):
value, user = getword()
try:
print "-"*12
print "User:",user,"Password:",value
pop = poplib.POP3(sys.argv[1])
pop.user(user)
pop.pass_(value)
print "\t\nLogin successful:",value, user
print pop.stat()
pop.quit()
work.join()
sys.exit(2)
except (poplib.error_proto), msg:
#print "An error occurred:", msg
pass
示例7: getmail
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def getmail():
FROM = ""
SUBJECT = ""
try:
M = poplib.POP3('mail.darkc0de.com')
M.user(USER)
M.pass_(PASSWORD)
c = M.stat()[0]
numMessages = len(M.list()[1])
for i in range(numMessages):
SUBJECT = M.retr(i+1)[1][15]
FROM = M.retr(i+1)[1][16]
except (poplib.error_proto), msg:
c = -1
print "Mail Failed:",msg
pass
示例8: test_exceptions
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def test_exceptions(self):
self.assertRaises(poplib.error_proto, self.client._shortcmd, 'echo -err')
示例9: test_user
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def test_user(self):
self.assertOK(self.client.user('guido'))
self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
示例10: test_pass_
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def test_pass_(self):
self.assertOK(self.client.pass_('python'))
self.assertRaises(poplib.error_proto, self.client.user, 'invalid')
示例11: test_too_long_lines
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def test_too_long_lines(self):
self.assertRaises(poplib.error_proto, self.client._shortcmd,
'echo +%s' % ((poplib._MAXLINE + 10) * 'a'))
示例12: test_apop_REDOS
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def test_apop_REDOS(self):
# Replace welcome with very long evil welcome.
# NB The upper bound on welcome length is currently 2048.
# At this length, evil input makes each apop call take
# on the order of milliseconds instead of microseconds.
evil_welcome = b'+OK' + (b'<' * 1000000)
with test_support.swap_attr(self.client, 'welcome', evil_welcome):
# The evil welcome is invalid, so apop should throw.
self.assertRaises(poplib.error_proto, self.client.apop, 'a', 'kb')
示例13: execute
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def execute(self, host, port='', ssl='0', user=None, password=None, timeout='10', persistent='1'):
with Timing() as timing:
fp, resp = self.bind(host, port, ssl, timeout=timeout)
try:
if user is not None or password is not None:
with Timing() as timing:
if user is not None:
resp = fp.user(user)
if password is not None:
resp = fp.pass_(password)
logger.debug('No error: %s' % resp)
self.reset()
except pop_error as e:
logger.debug('pop_error: %s' % e)
resp = e.args[0]
if persistent == '0':
self.reset()
code, mesg = B(resp).split(' ', 1)
return self.Response(code, mesg, timing)
示例14: test_utf8_raises_if_unsupported
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def test_utf8_raises_if_unsupported(self):
self.server.handler.enable_UTF8 = False
self.assertRaises(poplib.error_proto, self.client.utf8)
示例15: tearDown
# 需要导入模块: import poplib [as 别名]
# 或者: from poplib import error_proto [as 别名]
def tearDown(self):
if self.client.file is not None and self.client.sock is not None:
try:
self.client.quit()
except poplib.error_proto:
# happens in the test_too_long_lines case; the overlong
# response will be treated as response to QUIT and raise
# this exception
self.client.close()
self.server.stop()