コード例 #1
0
ファイル: State.py プロジェクト: openspaceaarhus/Foodputer
    def handle_hal(self, json_data):
        """handles the dict generated from parsing the json data

        fields:
        status: Hal.ACCEPT ect as int REQUIRED
        """
        
        status = int(json_data['status'])
        print "status: ", status

        if status == Hal.ACCEPT:
            Foodputer.set_state(start)
            GUI.accepted_order()
        elif status == Hal.DENY:
            if Pin_check.tries_left == 0:
                self.handle_abort()
            else:
                Foodputer.set_state(ordering)
                GUI.wrong_pin(Pin_check.tries_left)
                Pin_check.tries_left -= 1;
        elif status == Hal.NOFUNDS:
            Foodputer.set_state(ordering)
            GUI.not_enough_money();
        else:
            putil.trace("no such return is nice {}".format(status));
            self.handle_abort()