def execute(*args, **kw):
    """
        List deleted mailboxes
    """

    try:
        domain = conf.cli_args.pop(0)
    except:
        domain = utils.ask_question(_("Domain"))

    imap = IMAP()
    imap.connect()

    auth = Auth()
    auth.connect()

    domains = auth.list_domains()

    folders = []
    for primary,secondaries in domains:
        if not domain == primary and not domain in secondaries:
            continue

        folders.extend(imap.lm("user/%%@%s" % (primary)))
        for secondary in secondaries:
            folders.extend(imap.lm("user/%%@%s" % (secondary)))

    print "Deleted folders:"

    for folder in folders:
        if not conf.raw:
            print imap_utf7.decode(folder)
        else:
            print folder
def execute(*args, **kw):
    """
        List deleted mailboxes
    """

    try:
        domain = conf.cli_args.pop(0)
    except:
        domain = utils.ask_question(_("Domain"))

    imap = IMAP()
    imap.connect()

    auth = Auth()
    auth.connect()

    domains = auth.list_domains()

    folders = []
    for primary,secondaries in domains:
        if not domain == primary and not domain in secondaries:
            continue

        folders.extend(imap.lm("user/%%@%s" % (primary)))
        for secondary in secondaries:
            folders.extend(imap.lm("user/%%@%s" % (secondary)))

    print "Deleted folders:"

    for folder in folders:
        if not conf.raw:
            print imap_utf7.decode(folder)
        else:
            print folder
def execute(*args, **kw):
    """
        List deleted mailboxes
    """
    imap = IMAP()
    imap.connect()

    auth = Auth()
    auth.connect()

    domains = auth.list_domains()

    folders = []
    for domain in list(set(domains.keys())):
        folders.extend(imap.lm("DELETED/*@%s" % (domain)))

    folders.extend(imap.lm("DELETED/*"))

    print "Deleted folders:"

    for folder in folders:
        mbox_parts = imap.parse_mailfolder(folder)

        if not conf.raw:
            print "%s (Deleted at %s)" % (imap_utf7.decode(folder).encode('utf-8'), datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16)))
        else:
            print "%s (Deleted at %s)" % (folder, datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16)))
def execute(*args, **kw):
    """
        List deleted mailboxes
    """
    imap = IMAP()
    imap.connect()

    auth = Auth()
    auth.connect()

    domains = auth.list_domains()

    folders = []
    for domain in list(set(domains.keys())):
        folders.extend(imap.lm("DELETED/*@%s" % (domain)))

    folders.extend(imap.lm("DELETED/*"))

    print "Deleted folders:"

    for folder in folders:
        utf8_folder = imap_utf7.decode(folder).encode('utf-8')
        mbox_parts = imap.parse_mailfolder(utf8_folder)
        ts = datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16))

        if not conf.raw:
            print "%s (Deleted at %s)" % (utf8_folder, ts)
        else:
            print "%s (Deleted at %s)" % (folder, ts)
Example #5
0
def execute(*args, **kw):
    """
        List mailboxes
    """

    searches = []

    # See if conf.cli_args components make sense.
    for arg in conf.cli_args:
        if arg == '*':
            searches.append(arg)
        if arg.startswith('user'):
            searches.append(arg)
        if arg.startswith('shared'):
            searches.append(arg)
        if arg.startswith('DELETED'):
            searches.append(arg)
        if arg.startswith('news'):
            searches.append(arg)

    if len(searches) == 0:
        searches = [ '' ]

    imap = IMAP()

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

    folders = []

    for search in searches:
        log.debug(_("Appending folder search for %r") % (search), level=8)
        folders.extend(imap.lm(imap_utf7.encode(search)))

    for folder in folders:
        if not conf.raw:
            print imap_utf7.decode(folder)
        else:
            print folder
Example #6
0
                except:
                    log.error(_("Error deleting folder '%s'") % (folder))

        for folder in imap.lm('shared/%%@%s' % (domain)):
            if conf.dryrun:
                log.info(
                    _("Would have deleted folder '%s' (dryrun)") % (folder))
            else:
                log.info(_("Deleting folder '%s'") % (folder))
                try:
                    imap.dm(folder)
                except:
                    log.error(_("Error deleting folder '%s'") % (folder))

    for folder in [x for x in imap.lm() if not x.startswith('DELETED/')]:
        folder = imap_utf7.decode(folder)
        acls = imap.list_acls(folder)

        for subject in acls.keys():
            if subject == 'anyone':
                log.info(
                    _("Skipping removal of ACL %s for subject %s on folder %s")
                    % (acls[subject], subject, folder))

                continue

            if not subject in subjects and not subject in subjects_deleted:
                if conf.dryrun:
                    log.info(
                        _("Would have deleted ACL %s for subject %s on folder %s"
                          ) % (acls[subject], subject, folder))
Example #7
0
 def folder_utf8(self, folder):
     from pykolab import imap_utf7
     return imap_utf7.decode(folder)
Example #8
0
 def folder_utf8(self, folder):
     from pykolab import imap_utf7
     return imap_utf7.decode(folder)
Example #9
0
        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:
            print _("No unsubscribed folders for user %s") % (user)

    else:
        if not conf.raw:
            print "\n".join([imap_utf7.decode(x) for x in subscribed_folders])
        else:
            print "\n".join(subscribed_folders)
        domain = folder.split('@')[1]
    elif not conf.user == None and len(conf.user.split('@')) > 1:
        domain = conf.user.split('@')[1]
    else:
        domain = conf.get('kolab', 'primary_domain')

    imap = IMAP()

    if not conf.user == None:
        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, conf.user)
    else:
        imap.connect(domain=domain)

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

    else:
        folders = imap.lm(imap_utf7.encode(folder))
        for folder in folders:
            imap.set_metadata(imap_utf7.decode(folder), metadata_path,
                              metadata_value)