Esempio n. 1
0
 def post(self):
     # check lock file
     filelock = FileLock("raspidrink")
     if filelock.is_valide():
         return {'status': 'working'}
     else:
         # No lock file, we can reverse all pump
         json_data = request.get_json(force=True)
         action = json_data['action']
         if action not in ("on", "off"):
             return {'error': 'Bad action'}
         else:
             reverse_pump.delay(action)
             return {'status': 'ok'}
Esempio n. 2
0
 def post(self):
     # check lock file
     filelock = FileLock("raspidrink")
     if filelock.is_valide():
         return {'status': 'working'}
     else:
         # No lock file, we can make the cocktail
         json_data = request.get_json(force=True)
         slot_volume_dict = json_data['data']
         # decode json. This give a string
         slot_volume_dict = json.dumps(slot_volume_dict)
         # use ast to convert str from unicode to a dict
         slot_volume_dict = ast.literal_eval(slot_volume_dict)
         make_cocktail.delay(slot_volume_dict)
         timeout_delay = get_time_delay_for_slot_and_volume(
             slot_volume_dict)
         return {'status': 'ok', 'delay': timeout_delay}
Esempio n. 3
0
    def post(self):
        # check lock file
        filelock = FileLock("raspidrink")
        if filelock.is_valide():
            return {'status': 'working'}
        else:
            json_data = request.get_json(force=True)
            action = json_data['action']
            try:
                slot_id = json_data['slot_id']
                action = json_data['action']
            except KeyError, e:
                slot_id = None

            if action not in ("start", "stop"):
                return {'error': 'Bad action'}
            else:
                pump_management.delay(action, slot_id)
                return {'status': 'ok'}