当前位置: 首页>>代码示例>>Python>>正文


Python IMAP.list_folders方法代码示例

本文整理汇总了Python中pykolab.imap.IMAP.list_folders方法的典型用法代码示例。如果您正苦于以下问题:Python IMAP.list_folders方法的具体用法?Python IMAP.list_folders怎么用?Python IMAP.list_folders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pykolab.imap.IMAP的用法示例。


在下文中一共展示了IMAP.list_folders方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import list_folders [as 别名]
def execute(*args, **kw):
    """
        Delete mailbox
    """

    if len(conf.cli_args) < 1:
        print >> sys.stderr, _("No mailbox specified")
        sys.exit(1)

    imap = IMAP()

    imap.connect()

    delete_folders = []
    while len(conf.cli_args) > 0:
        folder = conf.cli_args.pop(0)
        folders = imap.list_folders(folder)

        if len(folders) < 1:
            print >> sys.stderr, _("No such folder(s): %s") % (folder)

        delete_folders.extend(folders)

    if len(delete_folders) == 0:
        print >> sys.stderr, _("No folders to delete.")
        sys.exit(1)

    for delete_folder in delete_folders:
        try:
            imap.delete_mailfolder(delete_folder)
        except Exception, errmsg:
            log.error(_("Could not delete mailbox '%s'") % (delete_folder))
开发者ID:tpokorra,项目名称:pykolab,代码行数:34,代码来源:cmd_delete_mailbox.py

示例2: description

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import list_folders [as 别名]
def description():
    return """Obtain a list of ACL entries on a folder."""

def execute(*args, **kw):
    try:
        folder = conf.cli_args.pop(0)
    except IndexError, errmsg:
        folder = utils.ask_question(_("Folder name"))

    if len(folder.split('@')) > 1:
        domain = folder.split('@')[1]
    else:
        domain = conf.get('kolab', 'primary_domain')

    imap = IMAP()
    imap.connect(domain=domain)

    if not imap.has_folder(folder):
        print >> sys.stderr, _("No such folder %r") % (folder)

    else:
        acls = []
        folders = imap.list_folders(folder)
        for folder in folders:
            print "Folder", folder
            acls = imap.list_acls(folder)

            for acl in acls.keys():
                print "  %-13s %s" %(acls[acl], acl)

开发者ID:tpokorra,项目名称:pykolab,代码行数:31,代码来源:cmd_list_mailbox_acls.py

示例3: IMAP

# 需要导入模块: from pykolab.imap import IMAP [as 别名]
# 或者: from pykolab.imap.IMAP import list_folders [as 别名]
    try:
        quota_folder = conf.cli_args.pop(0)
    except IndexError, e:
        quota_folder = '*'

    imap = IMAP()

    if not conf.connect_server == None:
        imap.connect(server=conf.connect_server)
    else:
        imap.connect()

    folders = []

    quota_folders = imap.list_folders(quota_folder)
    for quota_folder in quota_folders:
        try:
            (used, quota) = imap.get_quota(quota_folder)
            print "Folder: %s" % (quota_folder)
            if not used == None and not quota == None:
                if quota == 0:
                    print >> sys.stderr, _("The quota for folder %s is set to literally allow 0KB of storage.") % (quota_folder)
                    print "%d (Used: %d, Percentage: %s)" % (quota, used, u'\u221E')
                else:
                    percentage = round(((float)(used)/(float)(quota)) * 100.0, 1)
                    print "%d (Used: %d, Percentage: %d)" % (quota, used, percentage)
            else:
                if used == None:
                    print "%d (Used: %d, Percentage: %d)" % (quota, 0, 0)
                else:
开发者ID:tpokorra,项目名称:pykolab,代码行数:32,代码来源:cmd_list_quota.py


注:本文中的pykolab.imap.IMAP.list_folders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。