refs #1093 Script InventarioSoftware is optimized
parent
381099dcc4
commit
c066725bce
|
@ -4,18 +4,14 @@ import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
sys.path.append('/opt/opengnsys/lib/engine/bin')
|
||||||
|
import ogGlobals
|
||||||
|
|
||||||
def main(arg1, arg2, dest_file):
|
def main(arg1, arg2, dest_file):
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
# Cargar la configuración del motor desde el archivo engine.cfg
|
og_log_session = os.getenv(ogGlobals.OGLOGSESSION)
|
||||||
og_engine_configurate = os.getenv('OGENGINECONFIGURATE')
|
og_log_command = os.getenv(ogGlobals.OGLOGCOMMAND)
|
||||||
if not og_engine_configurate:
|
|
||||||
with open('/opt/opengnsys/etc/engine.cfg') as f:
|
|
||||||
exec(f.read())
|
|
||||||
|
|
||||||
# Limpiar los archivos temporales usados como log para httpdlog
|
|
||||||
og_log_session = os.getenv('OGLOGSESSION')
|
|
||||||
og_log_command = os.getenv('OGLOGCOMMAND')
|
|
||||||
if og_log_session and og_log_command:
|
if og_log_session and og_log_command:
|
||||||
with open(og_log_session, 'w') as f:
|
with open(og_log_session, 'w') as f:
|
||||||
f.write(" ")
|
f.write(" ")
|
||||||
|
@ -24,12 +20,10 @@ def main(arg1, arg2, dest_file):
|
||||||
with open(f"{og_log_command}.tmp", 'w') as f:
|
with open(f"{og_log_command}.tmp", 'w') as f:
|
||||||
f.write(" ")
|
f.write(" ")
|
||||||
|
|
||||||
# Registrar el inicio de ejecución
|
msg_interface_start = os.getenv(ogGlobals.MSG_INTERFACE_START)
|
||||||
msg_interface_start = os.getenv('MSG_INTERFACE_START')
|
|
||||||
if msg_interface_start:
|
if msg_interface_start:
|
||||||
subprocess.run(['ogEcho', 'log', 'session', f"{msg_interface_start} {__file__} {arg1} {arg2}"])
|
subprocess.run(['ogEcho', 'log', 'session', f"{msg_interface_start} {__file__} {arg1} {arg2}"])
|
||||||
|
|
||||||
# Ejecutar el script listSoftwareInfo y capturar el archivo de salida
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["python3", "/opt/opengnsys/scripts/listSoftwareInfo.py", arg1, arg2],
|
["python3", "/opt/opengnsys/scripts/listSoftwareInfo.py", arg1, arg2],
|
||||||
|
@ -37,15 +31,14 @@ def main(arg1, arg2, dest_file):
|
||||||
text=True,
|
text=True,
|
||||||
check=True
|
check=True
|
||||||
)
|
)
|
||||||
file = result.stdout.strip() # Captura la salida del script
|
file = result.stdout.strip().splitlines()[-1]
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(f"Error al ejecutar listSoftwareInfo: {e.stderr}")
|
print(f"Error al ejecutar listSoftwareInfo: {e.stderr}")
|
||||||
sys.exit(e.returncode)
|
sys.exit(e.returncode)
|
||||||
|
|
||||||
# Copiar el archivo resultante a dest_file
|
print(f"Copying:( {file} to {dest_file} )")
|
||||||
shutil.copy(file, dest_file)
|
shutil.copy(file, dest_file)
|
||||||
|
|
||||||
# Registrar el tiempo de ejecución
|
|
||||||
elapsed_time = time.time() - start_time
|
elapsed_time = time.time() - start_time
|
||||||
msg_scripts_time_partial = os.getenv('MSG_SCRIPTS_TIME_PARTIAL')
|
msg_scripts_time_partial = os.getenv('MSG_SCRIPTS_TIME_PARTIAL')
|
||||||
if msg_scripts_time_partial:
|
if msg_scripts_time_partial:
|
||||||
|
@ -55,4 +48,4 @@ if __name__ == "__main__":
|
||||||
if len(sys.argv) != 4:
|
if len(sys.argv) != 4:
|
||||||
print("Usage: python InventarioSoftware.py <arg1> <arg2> <dest_file>")
|
print("Usage: python InventarioSoftware.py <arg1> <arg2> <dest_file>")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
main(sys.argv[1], sys.argv[2], sys.argv[3])
|
main(sys.argv[1], sys.argv[2], sys.argv[3])
|
Loading…
Reference in New Issue