Exemplo n.º 1
0
def pyval(expr: str, ns: Namespace) -> None:
    """
    Évalue une expression.
    Retour (sérialisé) via pipe
    """
    try:
        evaluation = safe_eval(expr)
    except BaseException as ex:
        evaluation = ex
    ns.evaluation = evaluation
Exemplo n.º 2
0
def pyval(expr: str, queue: Queue) -> None:
    """
    Évalue une expression.
    Retour (sérialisé) via pipe
    """
    try:
        evaluation = safe_eval(expr)
    except BaseException as ex:
        evaluation = ex
    queue.put(evaluation)
Exemplo n.º 3
0
def pyval(expr: str, retour: list) -> None:
    """
    Évalue une expression.
    Reour via via argument
    """
    try:
        assert retour[0] == 99
        retour[0] = safe_eval(expr)
        print(expr, '=', retour[0])
    except BaseException as ex:
        exexit(ex)
Exemplo n.º 4
0
def pyval(expr: str, pipe: Connection) -> None:
    """
    Évalue une expression.
    Retour (sérialisé) via pipe
    """
    try:
        evaluation = safe_eval(expr)
    except BaseException as ex:
        evaluation = ex
    pipe.send(evaluation)
    pipe.close()
Exemplo n.º 5
0
def pyval(expr: str) -> None:
    """
    Évalue une expression.
    Reour via varaible globale
    """
    global EVALUATION
    try:
        EVALUATION = safe_eval(expr)
        print(expr, '=', EVALUATION)

    except BaseException as ex:
        exexit(ex)
Exemplo n.º 6
0
def pyval(expr: str, retour: Value) -> None:
    """
    Évalue une expression.
    Reour via via Multiprocessing.Value (shared memory)
    Type supporté: c_double = python float
    """
    try:
        assert retour.value == 99
        retour.value = float(safe_eval(expr))
        print(expr, '=', retour.value)
    except BaseException as ex:
        exexit(ex)
Exemplo n.º 7
0
def pyval(expr: str, retour: mp.Array) -> None:
    """
    Évalue une expression.
    Reour via via Multiprocessing.Value (shared memory)
    Type supporté: c_double = python float
    """
    try:
        evaluation = safe_eval(expr)
    except BaseException as ex:
        evaluation = ex
    serialisation: bytes = pickle.dumps(evaluation)
    retour[:len(serialisation)] = serialisation
Exemplo n.º 8
0
def pyval(expr: str, filename: str) -> None:
    """
    Évalue une expression.
    Reour via sérialisation dans un fichieer.
    Même l'exeption est retournée
    """
    try:
        evaluation = safe_eval(expr)
        print(expr, '=', evaluation)
    except BaseException as ex:
        evaluation = ex

    with open(filename, 'w+b') as f:
        pickle.dump(evaluation, f)
Exemplo n.º 9
0
def pyval(expr: str, filename: str) -> None:
    """
    Évalue une expression.
    Reour via via Multiprocessing.Value (shared memory)
    Type supporté: c_double = python float
    """
    try:
        evaluation = safe_eval(expr)
        print(expr, '=', evaluation)
        with open(filename, 'w+b') as f:
            pickle.dump(evaluation, f)

    except BaseException as ex:
        exexit(ex)