#!/usr/bin/python3
import subprocess
import json
print('Configuracion de EVO\n')
CONFIG_SOURCE = "/srv/datalogger_ecom/config_ecom.json"
try:
    update_flag = False  
    config_file=open(CONFIG_SOURCE,'r')
    config=json.load(config_file)
    lista_evo = config["DUST_SENSOR"]["EVOS"]
    if len(lista_evo)==0:
        print('NO HAY NINGUN EVO AGREGADO, REINICIANDO SERVICIO DE ACTUALIZACIÓN')
        out = subprocess.check_output(['config']).decode()
        print(out)
    else:
        print("Lista de EVOS Configurados: \n")
        for i in range(len(lista_evo)):
            print(str(i+1)+". "+lista_evo[i])
        print('REINICIANDO SERVICIO DE ACTUALIZACIÓN')
        out = subprocess.check_output(['config']).decode()
        print(out)
        
except: pass