]> git.ipfire.org Git - ddns.git/blobdiff - src/ddns/providers.py
Add runtime check for providers if all dependencies are met
[ddns.git] / src / ddns / providers.py
index b66afc51bc4dae7da2fa750553bb7fffd5135a4f..2c54f5a3efccbc55418aed5ab826598149777d40 100644 (file)
@@ -21,6 +21,7 @@
 
 import datetime
 import logging
+import os
 import subprocess
 import urllib2
 import xml.dom.minidom
@@ -84,6 +85,14 @@ class DDNSProvider(object):
 
                        _providers[provider.handle] = provider
 
+       @staticmethod
+       def supported():
+               """
+                       Should be overwritten to check if the system the code is running
+                       on has all the required tools to support this provider.
+               """
+               return True
+
        def __init__(self, core, **settings):
                self.core = core
 
@@ -406,6 +415,19 @@ class DDNSProviderBindNsupdate(DDNSProvider):
 
        DEFAULT_TTL = 60
 
+       @staticmethod
+       def supported():
+               # Search if the nsupdate utility is available
+               paths = os.environ.get("PATH")
+
+               for path in paths.split(":"):
+                       executable = os.path.join(path, "nsupdate")
+
+                       if os.path.exists(executable):
+                               return True
+
+               return False
+
        def update(self):
                scriptlet = self.__make_scriptlet()