@@ -0,0 +1,2963 @@
+#!/usr/bin/env python%0A# encoding=utf8%0A%0Aimport requests%0Afrom flexbe_core import EventState, Logger%0A%0A%22%22%22%0ACreated on 17/05/2018%0A%0A@author: Lucas Maurice%0A%22%22%22%0A%0A%0Aclass WonderlandPatchPerson(EventState):%0A    '''%0A    Patch (update) a person.%0A    %3E#  entity                  sara_msgs/Entity%0A%0A    %3C= done                     return when the add correctly append%0A    %3C= dont_exist                return when the entity already exist%0A    %3C= bad_request              return when error reading data%0A    %3C= error                    return when error reading data%0A    '''%0A%0A    def __init__(self):%0A        # See example_state.py for basic explanations.%0A        super(WonderlandPatchPerson, self).__init__(input_keys=%5B'entity'%5D,%0A                                                    outcomes=%5B'done', 'dont_exist', 'bad_request', 'error'%5D)%0A%0A    def execute(self, userdata):%0A        # Generate URL to contact%0A%0A        url = %22http://wonderland:8000/api/people/%22%0A%0A        entity = userdata.entity%0A%0A        data = %7B%7D%0A%0A        if entity.wonderlandId is None and entity.face.id is None:%0A            Logger.logwarn('Need wonderland ID or face ID !')%0A            return 'bad_request'%0A%0A        if entity.wonderlandId is not None:%0A            data.update(%7B'peopleId': entity.wonderlandId%7D)%0A%0A        if entity.face.id is not None:%0A            data.update(%7B'peopleRecognitionId': entity.face.id%7D)%0A%0A        if entity.color is not None:%0A            data.update(%7B'peopleColor': entity.color%7D)%0A%0A        if entity.pose is not None:%0A            data.update(%7B'peoplePose': entity.pose%7D)%0A%0A        if entity.poseProbability is not None:%0A            data.update(%7B'peoplePoseAccuracy': entity.color%7D)%0A%0A        if entity.face.gender is not None:%0A            data.update(%7B'peopleGender': entity.face.gender%7D)%0A%0A        if entity.face.genderProbability is not None:%0A            data.update(%7B'peopleGenderAccuracy': entity.face.genderProbability%7D)%0A%0A        if entity.face.emotion is not None:%0A            data.update(%7B'peopleEmotion': entity.face.emotion%7D)%0A%0A        if entity.face.emotionProbability is not None:%0A            data.update(%7B'peopleEmotionAccuracy': entity.face.emotionProbability%7D)%0A%0A        if entity.isOperator is not None:%0A            data.update(%7B'peopleIsOperator': entity.isOperator%7D)%0A%0A        if len(entity.aliases) %3E 0:%0A            data.update(%7B'peopleName': entity.aliases%5B0%5D%7D)%0A%0A        # try the request%0A        try:%0A            response = requests.patch(url, data=data)%0A            if response.status_code == 200:%0A                return 'done'%0A%0A            elif response.status_code == 404:%0A                return 'dont_exist'%0A%0A            elif 400 %3C= response.status_code %3C 500:%0A                Logger.logwarn(response.status_code)%0A                return 'bad_request'%0A%0A            else:%0A                Logger.logerr(response.status_code)%0A                return 'error'%0A%0A        except requests.exceptions.RequestException as e:%0A            Logger.logerr(e)%0A            return 'error'%0A

Add a state for patch a person in wonderland.