當前位置: 首頁>>代碼示例>>Python>>正文


Python IMAP.dm方法代碼示例

本文整理匯總了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:])))
開發者ID:tpokorra,項目名稱:pykolab,代碼行數:58,代碼來源:cmd_sync_mailhost_attrs.py

示例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
開發者ID:tpokorra,項目名稱:pykolab,代碼行數:13,代碼來源:purge_imap.py


注:本文中的pykolab.imap.IMAP.dm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。