]> git.ipfire.org Git - ddns.git/blobdiff - src/ddns/__init__.py
Add runtime check for providers if all dependencies are met
[ddns.git] / src / ddns / __init__.py
index 22764e6e230feed5365c01bdc8d6b876e881ef4d..7f2729c2c8c0cc93e09e46ec343fce6804664276 100644 (file)
@@ -28,6 +28,7 @@ from i18n import _
 logger = logging.getLogger("ddns.core")
 logger.propagate = 1
 
+import database
 import providers
 
 from .errors import *
@@ -42,6 +43,8 @@ def setup_logging():
        handler = logging.handlers.SysLogHandler(address="/dev/log",
                facility=logging.handlers.SysLogHandler.LOG_DAEMON
        )
+       formatter = logging.Formatter("ddns[%(process)d]: %(message)s")
+       handler.setFormatter(formatter)
        handler.setLevel(logging.INFO)
        rootlogger.addHandler(handler)
 
@@ -74,6 +77,9 @@ class DDNSCore(object):
                # Add the system class.
                self.system = DDNSSystem(self)
 
+               # Open the database.
+               self.db = database.DDNSDatabase(self, "/var/lib/ddns.db")
+
        def get_provider_names(self):
                """
                        Returns a list of names of all registered providers.
@@ -83,7 +89,7 @@ class DDNSCore(object):
        def load_configuration(self, filename):
                logger.debug(_("Loading configuration file %s") % filename)
 
-               configs = ConfigParser.SafeConfigParser()
+               configs = ConfigParser.RawConfigParser()
                configs.read([filename,])
 
                # First apply all global configuration settings.
@@ -118,6 +124,12 @@ class DDNSCore(object):
                                logger.warning("Could not find provider '%s' for entry '%s'." % (provider, entry))
                                continue
 
+                       # Check if the provider is actually supported and if there are
+                       # some dependencies missing on this system.
+                       if not provider.supported():
+                               logger.warning("Provider '%s' is known, but not supported on this machine" % (provider.name))
+                               continue
+
                        # Create an instance of the provider object with settings from the
                        # configuration file.
                        entry = provider(self, **settings)