Commit a2339576 authored by D1plo1d's avatar D1plo1d

Fixing websocket parameter parsing

parent 5ab4d8e0
......@@ -157,7 +157,6 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler):
"set",
"estop",
"print",
"pause_print",
"add_job",
"rm_job",
"change_job",
......@@ -165,24 +164,35 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler):
]
print "message received: %s"%(msg)
msg = re.sub(r'\s+', "\s" ,msg)
msg = re.sub(r'\s+', "\s" ,msg).strip()
msg = msg.replace(":\s", ":")
msg = msg.replace("@\s", "@")
msg = msg.replace("@", "at:")
words = msg.split("\s")
cmd = words[0]
args = {}
for w in words[1:]:
arg_words = words[1:]
if cmd == "set":
subCmd = words[1]
arg_words = words[2:]
kwargs = {}
if not (len(arg_words) == 1 and arg_words[0] == ''):
for w in arg_words:
if w.contains(":"):
k, v = w.split(":")
args[k] = float(v)
kwargs[k] = float(v)
else:
args[w] = True
print args
kwargs[w] = True
if cmd in cmds_whitelist:
getattr(pronserve, "do_%s"%cmd)(args)
try:
if cmd == "set":
getattr(pronserve, "do_set")(subCmd, **kwargs)
else:
getattr(pronserve, "do_%s"%cmd)(**kwargs)
except:
self.write_message({"error": "bad command."})
else:
self.write_message({"error": "%s command does not exist."%key})
......@@ -259,6 +269,9 @@ class Pronserve(pronsole.pronsole, EventEmitter):
if self.p.online:
self.printing_jobs = True
def do_home(self, **kwargs):
print "wut homing!"
def run_print_queue_loop(self):
# This is a polling work around to the current lack of events in printcore
# A better solution would be one in which a print_finised event could be
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment