self.apt_config['Dir'] = self.cache_dir.path
self.apt_config['Dir::State::status'] = self.cache_dir.preauthChild(self.apt_config['Dir::State']).preauthChild(self.apt_config['Dir::State::status']).path
self.packages = PackageFileList(cache_dir)
- self.loaded = 0
+ self.loaded = False
self.loading = None
self.unload_later = None
else:
self.srcrecords = None
- self.loaded = 1
+ self.loaded = True
return True
def unload(self):
del self.records
del self.srcrecords
del self.indexrecords
- self.loaded = 0
+ self.loaded = False
def cleanup(self):
"""Cleanup and close any loaded caches."""
"""The main apt-dht modules.
+To run apt-dht, you probably want to do something like::
+
+ from apt_dht.apt_dht import AptDHT
+ myapp = AptDHT(myDHT)
+
+where myDHT is a DHT that implements interfaces.IDHT.
+
Diagram of the interaction between the given modules::
+---------------+ +-----------------------------------+ +-------------
self.callback = callback
self.outstanding = 0
self.outstanding_results = 0
- self.finished = 0
+ self.finished = False
def sort(a, b, num=self.num):
"""Sort nodes relative to the ID we are looking for."""
if self.desired_results and ((len(self.results) >= abs(self.desired_results)) or
(self.desired_results < 0 and
len(self.answered) >= self.config['STORE_REDUNDANCY'])):
- self.finished=1
+ self.finished = True
result = self.generateResult()
reactor.callLater(0, self.callback, *result)
# If no requests are outstanding, then we are done
if self.outstanding == 0:
- self.finished = 1
+ self.finished = True
result = self.generateResult()
reactor.callLater(0, self.callback, *result)
decode_func['u'] = decode_unicode
decode_func['t'] = decode_datetime
-def bdecode(x, sloppy = 0):
+def bdecode(x, sloppy = False):
"""Bdecode a string of data.
@type x: C{string}
self.conn.commit()
def getRoutingTable(self):
- """Load routing table nodes from database.
-
- It's usually a good idea to call refreshTable(force=1) after loading the table.
- """
+ """Load routing table nodes from database."""
c = self.conn.cursor()
c.execute("SELECT * FROM nodes")
return c.fetchall()
class Node:
"""Encapsulate a node's contact info.
+ @ivar conn: the connection to the remote node (added externally)
+ @ivar table: the routing table (added externally)
@type fails: C{int}
@ivar fails: number of times this node has failed in a row
@type lastSeen: C{datetime.datetime}