changeset 1409:e78b8806ad05

actually set put payload this time. add treq dep Ignore-this: b6a05c294d9a5ee6052972cad4ecb5c5 darcs-hash:d41a16eb44db885ff391ddbe64352245b885a838
author drewp <drewp@bigasterisk.com>
date Tue, 23 Jul 2019 17:37:24 -0700
parents 89bf0d204b29
children dc70ee50c981
files service/reasoning/actions.py service/reasoning/requirements.txt
diffstat 2 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/service/reasoning/actions.py	Tue Jul 23 17:30:46 2019 -0700
+++ b/service/reasoning/actions.py	Tue Jul 23 17:37:24 2019 -0700
@@ -13,19 +13,20 @@
 class HttpPutOutput(object):
     def __init__(self, url):
         self.url = url
-        self.body = None
+        self.payload = None
         self.foafAgent = None
         self.nextCall = None
         self.numRequests = 0
 
-    def setBody(self, body, foafAgent):
-        if self.numRequests > 0 and (self.body == body or self.foafAgent == foafAgent):
+    def setPayload(self, payload, foafAgent):
+        if self.numRequests > 0 and (self.payload == payload or self.foafAgent == foafAgent):
             return
+        self.payload = payload
         self.foafAgent = foafAgent
         self.makeRequest()
 
     def makeRequest(self):
-        if self.body is None:
+        if self.payload is None:
             log.info("PUT None to %s - waiting", self.url)
             return
         h = {}
@@ -35,8 +36,8 @@
             self.nextCall.cancel()
             self.nextCall = None
         self.lastErr = None
-        log.info("PUT %s payload=%s agent=%s", self.url, self.body, self.foafAgent)
-        self.currentRequest = treq.put(self.url, data=self.body, headers=h, timeout=3)
+        log.info("PUT %s payload=%s agent=%s", self.url, self.payload, self.foafAgent)
+        self.currentRequest = treq.put(self.url, data=self.payload, headers=h, timeout=3)
         self.currentRequest.addCallback(self.onResponse).addErrback(self.onError)
         self.numRequests += 1
 
@@ -57,10 +58,10 @@
     def __init__(self):
         self.state = {} # url: HttpPutOutput
 
-    def put(self, url, body, foafAgent):
+    def put(self, url, payload, foafAgent):
         if url not in self.state:
             self.state[url] = HttpPutOutput(url)
-        self.state[url].setBody(body, foafAgent)
+        self.state[url].setPayload(payload, foafAgent)
         log.info('PutOutputs has %s urls', len(self.state))
 
 class Actions(object):
--- a/service/reasoning/requirements.txt	Tue Jul 23 17:30:46 2019 -0700
+++ b/service/reasoning/requirements.txt	Tue Jul 23 17:37:24 2019 -0700
@@ -4,6 +4,7 @@
 docopt
 ipdb
 service_identity
+treq==18.6.0
 twisted
 
 rdflib==4.2.2