Exemple #1
0
def start_runner(code,
                 runner,
                 controller_type,
                 callback,
                 prefix=DEFAULT_RUNNER_PREFIX,
                 errback=None,
                 add_close_builtins=None,
                 add_allowed_modules=None,
                 remove_allowed_modules=None,
                 write_execute_data=False,
                 cover_code=None,
                 name='__check__',
                 skip_json_serializer=True):
    wcode = add_waiter(callback, errback)
    echo.send_json({
        'do': 'start_runner',
        'waiter': wcode,
        'code': code,
        'runner': runner,
        'prefix': prefix,
        'type': controller_type,
        'name': name,
        'env_config': {
            'add_close_builtins': add_close_builtins,
            'add_allowed_modules': add_allowed_modules,
            'remove_allowed_modules': remove_allowed_modules,
            'cover_code': cover_code,
            'skip_json_serializer': skip_json_serializer,
        },
        'config': {
            'write_execute_data': write_execute_data
        }
    })
    return wcode
Exemple #2
0
def sys_runner(code, callback, prefix=DEFAULT_RUNNER_PREFIX, errback=None):
    wcode = add_waiter(callback, errback)
    echo.send_json({
        'do': 'sys_runner',
        'waiter': wcode,
        'code': code,
        'prefix': prefix
    })
    return wcode
Exemple #3
0
def execute_function(input_data, callback, func=DEFAULT_FUNCTION, prefix=DEFAULT_RUNNER_PREFIX, errback=None):
    wcode = add_waiter(callback, errback)
    echo.send_json({
        'do': 'execute_function',
        'waiter': wcode,
        'func': func,
        'prefix': prefix,
        'input': input_data
    })
    return wcode
Exemple #4
0
def sys_runner(code, callback,
               prefix=DEFAULT_RUNNER_PREFIX, errback=None):
    wcode = add_waiter(callback, errback)
    echo.send_json({
        'do': 'sys_runner',
        'waiter': wcode,
        'code': code,
        'prefix': prefix
    })
    return wcode
Exemple #5
0
def add_process_listener(prefix, signal, callback):
    if prefix not in PROCESS_LISTENERS:
        PROCESS_LISTENERS[prefix] = {}

    PROCESS_LISTENERS[prefix][signal] = callback
    echo.send_json({
        'do': 'set_process_informer',
        'prefix': prefix,
        'signal': signal
    })
Exemple #6
0
def add_process_listener(prefix, signal, callback):
    if prefix not in PROCESS_LISTENERS:
        PROCESS_LISTENERS[prefix] = {}

    PROCESS_LISTENERS[prefix][signal] = callback
    echo.send_json({
        'do': 'set_process_informer',
        'prefix': prefix,
        'signal': signal
    })
Exemple #7
0
def execute_function(input_data,
                     callback,
                     func=DEFAULT_FUNCTION,
                     prefix=DEFAULT_RUNNER_PREFIX,
                     errback=None):
    wcode = add_waiter(callback, errback)
    echo.send_json({
        'do': 'execute_function',
        'waiter': wcode,
        'func': func,
        'prefix': prefix,
        'input': input_data
    })
    return wcode
Exemple #8
0
def start_runner(code, runner, controller_type, callback,
                 prefix=DEFAULT_RUNNER_PREFIX, errback=None,
                 add_close_builtins=None, add_allowed_modules=None, remove_allowed_modules=None,
                 write_execute_data=False, cover_code=None, name='__check__'):
    wcode = add_waiter(callback, errback)
    echo.send_json({
        'do': 'start_runner',
        'waiter': wcode,
        'code': code,
        'runner': runner,
        'prefix': prefix,
        'type': controller_type,
        'name': name,
        'env_config': {
            'add_close_builtins': add_close_builtins,
            'add_allowed_modules': add_allowed_modules,
            'remove_allowed_modules': remove_allowed_modules,
            'cover_code': cover_code
        },
        'config': {
            'write_execute_data': write_execute_data
        }
    })
    return wcode
Exemple #9
0
def kill_runner(prefix):
    echo.send_json({
        'do': 'kill_runner',
        'prefix': prefix
    })
Exemple #10
0
def request_write(data):
    echo.send_json({
        'do': 'request_write',
        'data': data
    })
Exemple #11
0
def success(score=0):
    echo.send_json({'do': 'success', 'score': score})
Exemple #12
0
def kill_runner(prefix):
    echo.send_json({'do': 'kill_runner', 'prefix': prefix})
Exemple #13
0
def request_write(data):
    echo.send_json({'do': 'request_write', 'data': data})
Exemple #14
0
def fail(num, description=''):
    echo.send_json({'do': 'fail', 'num': num, 'description': description})
Exemple #15
0
def close():
    echo.send_json({
        'do': 'close'
    })
Exemple #16
0
def fail(num, description=''):
    echo.send_json({
        'do': 'fail',
        'num': num,
        'description': description
    })
Exemple #17
0
def success(score=0):
    echo.send_json({
        'do': 'success',
        'score': score
    })
Exemple #18
0
def close():
    echo.send_json({'do': 'close'})