def init(): if not os.path.exists(cts.CFG_DIR): os.makedirs(cts.CFG_DIR) datos.IDENT = register() result = cfg.read(CFG_NAME) if not result: with open(CFG_NAME, "wb") as config_file: cfg.add_section(cts.CFG_SECT_USER) cfg.add_section(cts.CFG_SECT_PROC) cfg.write(config_file) else: if not cfg.has_section(cts.CFG_SECT_PROC): cfg.add_section(cts.CFG_SECT_PROC) if not cfg.has_section(cts.CFG_SECT_USER): cfg.add_section(cts.CFG_SECT_USER) datos.user_bd = [Usuario.from_json(i) for i in read_from_file(cts.CFG_SECT_USER)] datos.proc_bd = [Proceso.from_json(i) for i in read_from_file(cts.CFG_SECT_PROC)]
def proces(pid, name, user, tiempo, comando, memoria, cpu): p = Proceso(pid, name, user, tiempo, comando) p.reg_data(tiempo, memoria, cpu) return p