diff options
author | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2011-04-11 11:52:29 +0100 |
---|---|---|
committer | Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com> | 2011-04-11 11:52:29 +0100 |
commit | a44f887e6609d46f39c6f4266a175dce1671d2a0 (patch) | |
tree | 18da56c093696b9017eec0d62be44ba25339c797 /pykolab/cli/__init__.py | |
parent | de8818dd793a1b1caff98be0ff03fc3e032f9f92 (diff) | |
download | pykolab-a44f887e6609d46f39c6f4266a175dce1671d2a0.tar.gz |
Pull out auth and conf from becoming multi-instance all over the place. One of each suffices.
Clean up imap module, along with making the imap.cyrus module work better
Diffstat (limited to 'pykolab/cli/__init__.py')
-rw-r--r-- | pykolab/cli/__init__.py | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/pykolab/cli/__init__.py b/pykolab/cli/__init__.py index 5b793f2..3700302 100644 --- a/pykolab/cli/__init__.py +++ b/pykolab/cli/__init__.py @@ -32,14 +32,15 @@ import pykolab.plugins from pykolab import utils from pykolab import conf -from pykolab.auth import Auth -from pykolab.imap import IMAP from pykolab.constants import * from pykolab.translate import _ log = pykolab.getLogger('pykolab.cli') conf = pykolab.getConf() +auth = pykolab.auth +imap = pykolab.imap + class Cli(object): def __init__(self): domain_group = conf.add_cli_parser_option_group(_("CLI Options")) @@ -82,12 +83,6 @@ class Cli(object): sys.exit(1) def action_sync(self): - imap = IMAP() - if hasattr(imap,'auth'): - auth = imap.auth - else: - auth = Auth() - log.debug(_("Listing domains..."), level=5) start = time.time() domains = auth.list_domains() @@ -115,8 +110,7 @@ class Cli(object): """ List deleted mailboxes """ - imap = IMAP() - imap._connect() + imap.connect() folders = imap.lm("DELETED/*") print "Deleted folders:" for folder in folders: @@ -130,8 +124,7 @@ class Cli(object): undelete_folder = conf.cli_args.pop(0) - imap = IMAP() - imap._connect() + imap.connect() folders = imap.lm("DELETED/*") for folder in folders: if undelete_folder == folder: @@ -146,7 +139,6 @@ class Cli(object): def action_list_domains(self): # Create the authentication object. # TODO: Binds with superuser credentials! - auth = Auth() domains = auth.list_domains() # TODO: Take a hint in --quiet, and otherwise print out a nice table @@ -155,7 +147,7 @@ class Cli(object): print _("Primary domain: %s - Secondary domain(s): %s") %(domain, ', '.join(domain_aliases)) def action_del_domain(self): - domainname = conf.args.pop(0) + domainname = conf.cli_args.pop(0) log.info(_("Deleting domain %s") %(domainname)) @@ -177,7 +169,7 @@ class Cli(object): def action_add_domain(self): log.info(_("TODO: Figure out where the domain should actually be added.")) - domainname = conf.args.pop(0) + domainname = conf.cli_args.pop(0) log.info(_("Adding domain %s") %(domainname)) @@ -203,7 +195,7 @@ class Cli(object): go_ahead = True - if conf.cli_options.review: + if conf.cli_keywords.review: ldif_writer = ldif.LDIFWriter(sys.stdout) ldif_writer.unparse(dn,attrs) if not utils.ask_confirmation(_("Please ACK or NACK the above LDIF:"), default="y", all_inclusive_no=True): |