本文整理汇总了Python中mail.Mail.mailbox_change方法的典型用法代码示例。如果您正苦于以下问题:Python Mail.mailbox_change方法的具体用法?Python Mail.mailbox_change怎么用?Python Mail.mailbox_change使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mail.Mail
的用法示例。
在下文中一共展示了Mail.mailbox_change方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MailApplet
# 需要导入模块: from mail import Mail [as 别名]
# 或者: from mail.Mail import mailbox_change [as 别名]
class MailApplet(gnaf.Gnaf):
settings = {
'interval':15,
'icon':{
'idle':'idle.png',
'updating':'updating.png',
'new':'new.png',
'error':'error.png'
},
'username':'',
'password':'',
'host':'',
'port':'auto',
'ssl':True,
'mailboxes':[
' Inbox'
],
'url':None
}
def initialize(self):
sett = self.settings
self.Mail = Mail(
sett['username'],
sett['password'],
sett['host'],
sett['port'],
sett['ssl']
)
if self.Mail == None or self.Mail.conn == None:
return None
self.mailboxes = sett['mailboxes']
self.mails_old = {}
return True
def update(self):
self.get_unreads()
if self.mail_count == 0:
self.data = ['No new mail...']
self.tooltip = 'No new mail...'
self.mails_old = {}
return False
if 'Inbox' in self.mails:
self.remove_duplicates()
data = []
# loop through user's mailbox list instead, to ensure correct mailbox order
for mailbox in self.mailboxes:
if mailbox not in self.mails:
continue
mails = []
for mail in self.mails[mailbox]:
mails.append((mail['Subject'],
self.open_browser,
formatTooltip([
('From', mail['From']),
('Date', mail['Date'])
])
))
data.append((
'%s (%s)' % (mailbox, len(mails)),
mails
))
self.data = data
self.tooltip = '%i new mail(s)!' % self.mail_count
return (True if not self.mail_failed else None)
def notify(self):
self.filter_new_ones()
notifications = []
for mailbox in self.mails_new:
for mail in self.mails_new[mailbox]:
mail_from = mail['From'].replace('<','<').replace('>','>')
notifications.append((
mail['Subject'],
formatTooltip([
('From', mail_from),
('Date', mail['Date'])
])
))
self.notifications = notifications
return (len(notifications) > 0)
def get_unreads(self):
self.mails = {}
self.mail_count = 0
self.mail_failed = False
for mailbox in self.mailboxes:
self.Mail.mailbox_change(mailbox)
unreads = self.Mail.unread()
if unreads == None:
self.mail_failed = True
continue
unreads_num = len(unreads)
if unreads_num > 0:
self.mail_count += unreads_num
self.mails[mailbox] = unreads
def remove_duplicates(self):
removals = []
#.........这里部分代码省略.........