X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=apt_dht_Khashmir%2Factions.py;h=72637110860cd8fbcb6acbf1c630cae2783d8efa;hb=9400d298505b852ab82e78e1f9b9d82c3f6aeb34;hp=a99b7ea7d9c5810e7cf443f4e9673a3ea1e936f7;hpb=74e8a91349d0b55447de62ce72db692c177bcec7;p=quix0rs-apt-p2p.git diff --git a/apt_dht_Khashmir/actions.py b/apt_dht_Khashmir/actions.py index a99b7ea..7263711 100644 --- a/apt_dht_Khashmir/actions.py +++ b/apt_dht_Khashmir/actions.py @@ -2,6 +2,7 @@ # see LICENSE.txt for license information from twisted.internet import reactor +from twisted.python import log from khash import intify @@ -75,7 +76,7 @@ class FindNode(ActionBase): self.queried[node.id] = 1 if self.outstanding >= self.config['CONCURRENT_REQS']: break - assert(self.outstanding) >=0 + assert self.outstanding >=0 if self.outstanding == 0: ## all done!! self.finished=1 @@ -83,7 +84,8 @@ class FindNode(ActionBase): def makeMsgFailed(self, node): def defaultGotNodes(err, self=self, node=node): - print ">>> find failed (%s) %s/%s" % (self.config['PORT'], node.host, node.port), err + log.msg("find failed (%s) %s/%s" % (self.config['PORT'], node.host, node.port)) + log.err(err) self.caller.table.nodeFailed(node) self.outstanding = self.outstanding - 1 self.schedule() @@ -153,7 +155,7 @@ class GetValue(FindNode): try: f = getattr(node, self.findValue) except AttributeError: - print ">>> findValue %s doesn't have a %s method!" % (node, self.findValue) + log.msg("findValue %s doesn't have a %s method!" % (node, self.findValue)) else: df = f(self.target, self.caller.node.id) df.addCallback(self.handleGotNodes) @@ -162,7 +164,7 @@ class GetValue(FindNode): self.queried[node.id] = 1 if self.outstanding >= self.config['CONCURRENT_REQS']: break - assert(self.outstanding) >=0 + assert self.outstanding >=0 if self.outstanding == 0: ## all done, didn't find it!! self.finished=1 @@ -184,9 +186,10 @@ class GetValue(FindNode): class StoreValue(ActionBase): - def __init__(self, caller, target, value, callback, config, store="storeValue"): + def __init__(self, caller, target, value, originated, callback, config, store="storeValue"): ActionBase.__init__(self, caller, target, callback, config) self.value = value + self.originated = originated self.stored = [] self.store = store @@ -205,7 +208,7 @@ class StoreValue(ActionBase): return t def storeFailed(self, t, node): - print ">>> store failed %s/%s" % (node.host, node.port) + log.msg("store failed %s/%s" % (node.host, node.port)) self.caller.nodeFailed(node) self.outstanding -= 1 if self.finished: @@ -232,9 +235,9 @@ class StoreValue(ActionBase): try: f = getattr(node, self.store) except AttributeError: - print ">>> %s doesn't have a %s method!" % (node, self.store) + log.msg("%s doesn't have a %s method!" % (node, self.store)) else: - df = f(self.target, self.value, self.caller.node.id) + df = f(self.target, self.value, self.originated, self.caller.node.id) df.addCallback(self.storedValue, node=node) df.addErrback(self.storeFailed, node=node)