Change class names to less misleading

This commit is contained in:
Igor Dunaev 2023-11-16 18:57:59 +03:00
parent e70077c9bc
commit 939b433841

View File

@ -14,7 +14,7 @@ def select(fr: Collection[ActionDescriptor], where: tuple[str, Any]) -> Optional
return None if len(results) == 0 else results[0]
class TurtleDeviceThread():
class TurtleDeviceController():
def __init__(self):
super().__init__()
self._device = TurtleDevice()
@ -52,24 +52,24 @@ class NoBlockingTurtleShell(cmd.Cmd):
prompt = '(turtle) '
file = None
def __init__(self, turtle_thread: TurtleDeviceThread):
def __init__(self, turtle_thread: TurtleDeviceController):
super(NoBlockingTurtleShell, self).__init__()
self._turtle_thread = turtle_thread
self._turtle_controller = turtle_thread
def do_execute(self, arg: str):
'Execute a turtle command: EXECUTE COMMAND ARG1 ARG2 ...'
self._turtle_thread.send(arg.split(' '))
self._turtle_controller.send(arg.split(' '))
def do_exit(self, arg):
'close the turtle window, and exit: EXIT'
print('Waiting for the turtle to finish jobs...')
self._turtle_thread.send(['stop'])
self._turtle_controller.send(['stop'])
return True
if __name__ == '__main__':
turtle_thread = TurtleDeviceThread()
shell = NoBlockingTurtleShell(turtle_thread)
turtle_controller = TurtleDeviceController()
shell = NoBlockingTurtleShell(turtle_controller)
cmd_thread = threading.Thread(target=shell.cmdloop)
cmd_thread.start()
turtle_thread.run()
turtle_controller.run()