本文整理汇总了Python中mail.Mail.logout方法的典型用法代码示例。如果您正苦于以下问题:Python Mail.logout方法的具体用法?Python Mail.logout怎么用?Python Mail.logout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mail.Mail
的用法示例。
在下文中一共展示了Mail.logout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import logout [as 别名]
def main():
MAIL = 'M'
NO_MAIL = 'N'
# create Mail object, login get
# number of unread emails, then logout
g = Mail()
g.login()
numUnread = g.getNumUnread()
g.logout()
# create SConnection object and connect
# to serial port
s = SConnection()
s.connectToSerial('COM3')
# write message to serial depending on if
# there are unread emails or not
if numUnread > 0:
s.writeToSerial(MAIL)
else:
s.writeToSerial(NO_MAIL)
# close serial connection
s.closeSerial()
示例2: fetch
# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import logout [as 别名]
class Detach:
MESSAGE_PARTS = '(RFC822.SIZE BODY[HEADER.FIELDS (FROM DATE SUBJECT)] BODY)'
def fetch(self, mesg_nums):
typ, data = self.mail.send_cmd('FETCH', mesg_nums, self.MESSAGE_PARTS)
result = [ self.parse(data[i:i+2]) for i in range(0, len(data), 2) ]
self.mail.verbose(pprint.pformat(result))
return result
def connect(self, args):
if not args.host:
try:
from imap_config import HOSTNAME
args.host = HOSTNAME
except ImportError:
args.host = None
self.mail = Mail(args)
def login(self, username):
password = None
if not username:
try:
from imap_config import USERNAME, PASSWORD
username, password = (USERNAME, PASSWORD)
except ImportError:
pass
self.mail.login(username, password)
def logout(self):
self.mail.logout()
def parse(self, data):
mesg = parse_fetch.parse_fields(data[0][1])
mesg['num'] = parse_fetch.parse_message_id(data[0][0])
mesg['size'] = parse_fetch.parse_rfc822_size(data[0][0])
mesg['num_attachments'] = len(parse_fetch.get_attachment_names(data[1]))
return mesg
def search(self, search_criterion):
typ, data = self.mail.send_cmd('SEARCH', None, search_criterion)
mesg_nums = data[0].replace(' ', ',')
mesg = 'SEARCH returned {0} message(s).\n'
mesg_count = (arg_nums.count(',') + 1) if mesg_nums else 0
self.mail.verbose(mesg.format(mesg_count))
return arg.nums
def select(self, mailbox='INBOX'):
typ, data = self.mail.send_cmd('SELECT', mailbox)
mesg = 'Found {0} message(s) in {1!r}.\n'
self.mail.verbose(mesg.format(data[0], mailbox))
示例3: input
# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import logout [as 别名]
name = input()
if name == '':
if len(folder_names) < 2:
print('Enter atleast two Folders!')
continue
else:
break
success = e.select(name)
if success:
folder_names.append(name)
for label in folder_names:
print('Fetching mails from ' + label + '...')
e.fetch_mailbox(dataset_path, label)
e.logout()
ex.main(dataset_name)
else:
print('Invalid Input.')
elif choice == 2:
# Classify using kNN
choice2 = 0
while choice2 != 4:
print('\nkNN Classification:')
print('1 -> Classify Dataset. (Splits Dataset into training and test set)')
print('2 -> Classify Testset. (Test kNN accuracy using Dataset as training set)')
print('3 -> Classify New Emails.\n4 -> Back.')
choice2 = int(input('Enter your choice: '))