From d7db7041b2e3ddb213b1e2152db1ba5d7f41994b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 13 Sep 2013 16:07:39 -0400 Subject: [PATCH] Changes to get SOL console kind of working --- confluent/console.py | 4 ++-- confluent/httpapi.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/confluent/console.py b/confluent/console.py index 0d3d94ab..d13172a5 100644 --- a/confluent/console.py +++ b/confluent/console.py @@ -35,7 +35,7 @@ class _ConsoleHandler(object): #this represents some api view of a console handler. This handles things like #holding the caller specific queue data, for example, when http api should be -#sending data, but there is no outstanding POST request to hold it, +#sending data, but there is no outstanding POST request to hold it, # this object has the job of holding the data class ConsoleSession(object): """Create a new socket to converse with node console @@ -68,7 +68,7 @@ class ConsoleSession(object): deadline = currtime + 45 while len(self.databuffer) == 0 and currtime < deadline: timeo = deadline - currtime - self.conshdl.wait_for_data(timeout=timeo) + self.conshdl._console.wait_for_data(timeout=timeo) currtime = util.monotonic_time() retval = self.databuffer self.databuffer = "" diff --git a/confluent/httpapi.py b/confluent/httpapi.py index 5a2da740..ee887134 100644 --- a/confluent/httpapi.py +++ b/confluent/httpapi.py @@ -8,6 +8,7 @@ import confluent.console as console import confluent.auth as auth import confluent.util as util import eventlet +import json import os import string import urlparse @@ -124,19 +125,20 @@ def resourcehandler(env, start_response): elif 'keys' in querydict.keys(): # client wishes to push some keys into the remote console input = "" - for idx in xrange(0, len(querydict['keys'])): - input += chr(int(querydict['keys'][idx:idx+2])) - print "taking in "+input + for idx in xrange(0, len(querydict['keys']), 2): + input += chr(int(querydict['keys'][idx:idx+2],16)) sessid = querydict['session'] consolesessions[sessid].write(input) start_response('200 OK', [('Content-Type', 'application/json; charset=utf-8')]) - return # client has requests to send or receive, not both... + return [] # client has requests to send or receive, not both... else: #no keys, but a session, means it's hooking to receive data sessid = querydict['session'] outdata = consolesessions[sessid].get_next_output(timeout=45) - json = '{"session":"%s","data":"%s"}'%(querydict['session'], - outdata) + rsp = json.dumps({'session': querydict['session'], 'data': outdata}) + start_response('200 OK', [('Content-Type', + 'application/json; charset=utf-8')]) + return [rsp] start_response('404 Not Found', []) return ["Unrecognized directive (404)"]