def run(self):
        # get the vector's database entry
        vector = Vectors.query.filter_by(id=self.vector_id).first()

        # try to send to command to the robot, log the result
        with anki_vector.Robot(vector.serial) as robot:
            try:
                if self.command == "dock":
                    output = str(robot.behavior.drive_on_charger())
                elif self.command == "undock":
                    output = str(robot.behavior.drive_off_charger())
            except Exception as e:
                output = e

        if self.log == "true":
            info = f"vector_id: {self.vector_id} \n \n output: {output}"
            run_plugin(
                "logbook",
                {
                    "name": f"{vector.name} ran {self.command}",
                    "vector_id": vector.id,
                    "info": info,
                    "log_type": "success",
                },
            )
        run_plugin("stats", {"vector_id": vector.id, "log": False})
        return output
Beispiel #2
0
    def run(self):
        # get the vector's database entry
        vector = Vectors.query.filter_by(id=self.vector_id).first()

        # try to send to command to the robot, log the result if log is True
        with anki_vector.Robot(vector.serial) as robot:
            try:
                output = str(robot.behavior.say_text(self.text_to_say))
            except Exception as e:
                output = e
        if self.log == "true":
            info = (
                f"text_to_say: {self.text_to_say} \n \n"
                f"vector_id: {self.vector_id} \n \n"
                f"output: {output}"
            )
            run_plugin(
                "logbook",
                {
                    "name": f"{vector.name} ran custom say",
                    "vector_id": vector.id,
                    "info": info,
                    "log_type": "success",
                },
            )
        return output
Beispiel #3
0
 def handle_logbook_log(json):
     run_plugin(
         "logbook",
         {
             "name": json.get("name", None),
             "info": json.get("info", None),
             "log_type": json.get("log_type", None),
         },
     )
Beispiel #4
0
 def get(self):
     api_key = "123456789"
     if request.args["api_key"] == api_key:
         options = {}
         for key, value in request.args.items():
             options[key] = value
         output = run_plugin(request.args.get("name"), options)
         return output
     else:
         return {"response": "Unauthorized"}
     return "ok"
Beispiel #5
0
 def handle_logbook_request():
     run_plugin("logbook", {"emit_only": True})
 def run(self):
     run_plugin(
         "logbook", {"name": "rc does not have a run function", "log_type": "fail"},
     )
Beispiel #7
0
def run():
    options = {}
    for fieldname, value in request.form.items():
        if fieldname != "plugin_name" and len(value) >= 1:
            options[fieldname] = value
    return run_plugin(request.form.get("plugin_name"), options)
Beispiel #8
0
 def handle_logbook_request(json={}):
     run_plugin("logbook", {
         "emit_only": True,
         "from_item": json.get("from_item", 0)
     })