refs #1093 the call to ogListSoftware is optimized
parent
61fb90d033
commit
381099dcc4
|
@ -14,26 +14,21 @@ if len(sys.argv) > 1 and sys.argv[1] == "-r":
|
|||
REDUCED = "yes"
|
||||
sys.argv.pop(1)
|
||||
|
||||
# Validar argumentos
|
||||
if len(sys.argv) != 3:
|
||||
SystemLib.ogRaiseError("session", ogGlobals.OG_ERR_FORMAT, f"{ogGlobals.MSG_FORMAT}: {PROG} ndisco nparticion")
|
||||
sys.exit(1)
|
||||
|
||||
# Nombre del archivo de listado
|
||||
SOFTFILE = f"soft-{NetLib.ogGetIpAddress()}-{sys.argv[1]}-{sys.argv[2]}"
|
||||
softfile_path = os.path.join(ogGlobals.OGLOG, SOFTFILE)
|
||||
|
||||
try:
|
||||
# Generar listado de software con InventoryLib.ogListSoftware
|
||||
software_list = InventoryLib.ogListSoftware(int(sys.argv[1]), int(sys.argv[2]))
|
||||
|
||||
if REDUCED == "no":
|
||||
# Escribir el listado completo al archivo
|
||||
with open(softfile_path, "w") as f:
|
||||
for line in software_list:
|
||||
f.write(f"{line}\n")
|
||||
else:
|
||||
# Filtrar parches de Windows (KBxxxxxx) y guardar
|
||||
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:
|
||||
|
@ -42,6 +37,5 @@ try:
|
|||
print(softfile_path)
|
||||
|
||||
except Exception as e:
|
||||
# Manejar errores
|
||||
SystemLib.ogRaiseError("session", ogGlobals.OG_ERR_FORMAT, f"Error al generar el listado de software: {e}")
|
||||
sys.exit(1)
|
Loading…
Reference in New Issue