summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-06-12 07:03:00 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-06-12 07:03:23 +0200
commite8703d9ad2f0f6bcf20a04529b179efaebc7d6d7 (patch)
tree13fb2d2f8e6c14d1374ff0c848630fec23a13008
parent2685e075e05a080d9b9a1108674ff658c411857a (diff)
downloadpykolab-e8703d9ad2f0f6bcf20a04529b179efaebc7d6d7.tar.gz
Rebase command transfer-mailbox so that it actually functions
-rw-r--r--pykolab/cli/cmd_transfer_mailbox.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/pykolab/cli/cmd_transfer_mailbox.py b/pykolab/cli/cmd_transfer_mailbox.py
index 2176bde..4a4069a 100644
--- a/pykolab/cli/cmd_transfer_mailbox.py
+++ b/pykolab/cli/cmd_transfer_mailbox.py
@@ -21,6 +21,8 @@ import commands
import pykolab
+from pykolab.auth import Auth
+from pykolab.imap import IMAP
from pykolab.translate import _
log = pykolab.getLogger('pykolab.cli')
@@ -41,22 +43,25 @@ def execute(*args, **kw):
if len(conf.cli_args) > 0:
target_partition = conf.cli_args.pop(0)
- mbox_parts = imap.parse_mailfolder(mailfolder)
+ imap = IMAP()
+ imap.connect()
- print "Mailbox parts:", mbox_parts
+ mbox_parts = imap.parse_mailfolder(mailfolder)
if mbox_parts['domain'] == None:
+ domain = conf.get('kolab', 'primary_domain')
user_identifier = mbox_parts['path_parts'][1]
else:
+ domain = mbox_parts['domain']
user_identifier = "%s@%s" % (mbox_parts['path_parts'][1], mbox_parts['domain'])
- print "User Identifier:", user_identifier
-
- user = auth.find_user("mail", user_identifier)
+ source_server = imap.user_mailbox_server(mailfolder)
+ imap.connect(server=source_server)
+ imap.imap.xfer(mailfolder, target_server)
- print "User:", user
+ auth = Auth()
+ auth.connect()
- imap.connect()
- imap.imap.xfer(mailfolder, target_server)
+ user = auth.find_recipient(user_identifier)
- auth.set_user_attribute(mbox_parts['domain'], user, "mailHost", target_server)
+ auth.set_entry_attributes(domain, user, {'mailhost': target_server})