summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-13 17:03:29 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-13 17:03:29 +0100
commitbdaefc9e82e48f683c0a4a6f527c327cbc18ba65 (patch)
tree1b94cd10331627fe60ad110574a48f03db93fda5
parenta2dc01ba14aa4cbbef81f5438fa748c4ac14a436 (diff)
downloadpykolab-bdaefc9e82e48f683c0a4a6f527c327cbc18ba65.tar.gz
Correct cmd_create_mailbox.py
-rw-r--r--pykolab/cli/cmd_create_mailbox.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/pykolab/cli/cmd_create_mailbox.py b/pykolab/cli/cmd_create_mailbox.py
index 20d9d6d..4ecc788 100644
--- a/pykolab/cli/cmd_create_mailbox.py
+++ b/pykolab/cli/cmd_create_mailbox.py
@@ -17,10 +17,13 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
+import sys
+
import commands
import pykolab
+from pykolab.imap import IMAP
from pykolab.translate import _
log = pykolab.getLogger('pykolab.cli')
@@ -29,12 +32,36 @@ conf = pykolab.getConf()
def __init__():
commands.register('create_mailbox', execute, description=description(), aliases='cm')
+def cli_options():
+ my_option_group = conf.add_cli_parser_option_group(_("CLI Options"))
+ my_option_group.add_option( '--metadata',
+ dest = "metadata",
+ action = "store",
+ default = None,
+ help = _("Set metadata for folder to ANNOTATION=VALUE"))
+
def description():
return """Create a mailbox or sub-folder of an existing mailbox."""
def execute(*args, **kw):
- mailbox = conf.cli_args.pop(0)
+ try:
+ mailbox = conf.cli_args.pop(0)
+ except IndexError, errmsg:
+ log.error(_("Invalid argument"))
+ sys.exit(1)
+ if not conf.metadata == None:
+ if len(conf.metadata.split('=')) == 2:
+ annotation = conf.metadata.split('=')[0]
+ annotation_value = conf.metadata.split('=')[1]
+ else:
+ log.error(_("Invalid argument for metadata"))
+ sys.exit(1)
+
+ imap = IMAP()
imap.connect()
imap.cm(mailbox)
+ if not conf.metadata == None:
+ imap.setannotation(mailbox, conf.metadata.split('=')[0], conf.metadata.split('=')[1])
+