Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes produce.py

  • Loading branch information...
commit 89db203a587f35b53ae237562f7d598ca10691c7 1 parent 74c7215
@barberdt barberdt authored
Showing with 3 additions and 5 deletions.
  1. +0 −3  lib/swarmtoolscore.py
  2. +3 −2 produce.py
View
3  lib/swarmtoolscore.py
@@ -51,8 +51,6 @@ def set_keys(hostname, user_id, password):
create_key(hostname, user_id, password, "participation")
resp = get_keys_from_server(hostname, user_id, password)
txt = resp.read()
- print txt
- print resp.status
if resp.status >= 400:
print "Something bad happened: "
print resp.status, txt
@@ -90,7 +88,6 @@ def get_keys_from_server(hostname, user_id, password):
conn = httplib.HTTPConnection(hostname)
auth_hash = user_id + ":" + password
auth_header = "Basic " + base64.b64encode(auth_hash)
- print auth_header
conn.request("GET", "/keys", None, {"Authorization":auth_header})
resp = conn.getresponse()
return resp
View
5 produce.py
@@ -22,6 +22,7 @@ def signal_handler(signal, frame):
def produce(hostname, api_key, swarm_id, resource_id, raw):
global conn
conn = httplib.HTTPConnection(hostname)
+ conn.debuglevel = 1
sel = "/stream?swarm_id=%s&resource_id=%s"%(swarm_id, resource_id)
conn.putrequest("POST", sel)
conn.putheader("x-bugswarmapikey", api_key)
@@ -45,7 +46,7 @@ def produce(hostname, api_key, swarm_id, resource_id, raw):
elif (len(msg) < 1):
break
else:
- stripped_msg = msg.strip()
+ stripped_msg = msg.strip() + "\r\n"
size = hex(len(stripped_msg))[2:] + "\r\n"
chunk = stripped_msg + "\r\n"
conn.send(size+chunk)
@@ -58,7 +59,7 @@ def produce(hostname, api_key, swarm_id, resource_id, raw):
if (len(payload) < 1):
break
stripped_payload = payload.strip()
- msg = '{"message": {"to": ["' + swarm_id + '"], "payload": ' + stripped_payload + '}}'
+ msg = '{"message": {"to": ["' + swarm_id + '"], "payload": ' + stripped_payload + '}}\r\n'
size = hex(len(msg))[2:] + "\r\n"
chunk = msg + "\r\n"
conn.send(size+chunk)
Please sign in to comment.
Something went wrong with that request. Please try again.