summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-08-13 10:57:49 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-08-13 10:57:49 +0100
commit0c8d510df94bacbea289d6738a00d0b56928fcf6 (patch)
tree8fde414d13ef3e94285af39efef4f0961953d635
parent79bfb73a9d88711deb5c6c7a9e5f7142c61ae26c (diff)
downloadpykolab-0c8d510df94bacbea289d6738a00d0b56928fcf6.tar.gz
Add commands count-domain-mailboxes and server-info, enhance list-mailboxes
-rw-r--r--.gitignore3
-rw-r--r--pykolab/cli/cmd_count_domain_mailboxes.py68
-rw-r--r--pykolab/cli/cmd_list_mailboxes.py2
-rw-r--r--pykolab/cli/cmd_server_info.py58
4 files changed, 130 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 7c1de8b..e8d60b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,11 +9,13 @@ Makefile.in
*.rej
*.spec
*.tar.gz
+*.tar.gz.gpg
aclocal.m4
autom4te.cache/
bin/rebuild.sh
bin/test*
ChangeLog
+conf/*-*.conf
config.log
config.status
configure
@@ -23,3 +25,4 @@ po/POTFILES
pykolab/constants.py
pykolab-[0-9]*.*/
src/
+test-*
diff --git a/pykolab/cli/cmd_count_domain_mailboxes.py b/pykolab/cli/cmd_count_domain_mailboxes.py
new file mode 100644
index 0000000..6cc71ef
--- /dev/null
+++ b/pykolab/cli/cmd_count_domain_mailboxes.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010-2013 Kolab Systems AG (http://www.kolabsys.com)
+#
+# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
+#
+# 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; version 3 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 Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+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('count_domain_mailboxes', execute)
+
+def cli_options():
+ my_option_group = conf.add_cli_parser_option_group(_("CLI Options"))
+ 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 primary,secondaries in domains:
+ print "%s: %d" % (primary,len(imap.lm("user/%%@%s" % (primary))))
+ for secondary in secondaries:
+ print "%s: %d" % (secondary,len(imap.lm("user/%%@%s" % (secondary))))
+
+ null_realm = len(imap.lm("user/%%"))
+
+ if null_realm > 0:
+ print "null: %d" % (null_realm)
+
diff --git a/pykolab/cli/cmd_list_mailboxes.py b/pykolab/cli/cmd_list_mailboxes.py
index ebfefb7..f9391eb 100644
--- a/pykolab/cli/cmd_list_mailboxes.py
+++ b/pykolab/cli/cmd_list_mailboxes.py
@@ -85,7 +85,7 @@ def execute(*args, **kw):
for search in searches:
log.debug(_("Appending folder search for %r") % (search), level=8)
- folders.extend(imap.lm(search))
+ folders.extend(imap.lm(imap_utf7.encode(search)))
for folder in folders:
if not conf.raw:
diff --git a/pykolab/cli/cmd_server_info.py b/pykolab/cli/cmd_server_info.py
new file mode 100644
index 0000000..51ec40d
--- /dev/null
+++ b/pykolab/cli/cmd_server_info.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010-2013 Kolab Systems AG (http://www.kolabsys.com)
+#
+# Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen a kolabsys.com>
+#
+# 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; version 3 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 Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+import commands
+
+import pykolab
+
+from pykolab.imap import IMAP
+from pykolab.translate import _
+
+log = pykolab.getLogger('pykolab.cli')
+conf = pykolab.getConf()
+
+def __init__():
+ commands.register('server_info', execute, description=description())
+
+def cli_options():
+ my_option_group = conf.add_cli_parser_option_group(_("CLI Options"))
+ my_option_group.add_option( '--server',
+ dest = "connect_server",
+ action = "store",
+ default = None,
+ metavar = "SERVER",
+ help = _("List mailboxes on server SERVER only."))
+
+
+def description():
+ return "Display server info.\n"
+
+def execute(*args, **kw):
+ """
+ List mailboxes
+ """
+
+ imap = IMAP()
+
+ if not conf.connect_server == None:
+ imap.connect(server=conf.connect_server)
+ else:
+ imap.connect()
+
+ print imap.get_metadata("")