import os import sys sys.path.append('/opt/opengnsys/lib/engine/bin') import SystemLib import InventoryLib import NetLib import ogGlobals PROG = os.path.basename(__file__) REDUCED = "no" if len(sys.argv) > 1 and sys.argv[1] == "-r": REDUCED = "yes" sys.argv.pop(1) if len(sys.argv) != 3: SystemLib.ogRaiseError("session", ogGlobals.OG_ERR_FORMAT, f"{ogGlobals.MSG_FORMAT}: {PROG} ndisco nparticion") sys.exit(1) SOFTFILE = f"soft-{NetLib.ogGetIpAddress()}-{sys.argv[1]}-{sys.argv[2]}" softfile_path = os.path.join(ogGlobals.OGLOG, SOFTFILE) try: software_list = InventoryLib.ogListSoftware(int(sys.argv[1]), int(sys.argv[2])) if REDUCED == "no": with open(softfile_path, "w") as f: for line in software_list: f.write(f"{line}\n") else: filtered_list = [line for line in software_list if "(KB" not in line] with open(softfile_path, "w") as f: for line in filtered_list: f.write(f"{line}\n") print(softfile_path) except Exception as e: SystemLib.ogRaiseError("session", ogGlobals.OG_ERR_FORMAT, f"Error al generar el listado de software: {e}") sys.exit(1)