summaryrefslogtreecommitdiff
path: root/test/module/test.py
blob: a0b649383ba77cf2624424160b923014912fad2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import importlib.util
spec = importlib.util.spec_from_file_location("module.name", "../../rpc/__main__.py")
CortexRPC = importlib.util.module_from_spec(spec)
spec.loader.exec_module(CortexRPC)

if __name__ == '__main__':
  def get_params(key, value):
    print('get params.')
    return 'test'
  def set_param(key, value):
    print('log param. {}: {}'.format(key, value))
    return 'ok'
  def ready:
    return 'ready'
  def process_cmd(cmd, payload):
    print('process command', cmd, payload)
    return 'processed'

  # this will block
  rpc = CortexRPC(get_params, set_param, ready, process_cmd)