11import sys
22import threading
3- from typing import List
43
5- import humps
64from nopdb import nopdb
75from vertx import EventBus
86
@@ -26,8 +24,8 @@ def __init__(self, eb: EventBus):
2624 LiveInstrumentRemote .dbg .start ()
2725 threading .settrace (sys .gettrace ())
2826
29- def add_live_instrument (self , instruments : List [ dict ] ):
30- for inst_dict in instruments :
27+ def add_live_instrument (self , command : LiveInstrumentCommand ):
28+ for inst_dict in command . instruments :
3129 instrument_type : LiveInstrumentType = LiveInstrumentType .from_string (inst_dict ["type" ])
3230 if instrument_type == LiveInstrumentType .BREAKPOINT :
3331 live_instrument = LiveBreakpoint .from_dict (inst_dict )
@@ -43,21 +41,15 @@ def add_live_instrument(self, instruments: List[dict]):
4341 if instrument_type == LiveInstrumentType .BREAKPOINT :
4442 bp .exec ("import sourceplusplus.control.ContextReceiver as ContextReceiver\n "
4543 "ContextReceiver.apply_breakpoint('" + live_instrument .id + "',globals(),locals())" )
46- body = humps .camelize (inst_dict )
47- body ["meta" ] = inst_dict ["meta" ]
48- self .eb .publish (address = "spp.processor.status.live-instrument-applied" , body = body )
44+ self .eb .publish (address = "spp.processor.status.live-instrument-applied" , body = live_instrument .to_dict ())
4945 elif instrument_type == LiveInstrumentType .LOG :
5046 bp .exec ("import sourceplusplus.control.ContextReceiver as ContextReceiver\n "
5147 "ContextReceiver.apply_log('" + live_instrument .id + "',globals(),locals())" )
52- body = humps .camelize (inst_dict )
53- body ["meta" ] = inst_dict ["meta" ]
54- self .eb .publish (address = "spp.processor.status.live-instrument-applied" , body = body )
48+ self .eb .publish (address = "spp.processor.status.live-instrument-applied" , body = live_instrument .to_dict ())
5549 else :
5650 bp .exec ("import sourceplusplus.control.ContextReceiver as ContextReceiver\n "
5751 "ContextReceiver.apply_meter('" + live_instrument .id + "',globals(),locals())" )
58- body = humps .camelize (inst_dict )
59- body ["meta" ] = inst_dict ["meta" ]
60- self .eb .publish (address = "spp.processor.status.live-instrument-applied" , body = body )
52+ self .eb .publish (address = "spp.processor.status.live-instrument-applied" , body = live_instrument .to_dict ())
6153
6254 def remove_live_instrument (self , command : LiveInstrumentCommand ):
6355 print ("Removing live instrument(s)" )
@@ -84,6 +76,6 @@ def remove_live_instrument(self, command: LiveInstrumentCommand):
8476 def handle_instrument_command (self , command : LiveInstrumentCommand ):
8577 print ("Received command: " + command .command_type )
8678 if command .command_type == CommandType .ADD_LIVE_INSTRUMENT :
87- self .add_live_instrument (command . instruments )
79+ self .add_live_instrument (command )
8880 elif command .command_type == CommandType .REMOVE_LIVE_INSTRUMENT :
8981 self .remove_live_instrument (command )
0 commit comments