if backend == None:
        backend = conf.get('kolab', 'imap_backend')

    admin_login = conf.get(backend, 'admin_login')
    admin_password = conf.get(backend, 'admin_password')

    imap.login_plain(admin_login, admin_password, user)

    if not imap.has_folder(folder_pattern):
        print >> sys.stderr, \
                _("Cannot subscribe user to folder %r:") % (folder_pattern), \
                _("No such folder")
        sys.exit(1)

    _folders = imap.lm(folder_pattern)
    _subscribed_folders = imap.lsub()
    unsubscribed_folders = []

    for _folder in _folders:
        if _folder in _subscribed_folders:
            imap.unsubscribe(_folder)
            unsubscribed_folders.append(_folder)

    if len(unsubscribed_folders) > 0:
        print _("Successfully unsubscribed user %s from the following folders:") % (
                user
            )

        print "\n".join(unsubscribed_folders)
    else:
        print >> sys.stderr, _("User %s was not unsubscribed from any folders.") % (
    if backend == None:
        backend = conf.get('kolab', 'imap_backend')

    admin_login = conf.get(backend, 'admin_login')
    admin_password = conf.get(backend, 'admin_password')

    imap.login_plain(admin_login, admin_password, user)

    if not imap.has_folder(folder_pattern):
        print >> sys.stderr, \
                _("Cannot subscribe user to folder %r:") % (folder_pattern), \
                _("No such folder")
        sys.exit(1)

    _folders = imap.lm(folder_pattern)
    _subscribed_folders = imap.lsub()
    unsubscribed_folders = []

    for _folder in _folders:
        if _folder in _subscribed_folders:
            imap.unsubscribe(_folder)
            unsubscribed_folders.append(_folder)

    if len(unsubscribed_folders) > 0:
        print _("Successfully unsubscribed user %s from the following folders:"
                ) % (user)

        print "\n".join(unsubscribed_folders)
    else:
        print >> sys.stderr, _(
            "User %s was not unsubscribed from any folders.") % (user)
Пример #3
0
    else:
        domain = conf.get('kolab', 'primary_domain')

    imap = IMAP()
    imap.connect(domain=domain, login=False)

    backend = conf.get(domain, 'imap_backend')
    if backend == None:
        backend = conf.get('kolab', 'imap_backend')

    admin_login = conf.get(backend, 'admin_login')
    admin_password = conf.get(backend, 'admin_password')

    imap.login_plain(admin_login, admin_password, user)

    subscribed_folders = imap.lsub(folder_pattern)

    if conf.unsubscribed:
        unsubscribed_folders = []
        all_folders = imap.lm(folder_pattern)

        for folder in all_folders:
            if not folder in subscribed_folders:
                unsubscribed_folders.append(folder)

        if len(unsubscribed_folders) > 0:
            if not conf.raw:
                print "\n".join([imap_utf7.decode(x) for x in unsubscribed_folders])
            else:
                print "\n".join(unsubscribed_folders)
        else: