Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
    })
Beispiel #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
    })
Beispiel #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
Beispiel #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
Beispiel #9
0
def kill_runner(prefix):
    echo.send_json({
        'do': 'kill_runner',
        'prefix': prefix
    })
Beispiel #10
0
def request_write(data):
    echo.send_json({
        'do': 'request_write',
        'data': data
    })
Beispiel #11
0
def success(score=0):
    echo.send_json({'do': 'success', 'score': score})
Beispiel #12
0
def kill_runner(prefix):
    echo.send_json({'do': 'kill_runner', 'prefix': prefix})
Beispiel #13
0
def request_write(data):
    echo.send_json({'do': 'request_write', 'data': data})
Beispiel #14
0
def fail(num, description=''):
    echo.send_json({'do': 'fail', 'num': num, 'description': description})
Beispiel #15
0
def close():
    echo.send_json({
        'do': 'close'
    })
Beispiel #16
0
def fail(num, description=''):
    echo.send_json({
        'do': 'fail',
        'num': num,
        'description': description
    })
Beispiel #17
0
def success(score=0):
    echo.send_json({
        'do': 'success',
        'score': score
    })
Beispiel #18
0
def close():
    echo.send_json({'do': 'close'})