]> git.mxchange.org Git - quix0rs-apt-p2p.git/blobdiff - apt_dht_Khashmir/DHT.py
No need to look at the DEFAULT section when parsing the config.
[quix0rs-apt-p2p.git] / apt_dht_Khashmir / DHT.py
index 42e2e9afd4489f33a1ddc385f1938b18301f5ec4..cfe07f004daff4bc075da4459bf2d168deb881fc 100644 (file)
@@ -32,7 +32,7 @@ class DHT:
         self.config_parser = config
         self.section = section
         self.config = {}
-        self.cache_dir = self.config_parser.get('DEFAULT', 'cache_dir')
+        self.cache_dir = self.config_parser.get(section, 'cache_dir')
         self.bootstrap = self.config_parser.getstringlist(section, 'BOOTSTRAP')
         self.bootstrap_node = self.config_parser.getboolean(section, 'BOOTSTRAP_NODE')
         for k in self.config_parser.options(section):
@@ -44,8 +44,6 @@ class DHT:
                 self.config[k] = self.config_parser.gettime(section, k)
             else:
                 self.config[k] = self.config_parser.get(section, k)
-        if 'PORT' not in self.config:
-            self.config['PORT'] = self.config_parser.getint('DEFAULT', 'PORT')
     
     def join(self):
         """See L{apt_dht.interfaces.IDHT}."""
@@ -253,12 +251,12 @@ class TestSimpleDHT(unittest.TestCase):
     def tearDown(self):
         self.a.leave()
         try:
-            os.unlink(self.a.khashmir.db)
+            os.unlink(self.a.khashmir.store.db)
         except:
             pass
         self.b.leave()
         try:
-            os.unlink(self.b.khashmir.db)
+            os.unlink(self.b.khashmir.store.db)
         except:
             pass
 
@@ -322,7 +320,7 @@ class TestMultiDHT(unittest.TestCase):
     def get_values(self):
         self.checked = 0
         for i in range(len(self.l)):
-            for j in random.sample(xrange(len(self.l)), 4):
+            for j in random.sample(xrange(len(self.l)), max(len(self.l), 4)):
                 self.checked += 1
                 d = self.l[i].getValue(sha.new(str(self.startport+j)).digest())
                 check = []
@@ -349,6 +347,6 @@ class TestMultiDHT(unittest.TestCase):
         for i in self.l:
             try:
                 i.leave()
-                os.unlink(i.khashmir.db)
+                os.unlink(i.khashmir.store.db)
             except:
                 pass