async def stop_calibration(): pump_type = request.args.get('type') print(pump_type) resp = {} if pump_type in ['conditioner', 'co2', 'fertilizer']: controller.stop_cal() if controller.cal_time: resp['cal_time'] = controller.cal_time else: resp['error'] = 'Calibration was cancelled' else: resp['error'] = 'Invalid pump type' return jsonify(resp)
async def update_db(): transaction_id = request.args.get('transact_id') contact_no = request.args.get('contact_no') session_id = request.args.get('session_id') conn = pymssql.connect('DBSERVER', 'DBUSER', 'DBPASS', "DBNAME") cursor = conn.cursor() cursor.execute("UPDATE transactionTable set transactionID='" + transaction_id + "',contactNumber='" + contact_no + "' WHERE ID=" + session_id) conn.commit() response = {'result': "OK", 'message': "Database updated"} cursor.close() conn.close() return json.jsonify(response)
async def send_message(): number = request.args.get('number') message = request.args.get('message') response = {} if number and message: if not client.is_connected(): await client.connect() try: message_object = await (client.send_message(number, message)) response['message'] = str(message_object) response['result'] = "OK" except ValueError: response['message'] = "Recepient name or number not found " response['result'] = "ERROR" except: response['message'] = "Error sending message" response['result'] = "ERROR" else: response['message'] = "Params missing" response['result'] = "ERROR" return json.jsonify(response)
async def playlist(): return jsonify([])
async def get_server_data(): print("Sending Data to Client") return jsonify(utils.load())
async def get_conversions_tanksize(): print(f"Sending Tank Size") return jsonify(utils.load())
async def delete(self): """ Delete treatments """ return jsonify({'status': 'Not implemented'})
async def post(self): """ Submit new treatments """ return jsonify({'status': 'Not implemented'})
def get(self): return jsonify(json_serializers.serialize_default(self.stage))
async def update(): data = controller.update() return jsonify(data)
async def root(): response = {'status': '200 OK'} return json.jsonify(response)
def task_test(self): # task = FlickerDim(self.stage.grid_front_left, length=None) # task = FlickerDim(self.stage.all, length=None) task = SineRainbow(self.stage.all) self.scheduler.add_task(task, 2) return jsonify(json_serializers.serialize_default(task))
def get_list(self): return jsonify(json_serializers.serialize_default(self.scheduler._tasks))
def get_by_id(self, id): print(id) return jsonify(json_serializers.serialize_default([self.universe]))
def get_list(self): return jsonify(json_serializers.serialize_default([self.universe]))
async def get_server_data(): print("Sending Data to Client") data = controller.load_data() return jsonify(data)
async def load_config(): print("Sending Config to Client") config_data = controller.load_config() print(f"Return Config: {config_data}") return jsonify(config_data)
async def get(self): """ Get all entries matching the query """ return jsonify(json_list=app.db_session.query(Entry).all())
async def get(self): """ Get all treatments matching the query """ return jsonify(json_list=app.db_session.query(Treatment).all())
async def swagger_blueprint_config_handler(): return jsonify(doc.get_config(request.host))