Added error feedback for run_program and stop_programs
Previously the client had no way of knowing if the controller actually executed an action. Now it does.
This commit is contained in:
parent
278caced99
commit
74a7737d05
1 changed files with 9 additions and 3 deletions
|
@ -40,7 +40,7 @@ class SensorReadout:
|
||||||
MODES = tuple(NAMED_MODES.keys())
|
MODES = tuple(NAMED_MODES.keys())
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, handler, poll_rate=0.2):
|
def __init__(self, handler, poll_rate=0.5):
|
||||||
self.poll_rate = poll_rate
|
self.poll_rate = poll_rate
|
||||||
self.handler = handler
|
self.handler = handler
|
||||||
self.peer_lock = threading.Lock()
|
self.peer_lock = threading.Lock()
|
||||||
|
@ -173,14 +173,19 @@ class ListPrograms(Pipe):
|
||||||
|
|
||||||
|
|
||||||
class StopPrograms(Pipe):
|
class StopPrograms(Pipe):
|
||||||
|
NO_PROGRAMS_RUNNING = 1
|
||||||
|
|
||||||
def run(self, data, peer, handler):
|
def run(self, data, peer, handler):
|
||||||
if handler.debug:
|
if handler.debug:
|
||||||
Logging.info("Stopping all botball programs.")
|
Logging.info("Stopping all botball programs.")
|
||||||
output = subprocess.call(["killall", "botball_user_program"],
|
if subprocess.call(["killall", "botball_user_program"],
|
||||||
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT):
|
||||||
|
handler.pipe(self.__class__.NO_PROGRAMS_RUNNING, "stop_programs", peer)
|
||||||
|
|
||||||
|
|
||||||
class RunProgram(Pipe):
|
class RunProgram(Pipe):
|
||||||
|
PROGRAM_NOT_FOUND = 1
|
||||||
|
|
||||||
def __init__(self, output_unbuffer):
|
def __init__(self, output_unbuffer):
|
||||||
self.command = [output_unbuffer, "-i0", "-o0", "-e0"]
|
self.command = [output_unbuffer, "-i0", "-o0", "-e0"]
|
||||||
|
|
||||||
|
@ -195,6 +200,7 @@ class RunProgram(Pipe):
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
start_new_thread(self.stream_stdout, (program, peer, handler))
|
start_new_thread(self.stream_stdout, (program, peer, handler))
|
||||||
else:
|
else:
|
||||||
|
handler.pipe(self.__class__.PROGRAM_NOT_FOUND, "run_program", peer)
|
||||||
if handler.debug:
|
if handler.debug:
|
||||||
Logging.warning("Program '%s' not found." % data[:-1])
|
Logging.warning("Program '%s' not found." % data[:-1])
|
||||||
|
|
||||||
|
|
Reference in a new issue