refs #1164 ogCheckProgram function correction
parent
88dce42514
commit
18339f947c
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue