refs #1399 remove ogCheckStringInGroup, ogCheckStringInReg
parent
9997e78b31
commit
30c90442b7
|
@ -1,31 +1,5 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
def ogCheckStringInGroup(element, group):
|
|
||||||
"""
|
|
||||||
Función para determinar si el elemento pertenece a un conjunto.
|
|
||||||
|
|
||||||
:param element: elemento a comprobar
|
|
||||||
:param group: grupo de elementos para comprobar tipo "valor1 valor2 valor3"
|
|
||||||
:return: True si pertenece al grupo, False si NO pertenece al grupo
|
|
||||||
"""
|
|
||||||
if not isinstance(element, str) or not isinstance(group, str):
|
|
||||||
raise ValueError("Formato incorrecto, ambos parámetros deben ser cadenas.")
|
|
||||||
|
|
||||||
return element in group.split()
|
|
||||||
|
|
||||||
def ogCheckStringInReg(element, regex):
|
|
||||||
"""
|
|
||||||
Función para determinar si el elemento contiene una "expresión regular".
|
|
||||||
|
|
||||||
:param element: elemento a comprobar
|
|
||||||
:param regex: expresión regular
|
|
||||||
:return: True si coincide con la expresión, False si NO coincide con la expresión
|
|
||||||
"""
|
|
||||||
if not isinstance(element, str) or not isinstance(regex, str):
|
|
||||||
raise ValueError("Formato incorrecto, ambos parámetros deben ser cadenas.")
|
|
||||||
|
|
||||||
return re.match(regex, element) is not None
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#/**
|
#/**
|
||||||
|
|
|
@ -236,15 +236,17 @@ def ogRaiseError (logtypes, code, msg):
|
||||||
MSG = ogGlobals.lang.MSG_ERR_GENERIC
|
MSG = ogGlobals.lang.MSG_ERR_GENERIC
|
||||||
CODE = ogGlobals.OG_ERR_GENERIC
|
CODE = ogGlobals.OG_ERR_GENERIC
|
||||||
|
|
||||||
|
# Obtener lista de funciones afectadas, incluyendo el script que las llama.
|
||||||
call_stack = [i[3] for i in inspect.stack()]
|
call_stack = [i[3] for i in inspect.stack()]
|
||||||
if len (call_stack) < 2: return ## shouldn't happen
|
if len (call_stack) < 2: return ## shouldn't happen
|
||||||
call_stack.pop() ## remove '<module>'
|
call_stack.pop() ## remove '<module>'
|
||||||
call_stack.pop(0) ## remove 'ogRaiseError'
|
call_stack.pop(0) ## remove 'ogRaiseError'
|
||||||
str_call_stack = ' '.join (call_stack)
|
str_call_stack = ' '.join (call_stack)
|
||||||
|
|
||||||
|
# Mostrar mensaje de error si es función depurable y salir con el código indicado.
|
||||||
if code == ogGlobals.OG_ERR_FORMAT or \
|
if code == ogGlobals.OG_ERR_FORMAT or \
|
||||||
StringLib.ogCheckStringInGroup (str_call_stack, ogGlobals.NODEBUGFUNCTIONS) or \
|
(str_call_stack in ogGlobals.NODEBUGFUNCTIONS) or \
|
||||||
not (len(call_stack)>0 and StringLib.ogCheckStringInGroup (call_stack[0], ogGlobals.NODEBUGFUNCTIONS)):
|
not (len(call_stack)>0 and (call_stack[0] in ogGlobals.NODEBUGFUNCTIONS)):
|
||||||
ogEcho (logtypes, "error", f"{str_call_stack.replace(' ', '<-')}: {MSG}")
|
ogEcho (logtypes, "error", f"{str_call_stack.replace(' ', '<-')}: {MSG}")
|
||||||
|
|
||||||
return code
|
return code
|
||||||
|
|
|
@ -45,7 +45,7 @@ MCASTWAIT=30 # timeout (segundos) para abortar la la tran
|
||||||
#BACKUP=False # Realizar copia de seguridad antes de crear la imagen.
|
#BACKUP=False # Realizar copia de seguridad antes de crear la imagen.
|
||||||
#IMGFS='EXT4' # Sistema de archivo de la imagenes sincronizadas. EXT4 o BTRFS
|
#IMGFS='EXT4' # Sistema de archivo de la imagenes sincronizadas. EXT4 o BTRFS
|
||||||
#OGSLEEP=20 # Tiempo de sleep antes de realizar el reboot
|
#OGSLEEP=20 # Tiempo de sleep antes de realizar el reboot
|
||||||
NODEBUGFUNCTIONS='ogCreateImageSyntax ogGetHivePath ogGetOsType ogRestoreImageSyntax ogUnmountAll ogUnmountCache' # Funciones que no deben mostrar salida de avisos si son llamadas por otras funciones.
|
NODEBUGFUNCTIONS=['ogCreateImageSyntax', 'ogGetHivePath', 'ogGetOsType', 'ogRestoreImageSyntax', 'ogUnmountAll', 'ogUnmountCache'] # Funciones que no deben mostrar salida de avisos si son llamadas por otras funciones.
|
||||||
#DEFAULTSPEED=''
|
#DEFAULTSPEED=''
|
||||||
## /engine.cfg
|
## /engine.cfg
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue