42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
|
|
import hana_client
|
|
import sap_services
|
|
import core
|
|
import logger_utilities
|
|
from datetime import datetime
|
|
###################################################
|
|
def main():
|
|
|
|
registros = hana_client.obtener_registros()
|
|
|
|
session = sap_services.login()
|
|
|
|
for registro in registros:
|
|
|
|
|
|
print(f"\n▶▶ Procesando registro número: {registro['DocNum']} (DocEntry: {registro['DocEntry']}) - Usuario: {registro.get('UserCode', 'N/A')}")
|
|
core.procesar_registro(registro, session)
|
|
|
|
sap_services.logout(session)
|
|
|
|
###################################################
|
|
if __name__ == "__main__":
|
|
|
|
# Configurar Logger (Redirige stdout a archivo y consola)
|
|
log_path = logger_utilities.setup_logger()
|
|
logger_utilities.limpiar_logs_antiguos(dias=30)
|
|
|
|
inicio_ejecucion = datetime.now()
|
|
print("="*60)
|
|
print(f"🚀 INICIO DE EJECUCIÓN: {inicio_ejecucion.strftime('%Y-%m-%d %H:%M:%S')}")
|
|
print(f"📄 Log guardado en: {log_path}")
|
|
print("="*60)
|
|
|
|
main()
|
|
|
|
fin_ejecucion = datetime.now()
|
|
duracion = fin_ejecucion - inicio_ejecucion
|
|
print("\n" + "="*60)
|
|
print(f"🏁 FIN DE EJECUCIÓN: {fin_ejecucion.strftime('%Y-%m-%d %H:%M:%S')}")
|
|
print(f"⏱️ Duración total: {str(duracion).split('.')[0]}")
|
|
print("="*60) |