parent
c6735b15ee
commit
04d0b2208b
|
@ -5,6 +5,7 @@ import sys
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import inspect
|
import inspect
|
||||||
|
import glob
|
||||||
|
|
||||||
## for ogExecAndLog
|
## for ogExecAndLog
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
@ -258,43 +259,32 @@ def ogRaiseError (logtypes, code, msg):
|
||||||
#@return Código de salida: 0 - bloqueado, 1 - sin bloquear o error.
|
#@return Código de salida: 0 - bloqueado, 1 - sin bloquear o error.
|
||||||
#*/
|
#*/
|
||||||
def ogIsRepoLocked():
|
def ogIsRepoLocked():
|
||||||
# Variables locales
|
# No hacer nada, si no está definido el punto de montaje del repositorio.
|
||||||
FILES = ""
|
|
||||||
FUNCNAME = ogIsRepoLocked.__name__
|
|
||||||
|
|
||||||
# Si se solicita, mostrar ayuda.
|
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == "help":
|
|
||||||
ogHelp(f"{FUNCNAME}", f"{FUNCNAME}", f"if {FUNCNAME}(): ...")
|
|
||||||
|
|
||||||
# No hacer nada, si no está definido el punto de montaje del repositorio.
|
|
||||||
if not ogGlobals.OGIMG:
|
if not ogGlobals.OGIMG:
|
||||||
return 1
|
return False
|
||||||
|
|
||||||
# Comprobar si alguno de los ficheros abiertos por los procesos activos está en el
|
# Comprobar si alguno de los ficheros abiertos por los procesos activos está en el
|
||||||
# punto de montaje del repositorio de imágenes.
|
# punto de montaje del repositorio de imágenes.
|
||||||
FILES = subprocess.check_output(["find", "/proc", "-maxdepth", "2", "-type", "f", "-lname", f"{ogGlobals.OGIMG}/*"]).decode("utf-8")
|
proc_entries = glob.glob ('/proc/[0-9]*/fd/*')
|
||||||
return bool(FILES)
|
for e in proc_entries:
|
||||||
|
p = os.path.realpath (e)
|
||||||
|
if ogGlobals.OGIMG in p:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def ogCheckProgram(program):
|
## has no users
|
||||||
FUNCNAME = ogCheckProgram.__name__
|
#def ogCheckProgram(program):
|
||||||
|
# FUNCNAME = ogCheckProgram.__name__
|
||||||
if not program or not isinstance(program, str):
|
#
|
||||||
SystemLib.ogRaiseError(
|
# if not program or not isinstance(program, str):
|
||||||
"session",
|
# SystemLib.ogRaiseError ("session", ogGlobals.OG_ERR_FORMAT, f"Error: {ogGlobals.lang.MSG_ERR_FORMAT} {FUNCNAME} \"program\"")
|
||||||
ogGlobals.OG_ERR_FORMAT,
|
# return
|
||||||
f"Error: {ogGlobals.lang.MSG_ERR_FORMAT} {FUNCNAME} \"program\""
|
#
|
||||||
)
|
# if not shutil.which(program):
|
||||||
return
|
# SystemLib.ogRaiseError ( "session", ogGlobals.OG_ERR_NOTEXEC, f"Error: The program '{program}' is not available on the system.")
|
||||||
|
# return
|
||||||
if not shutil.which(program):
|
#
|
||||||
SystemLib.ogRaiseError(
|
# return 0
|
||||||
"session",
|
|
||||||
ogGlobals.OG_ERR_NOTEXEC,
|
|
||||||
f"Error: The program '{program}' is not available on the system."
|
|
||||||
)
|
|
||||||
return
|
|
||||||
|
|
||||||
return 0
|
|
||||||
|
|
||||||
def ogIsVirtualMachine():
|
def ogIsVirtualMachine():
|
||||||
output = subprocess.run (["dmidecode", "-s", "system-product-name"], capture_output=True, text=True).stdout
|
output = subprocess.run (["dmidecode", "-s", "system-product-name"], capture_output=True, text=True).stdout
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from SystemLib import ogHelp
|
||||||
|
from SystemLib import ogIsRepoLocked
|
||||||
|
|
||||||
|
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||||
|
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||||
|
ogHelp ('ogIsRepoLocked', 'ogIsRepoLocked', ['ogIsRepoLocked'])
|
||||||
|
sys.exit (0)
|
||||||
|
|
||||||
|
ret = ogIsRepoLocked()
|
||||||
|
|
||||||
|
if ret is not None:
|
||||||
|
if ret == True: sys.exit (0)
|
||||||
|
elif ret == False: sys.exit (1)
|
||||||
|
else: print (ret)
|
Loading…
Reference in New Issue