30 lines
1010 B
Python
30 lines
1010 B
Python
from typing import Callable, Union, Tuple
|
|
|
|
from phasmplatform.common.config import WorkerConfig
|
|
from phasmplatform.common.methodcall import MethodCall, MethodCallError
|
|
from phasmplatform.common.value import Value, NoneValue
|
|
|
|
from .base import BaseRunner
|
|
|
|
|
|
class PreludeRunner(BaseRunner):
|
|
__slots__ = ('config', 'container_log', )
|
|
|
|
config: WorkerConfig
|
|
container_log: Tuple[Callable[[str], None]] # Tuple for typing issues
|
|
|
|
def set_config(self, config: WorkerConfig, container_log: Callable[[str], None]) -> None:
|
|
self.config = config
|
|
self.container_log = (container_log, )
|
|
|
|
def do_call(self, call: MethodCall) -> Union[Value, MethodCallError]:
|
|
if call.method.name == 'on_module_loaded':
|
|
self.container_log[0]('PreludeRunner loaded')
|
|
return NoneValue
|
|
|
|
if call.method.name == 'log_bytes':
|
|
self.container_log[0](f'LOG-BYTES: {repr(call.args[0].data)}')
|
|
return NoneValue
|
|
|
|
raise NotImplementedError(call)
|