class rGPIO(object): def __init__(self, logger): self.logger = logger logger.info("Starting GPIODaemon...") self.driver = Driver() logger.info("Initialized driver") def handle_cmd(self, cmd): # New handle command class that's simpler cmd = cmd.strip() self.logger.info("cmd: '%s'" % cmd) return self._handle_cmd(cmd) def _handle_cmd(self, internal_cmd): # Internal cmd is the actual command (triggered by the user command). # Any return value will be sent to the socket connection. self.logger.info("execute> %s" % internal_cmd) cmd_parts = internal_cmd.split(" ") cmd = cmd_parts[0] if cmd == "forward": self.logger.info("in command forward") self.driver.forward() return "going forward" elif cmd == "turn_left": self.logger.info("in command turn_left") self.driver.turn_left() return "turn left" elif cmd == "turn_right": self.logger.info("in command turn_right") self.driver.turn_right() return "turning_right" elif cmd == "stop": self.logger.info("in command stop") self.driver.stop() return "stop" elif cmd == "backward": self.logger.info("in command backward") self.driver.backward() return "backwards" else: self.logger.warn("command '%s' not recognized", cmd)