summaryrefslogtreecommitdiffstats
path: root/pykolab/base.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2010-08-26 10:17:37 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2010-08-26 10:17:37 +0100
commite2f75e06656c1bd0cd0cecb4a99b8220f468fd8d (patch)
treef0ac19bdd7be13845c8a706df50f37333bf02a86 /pykolab/base.py
downloadpykolab-e2f75e06656c1bd0cd0cecb4a99b8220f468fd8d.tar.gz
Initial commit
Diffstat (limited to 'pykolab/base.py')
-rw-r--r--pykolab/base.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/pykolab/base.py b/pykolab/base.py
new file mode 100644
index 0000000..224d466
--- /dev/null
+++ b/pykolab/base.py
@@ -0,0 +1,69 @@
+# -*- coding: utf-8 -*-
+# Copyright 2010 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 2 only
+#
+# 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.
+#
+
+from pykolab.conf import Defaults, Runtime
+import pykolab.conf
+
+class PyKolabBase(object):
+
+ def __init__(self, pykolab):
+ """
+ Initializes the a PyKolab class with the options specified from the command line.
+ Launches our plugin detection.
+ Creates a logger instance
+ Creates a configuration store
+ Detects whether we are in CLI or GUI mode
+ Sets the logger configuration
+ Sets up the final configuration store
+ """
+
+ # Get the options parser, it's valuable ;-)
+ self.parser = revisor.parser
+
+ # The options it has defined are valuable too
+ self.cli_options = revisor.cli_options
+ self.plugins = revisor.plugins
+ self.plugins.base = self
+
+ # At this point, 'self' isn't much yet, so:
+ # first create a simple logger instance that won't do much,
+ # then create a configuration store with that logger,
+ # then start detecting the mode that we are in (GUI / CLI),
+ # then let the logger know about the configuration store,
+ # then /really/ set up the configuration store (now that it has a
+ # valid logger that knows about the configuration store),
+ #
+ # Create logger
+ self.create_logger()
+
+ # Create ConfigStore (it needs the logger to be created!)
+ self.create_configstore()
+
+ # Detect our mode (options or try/except)
+ self.detect_mode()
+
+ # Let the logger know about cfg (it needs a ConfigStore instance!)
+ self.log.set_config(self.cfg)
+
+ # Then really setup the ConfigStore (because that needs a logger!)
+ self.cfg.setup_cfg()
+
+ misc.check_selinux(log=self.log)
+
+