comparison service/reasoning/httpputoutputs.py @ 1560:c3d699b5759c

more py3 fixes Ignore-this: f212b4a5edf8e599e9efd70bc65e7651 darcs-hash:d944ca9d7d7b36c2c02529dcf9225a99c0aa1831
author drewp <drewp@bigasterisk.com>
date Fri, 14 Feb 2020 00:33:31 -0800
parents d36d3b9ae516
children
comparison
equal deleted inserted replaced
1559:6047a660ef76 1560:c3d699b5759c
61 self.nextCall = None 61 self.nextCall = None
62 self.lastErr = None 62 self.lastErr = None
63 log.debug("PUT %s payload=%s agent=%s", 63 log.debug("PUT %s payload=%s agent=%s",
64 self.url, self.payload, self.foafAgent) 64 self.url, self.payload, self.foafAgent)
65 if not self.mockOutput: 65 if not self.mockOutput:
66 self.currentRequest = treq.put(self.url, data=self.payload, 66 self.currentRequest = treq.put(self.url, data=self.payload.encode('utf8'),
67 headers=h, timeout=3) 67 headers=h, timeout=3)
68 self.currentRequest.addCallback(self.onResponse).addErrback( 68 self.currentRequest.addCallback(self.onResponse).addErrback(
69 self.onError) 69 self.onError)
70 else: 70 else:
71 reactor.callLater(.2, self.onResponse, None) 71 reactor.callLater(.2, self.onResponse, None)
113 """these grow forever""" 113 """these grow forever"""
114 def __init__(self, mockOutput=False): 114 def __init__(self, mockOutput=False):
115 self.mockOutput = mockOutput 115 self.mockOutput = mockOutput
116 self.state = {} # url: HttpPutOutput 116 self.state = {} # url: HttpPutOutput
117 117
118 def put(self, url, payload, foafAgent, refreshSecs): 118 def put(self, url: str, payload: str, foafAgent: str, refreshSecs: float):
119 assert isinstance(url, str)
120 if url not in self.state: 119 if url not in self.state:
121 self.state[url] = HttpPutOutput(url, mockOutput=self.mockOutput, 120 self.state[url] = HttpPutOutput(url, mockOutput=self.mockOutput,
122 refreshSecs=refreshSecs) 121 refreshSecs=refreshSecs)
123 self.state[url].setPayload(payload, foafAgent) 122 self.state[url].setPayload(payload, foafAgent)