diff --git a/pykolab/cli/cmd_list_deleted_mailboxes.py b/pykolab/cli/cmd_list_deleted_mailboxes.py index 6506d65..55d90a6 100644 --- a/pykolab/cli/cmd_list_deleted_mailboxes.py +++ b/pykolab/cli/cmd_list_deleted_mailboxes.py @@ -1,79 +1,80 @@ # -*- coding: utf-8 -*- # Copyright 2010-2013 Kolab Systems AG (http://www.kolabsys.com) # # Jeroen van Meeuwen (Kolab Systems) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # import datetime import commands import pykolab from pykolab import imap_utf7 from pykolab.auth import Auth from pykolab.imap import IMAP from pykolab.translate import _ log = pykolab.getLogger('pykolab.cli') conf = pykolab.getConf() def __init__(): commands.register('list_deleted_mailboxes', execute) def cli_options(): my_option_group = conf.add_cli_parser_option_group(_("CLI Options")) my_option_group.add_option( '--raw', dest = "raw", action = "store_true", default = False, help = _("Display raw IMAP UTF-7 folder names")) my_option_group.add_option( '--server', dest = "connect_server", action = "store", default = None, metavar = "SERVER", help = _("List mailboxes on server SERVER only.")) 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) + 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)" % (imap_utf7.decode(folder).encode('utf-8'), datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16))) + print "%s (Deleted at %s)" % (utf8_folder, ts) else: - print "%s (Deleted at %s)" % (folder, datetime.datetime.fromtimestamp(int(mbox_parts['hex_timestamp'], 16))) - + print "%s (Deleted at %s)" % (folder, ts)