Commit 7f96ca82 authored by Guillaume Seguin's avatar Guillaume Seguin

Better integration of RPC server, fix bugs

parent 34e638e9
...@@ -462,6 +462,7 @@ class pronsole(cmd.Cmd): ...@@ -462,6 +462,7 @@ class pronsole(cmd.Cmd):
self.p.onlinecb = self.online self.p.onlinecb = self.online
self.p.errorcb = self.logError self.p.errorcb = self.logError
self.fgcode = None self.fgcode = None
self.rpc_server = None
self.listing = 0 self.listing = 0
self.sdfiles = [] self.sdfiles = []
self.paused = False self.paused = False
...@@ -484,6 +485,8 @@ class pronsole(cmd.Cmd): ...@@ -484,6 +485,8 @@ class pronsole(cmd.Cmd):
self.settings._bedtemp_abs_cb = self.set_temp_preset self.settings._bedtemp_abs_cb = self.set_temp_preset
self.settings._bedtemp_pla_cb = self.set_temp_preset self.settings._bedtemp_pla_cb = self.set_temp_preset
self.update_build_dimensions(None, self.settings.build_dimensions) self.update_build_dimensions(None, self.settings.build_dimensions)
self.update_tcp_streaming_mode(None, self.settings.tcp_streaming_mode)
self.update_rpc_server(None, self.settings.rpc_server)
self.monitoring = 0 self.monitoring = 0
self.starttime = 0 self.starttime = 0
self.extra_print_time = 0 self.extra_print_time = 0
...@@ -635,6 +638,10 @@ class pronsole(cmd.Cmd): ...@@ -635,6 +638,10 @@ class pronsole(cmd.Cmd):
self.prompt = self.promptf() self.prompt = self.promptf()
return stop return stop
def kill(self):
if self.rpc_server is not None:
self.rpc_server.shutdown()
def write_prompt(self): def write_prompt(self):
sys.stdout.write(self.promptf()) sys.stdout.write(self.promptf())
sys.stdout.flush() sys.stdout.flush()
...@@ -977,8 +984,13 @@ class pronsole(cmd.Cmd): ...@@ -977,8 +984,13 @@ class pronsole(cmd.Cmd):
self.p.tcp_streaming_mode = self.settings.tcp_streaming_mode self.p.tcp_streaming_mode = self.settings.tcp_streaming_mode
def update_rpc_server(self, param, value): def update_rpc_server(self, param, value):
if value and self.rpc_server is not None: if value:
self.rpc_server = ProntRPC(self) if self.rpc_server is None:
self.rpc_server = ProntRPC(self)
else:
if self.rpc_server is not None:
self.rpc_server.shutdown()
self.rpc_server = None
# -------------------------------------------------------------- # --------------------------------------------------------------
# Command line options handling # Command line options handling
......
...@@ -325,6 +325,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -325,6 +325,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.Close() self.Close()
def kill(self, e): def kill(self, e):
pronsole.pronsole.kill(self)
global pronterface_quitting global pronterface_quitting
pronterface_quitting = True pronterface_quitting = True
self.statuscheck = False self.statuscheck = False
......
...@@ -17,16 +17,20 @@ class ProntRPC(object): ...@@ -17,16 +17,20 @@ class ProntRPC(object):
def run_server(self): def run_server(self):
self.server.serve_forever() self.server.serve_forever()
def shutdown(self):
self.server.shutdown()
self.thread.join()
def get_status(self): def get_status(self):
if self.pronsole.p.printing: if self.pronsole.p.printing:
progress = 100 * float(self.pronsole.p.queueindex) / len(self.pronsole.p.mainqueue) progress = 100 * float(self.pronsole.p.queueindex) / len(self.pronsole.p.mainqueue)
elif self.pronsole.sdprinting: elif self.pronsole.sdprinting:
progress = self.percentdone progress = self.percentdone
else: progress = None else: progress = -1
if self.pronsole.p.printing or self.pronsole.sdprinting: if self.pronsole.p.printing or self.pronsole.sdprinting:
eta = self.get_eta() eta = self.get_eta()
else: else:
eta = None eta = -1
return {"filename": self.pronsole.filename, return {"filename": self.pronsole.filename,
"progress": progress, "progress": progress,
"eta": eta, "eta": eta,
......
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