def createXMLM(result_mova, token): logging.info({ "process": "createXMLM", "message": "Creating xmls" }) for row in result_mova: xml_mova = mova(row) xml_mova += """ <documentos> <documento>{}</documento> <fvencimiento>{}</fvencimiento> <numonto>{}</numonto> <nuinteres>{}</nuinteres> <nuiva>{}</nuiva> <tmovimiento>FAC</tmovimiento> </documentos> """.format( row[1], row[3], 0 if row[4] <= 0 else row[4], row[5], row[6] ) xml_mova += """ </movimiento> """ """ Envío de xmls a la API de Linq """ sendData(xml_mova, token)
def createXMLA(result_apli, token): logging.info({"process": "createXMLA", "message": "Creating xmls"}) for row in result_apli: xml_apli = apli(row) xml_apli += """ <documentos> <documento>{}</documento> <fvencimiento>{}</fvencimiento> <numonto>-{}</numonto> <tmovimiento>{}</tmovimiento> </documentos> """.format(row[1], row[3], str(row[4])[1:] if "-" in str(row[4]) else row[4], row[5]) xml_apli += """ </movimiento> """ """ Envío de xmls a la API de Linq """ sendData(xml_apli, token)
def createXMLS(result_saldo, token): logging.info({"process": "createXMLS", "message": "Creating xmls"}) for row in result_saldo: xml_saldo = saldo(row) """ Envío de xmls a la API de Linq """ sendData(xml_saldo, token)
def createXMLC(result_cacre, token): logging.info({"process": "createXMLC", "message": "Creating xmls"}) for row in result_cacre: xml_cacre = cacre(row) """ Envío de xmls a la API de Linq """ sendData(xml_cacre, token)
def apli(bot, update): logging.info({ "process": "napli", "user_id": update.message.from_user.id, "username": update.message.from_user.first_name, "text": update.message.text }) update.message.reply_text( "Ingresa fecha en formato AAAA/MM/DD para ver registros APLI") text = update.message.text chat_id = update.message.chat_id if "/" in text: # Validar fecha bot.send_chat_action(chat_id=chat_id, action=ChatAction.TYPING) time.sleep(0.3) response = sendData(text, "APLI") data = json.loads(response.text) """ content = dict(zip([i for i in range(1, len(data)+1, 1)],data)) content = {1: {dictionary}} """ content = dict(zip([i for i in range(1, len(data) + 1, 1)], data)) bot.send_message(chat_id=chat_id, text="*Movimientos del dia*", parse_mode=ParseMode.MARKDOWN) for k, v in content.items(): bot.send_message(chat_id=chat_id, text=v, parse_mode=ParseMode.MARKDOWN)
def createXML(result_alta, token): logging.info({"process": "createXML", "message": "Creating xmls"}) rc = [((row[30], row[32] if row[32] != "" else "")) for row in result_alta] diccionario_contratos = collections.defaultdict(list) for k, v in rc: diccionario_contratos[k].append(v) diccionario_contratos = dict(diccionario_contratos) for c in result_alta: xml_deu = alta(c, diccionario_contratos[c[30]]) xml_deu += """ </movimiento> """ """ Envío de xmls a la API de Linq """ sendData(xml_deu, token)
def createXMLO(result_otros, token): logging.info({ "process": "createXMLO", "message": "Creating xmls" }) for row in result_otros: xml_otros = otros(row) xml_otros += """ <documentos> <documento>{}</documento> <fvencimiento>{}</fvencimiento> <numonto>-{}</numonto> <nutmovimiento>1</nutmovimiento> </documentos> """.format(row[1], row[2], row[3]) xml_otros += """ <documentos> <documento>{}</documento> <fvencimiento>{}</fvencimiento> <numonto>-{}</numonto> <nutmovimiento>2</nutmovimiento> </documentos> """.format(row[1], row[2], row[4]) xml_otros += """ </movimiento> """ """ Desde aquí se envían a la API de Linq """ sendData(xml_otros, token)
def detect_task(bot, update): text = update.message.text chat_id = update.message.chat_id token = getToken() logging.info({ "process": "detect_task", "user_id": update.message.from_user.id, "username": update.message.from_user.first_name, "text": text }) if "/" in text: bot.send_chat_action(chat_id=chat_id, action=ChatAction.TYPING) time.sleep(0.3) response = sendData(text, "") content = cleanData.cleanNMovimientos(response) bot.send_message(chat_id=chat_id, text=content, parse_mode=ParseMode.MARKDOWN) # bot.send_chat_action(chat_id=chat_id, action=ChatAction.TYPING) # time.sleep(0.5) # response = sendData(text, "APLI") # content = cleanData.cleanMovimientos(response, bot, update) elif "#" in text: content = text.upper().split("#") oper = content[0] contracts = tuple(content[1].split(",")) if oper == 'CACRE': query = queries.QueryL.queryD(contracts) createXMLC(queryExecute(query), token, bot, update) elif oper == 'SALDOS': query = queries.QueryL.querySaldo() createXMLS(queryExecute(query), token) bot.send_chat_action(chat_id=chat_id, action=ChatAction.TYPING) time.sleep(0.3) bot.send_message(chat_id=chat_id, text="\ \n*Operación*: Envío de SALDOS:\ \n*Estatus*: Operación finalizada.", parse_mode=ParseMode.MARKDOWN)
def createXMLC(result_cacre, token, bot, update): chat_id = update.message.chat_id logging.info({ "process": "createXMLC", "message": "Creating xmls" }) for row in result_cacre: xml_cacre = cacre(row) """ Envío de xmls a la API de Linq """ response = sendData(xml_cacre, token) bot.send_chat_action(chat_id=chat_id, action=ChatAction.TYPING) time.sleep(0.3) bot.send_message( chat_id=chat_id, text="*{}*".format(response.text), parse_mode=ParseMode.MARKDOWN )
#!/usr/bin/env python # Library imports from time import sleep import time from datetime import datetime import json from send_data import sendData import random send_data = sendData() # check if MQTT client is connected to Broker if send_data.is_mqtt_connect == False: print("MQTT client is not Connected") while True: payload = { "temperature": str(random.randrange(60, 80)), "pressure-1": str(random.randrange(40, 60)), "pressure-2": str(random.randrange(40, 50)), "vibration": str(random.randrange(50, 100)), "timestamp": int(time.time()) } send_data.run(payload) time.sleep(10)