コード例 #1
0
ファイル: errors.py プロジェクト: ppizarror/korektor
def st_info(msg, call_exit=False):
    """
    Muestra un mensaje de información en pantalla.

    :param msg: String del mensaje
    :type msg: str
    :param call_exit: Booleano, indica si el programa debe cerrarse o no
    :type call_exit: bool

    :return: void
    :rtype: None
    """
    print del_accent_by_os(COLOR.dark_cyan() + ST_INFO + COLOR.end() + " {0}".format(msg))
    if call_exit:
        exit()
コード例 #2
0
ファイル: errors.py プロジェクト: ppizarror/korektor
def st_warning(msg, call_exit=False, module=None, errname=None):
    """
    Muestra un mensaje de precaución en pantalla.

    :param msg: String del mensaje
    :type msg: str
    :param call_exit: Booleano, indica si el programa debe cerrarse o no
    :type call_exit: bool
    :param module: String indicando el nombre del modulo que produjo el error
    :type module: str
    :param errname: Excepción
    :type errname: Exception

    :return: void
    :rtype: None
    """
    if module is None:
        print del_accent_by_os(COLOR.blue() + ST_WARNING + COLOR.end() + " {0}".format(msg))
    else:
        print del_accent_by_os(
            COLOR.blue()
            + ST_ERROR
            + COLOR.end()
            + " {0} ".format(msg)
            + "["
            + COLOR.underline()
            + module
            + COLOR.end()
            + "]"
        )
    if errname is not None:
        print del_accent_by_os("      {0}".format(str(errname)))
    if call_exit:
        exit()
コード例 #3
0
ファイル: errors.py プロジェクト: ppizarror/korektor
    def _throw_exception(self, e, *format_args):
        """
        Función que lanza una excepción según comportamiento.

        :param e: Error string
        :type e: str
        :param format_args: Argumentos opcionales de los errores
        :type format_args: list

        :return: String o void
        :rtype: object
        """
        # Si no se han deshabilitado las excepciones
        if not self._exceptionsDisabled:

            # Se obtiene el mensaje a retornar (string o código de error)
            err = ""
            if self._exceptionMsgCode:  # Como código
                try:  # Se comprueba que el código exista
                    eval(e)
                    err = e
                except:
                    err = "BAD_ERROR_CODE"
            else:  # Como string (mensaje)
                try:  # Se comprueba que el código exista
                    err = del_accent_by_os(eval(e))
                except:
                    err = BAD_ERROR_CODE

            # Si la excepción se retorna como un string
            if self._exceptionStrBehaviour:
                return err

            # Si la excepción lanza error o Exception
            else:

                # Lanzar excepción
                if self._isEnabledExceptionThrowable:
                    raise Exception(err)

                # Lanzar error
                else:
                    throw(err)