Files
tello-commander/brain/brain_base.py

33 lines
921 B
Python

import os
from commander.commands import CommandHandler
class BaseBrain:
def __init__(self):
self.command_handler = CommandHandler()
@property
def sys_prompt(self):
return self._read_prompt()
def _read_prompt(self):
prompt_file_name = "prompt.txt"
for root, dirs, files in os.walk("./"):
if prompt_file_name in files:
prompt_filepath = os.path.join(root, prompt_file_name)
with open(prompt_filepath, "r") as f:
return f.read()
def is_emergency(self, input):
if input == "q":
print("##### BASE BRAIN: EMERGENCY STOP DETECTED!!! #####")
self.command_handler.handle({"command": "emergency"})
return True
else:
return False
def listen(self):
self.cmd_prompt = input("\n\nwhat should I do now?\n(enter q for emergency)\n\t")