s4-python: Move dnspython to lib/, like the other Python modules
[kai/samba.git] / source4 / scripting / python / samba / external.py
index eca910b794dda010bfbfa446c70d48911e842d17..40d13fd7e5d0b72484815eda86e5f1ca18864d4c 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import sys, os
+import os, sys
 
-def samba_find_external(directory):
-    '''insert into out module search path the path to an
-       external library'''
-    for p in sys.path:
-        dir = os.path.join(p, directory)
-        if os.path.isdir(dir):
-            sys.path.insert(0, dir)
-            return
-
-    # finally try in the local directory, to handle in-tree testing
-    dir = os.path.join("scripting/python", directory)
-    if os.path.isdir(dir):
-        sys.path.insert(0, dir)
-        return
-
-    print "Failed to find external python library %s" % directory
-    raise
-
-
-def samba_external_dns_resolver():
+def dns_resolver():
     '''try and import the dns.resolver library, and if it fails
     then use a local copy from the external directory'''
 
     try:
         import dns.resolver as dns
-    except:
-        samba_find_external("samba_external/dnspython")
+    except ImportError:
+        sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../../../lib/dnspython"))
         import dns.resolver as dns
     return dns