From 18339f947ceef53c308d0f2976fa27ab93020368 Mon Sep 17 00:00:00 2001 From: Antonio Emmanuel Guerrero Silva Date: Wed, 20 Nov 2024 23:06:28 -0600 Subject: [PATCH] refs #1164 ogCheckProgram function correction --- client/lib/engine/bin/SystemLib.py | 31 +++++++++--------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/client/lib/engine/bin/SystemLib.py b/client/lib/engine/bin/SystemLib.py index 740eb35..39d0d23 100755 --- a/client/lib/engine/bin/SystemLib.py +++ b/client/lib/engine/bin/SystemLib.py @@ -268,47 +268,34 @@ def ogIsRepoLocked(): ogHelp(f"{FUNCNAME}", f"{FUNCNAME}", f"if {FUNCNAME}(): ...") # No hacer nada, si no está definido el punto de montaje del repositorio. - if not OGIMG: + if not ogGlobals.OGIMG: return 1 # Comprobar si alguno de los ficheros abiertos por los procesos activos está en el # punto de montaje del repositorio de imágenes. - FILES = subprocess.check_output(["find", "/proc", "-maxdepth", "2", "-type", "f", "-lname", f"{OGIMG}/*"]).decode("utf-8") + FILES = subprocess.check_output(["find", "/proc", "-maxdepth", "2", "-type", "f", "-lname", f"{ogGlobals.OGIMG}/*"]).decode("utf-8") return bool(FILES) -def ogCheckProgram(*args): +def ogCheckProgram(program): FUNCNAME = ogCheckProgram.__name__ - # Si se solicita, mostrar ayuda. - if len(args) > 0 and args[0] == "help": - ogHelp(f"{FUNCNAME} \"str_program ...\"", - f"{FUNCNAME} \"partimage partclone mbuffer\"") - return - # Error si no se recibe 1 parámetro. - if len(args) != 1: + if not program or not isinstance(program, str): SystemLib.ogRaiseError( "session", ogGlobals.OG_ERR_FORMAT, - f"Error: {ogGlobals.lang.MSG_ERR_FORMAT} {FUNCNAME} \"str_program ...\"" + f"Error: {ogGlobals.lang.MSG_ERR_FORMAT} {FUNCNAME} \"program\"" ) return - PERROR = 0 - PLOG = " " - for i in args[0].split(): - if not shutil.which(i): - PERROR = 1 - PLOG += f" {i}" - - if PERROR == 1: + if not shutil.which(program): SystemLib.ogRaiseError( "session", ogGlobals.OG_ERR_NOTEXEC, - f"Error: {PLOG}", + f"Error: The program '{program}' is not available on the system." ) return - else: - return 0 + + return 0 def ogIsVirtualMachine(): output = subprocess.run (["dmidecode", "-s", "system-product-name"], capture_output=True, text=True).stdout