Commit a2339576 authored by D1plo1d's avatar D1plo1d

Fixing websocket parameter parsing

...@@ -157,7 +157,6 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler): ...@@ -157,7 +157,6 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler):
"set", "set",
"estop", "estop",
"print", "print",
"pause_print",
"add_job", "add_job",
"rm_job", "rm_job",
"change_job", "change_job",
...@@ -165,24 +164,35 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler): ...@@ -165,24 +164,35 @@ class ConstructSocketHandler(tornado.websocket.WebSocketHandler):
] ]
print "message received: %s"%(msg) 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("@\s", "@")
msg = msg.replace("@", "at:")
words = msg.split("\s") words = msg.split("\s")
cmd = words[0] cmd = words[0]
arg_words = words[1:]
args = {} if cmd == "set":
for w in words[1:]: 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(":"): if w.contains(":"):
k, v = w.split(":") k, v = w.split(":")
args[k] = float(v) kwargs[k] = float(v)
else: else:
args[w] = True kwargs[w] = True
print args
if cmd in cmds_whitelist: 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: else:
self.write_message({"error": "%s command does not exist."%key}) self.write_message({"error": "%s command does not exist."%key})
...@@ -259,6 +269,9 @@ class Pronserve(pronsole.pronsole, EventEmitter): ...@@ -259,6 +269,9 @@ class Pronserve(pronsole.pronsole, EventEmitter):
if self.p.online: if self.p.online:
self.printing_jobs = True self.printing_jobs = True
def do_home(self, **kwargs):
print "wut homing!"
def run_print_queue_loop(self): def run_print_queue_loop(self):
# This is a polling work around to the current lack of events in printcore # 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 # 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