本文整理汇总了Python中pykolab.imap.IMAP.dm方法的典型用法代码示例。如果您正苦于以下问题:Python IMAP.dm方法的具体用法?Python IMAP.dm怎么用?Python IMAP.dm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykolab.imap.IMAP
的用法示例。
在下文中一共展示了IMAP.dm方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import dm [as 别名]
def execute(*args, **kw):
"""
Synchronize or display changes
"""
imap = IMAP()
if not conf.connect_server == None:
imap.connect(server=conf.connect_server)
else:
imap.connect()
auth = Auth()
auth.connect()
domains = auth.list_domains()
folders = imap.lm()
imap_domains_not_domains = []
for folder in folders:
if len(folder.split('@')) > 1 and not folder.startswith('DELETED'):
_folder_domain = folder.split('@')[-1]
if not _folder_domain in list(set(domains.keys() + domains.values())):
imap_domains_not_domains.append(folder.split('@')[-1])
imap_domains_not_domains = list(set(imap_domains_not_domains))
log.debug(_("Domains in IMAP not in LDAP: %r") % (imap_domains_not_domains), level=8)
if len(imap_domains_not_domains) > 0:
for domain in imap_domains_not_domains:
folders = []
folders.extend(imap.lm('shared/%%@%s' % (domain)))
folders.extend(imap.lm('user/%%@%s' % (domain)))
for folder in folders:
if conf.delete:
if conf.dry_run:
if not folder.split('/')[0] == 'shared':
log.warning(_("No recipients for '%s' (would have deleted the mailbox if not for --dry-run)!") % ('/'.join(folder.split('/')[1:])))
else:
continue
else:
if not '/'.join(folder.split('/')[0]) == 'shared':
log.info(_("Deleting mailbox '%s' because it has no recipients") % (folder))
try:
imap.dm(folder)
except Exception, errmsg:
log.error(_("An error occurred removing mailbox %r: %r") % (folder, errmsg))
else:
log.info(_("Not automatically deleting shared folder '%s'") % (folder))
else:
log.warning(_("No recipients for '%s' (use --delete to delete)!") % ('/'.join(folder.split('/')[1:])))
示例2: purge_imap
# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import dm [as 别名]
def purge_imap():
time.sleep(2)
imap = IMAP()
imap.connect()
for folder in imap.lm():
try:
imap.dm(folder)
except:
pass