Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-19 08:00:01

0001 """
0002 Command spec class: a panda poller will retrieve commands from panda server and store cache them internally
0003 """
0004 
0005 from .spec_base import SpecBase
0006 
0007 
0008 class CommandSpec(SpecBase):
0009     # attributes
0010     attributesWithTypes = ("command_id:integer primary key", "command:text", "receiver:text", "params:blob", "ack_requested:integer", "processed:integer")
0011     # commands
0012     COM_reportWorkerStats = "REPORT_WORKER_STATS"
0013     COM_setNWorkers = "SET_N_WORKERS_JOBTYPE"
0014     COM_killWorkers = "KILL_WORKERS"
0015     COM_syncWorkersKill = "SYNC_WORKERS_KILL"
0016 
0017     # mapping between command and receiver
0018     receiver_map = {COM_reportWorkerStats: "propagator", COM_setNWorkers: "submitter", COM_killWorkers: "sweeper", COM_syncWorkersKill: "sweeper"}
0019 
0020     # constructor
0021     def __init__(self):
0022         SpecBase.__init__(self)
0023 
0024     # convert from Command JSON
0025     def convert_command_json(self, data):
0026         # mandatory fields
0027         self.command_id = data["command_id"]
0028         self.command = data["command"]
0029         self.params = data["params"]
0030         self.ack_requested = data["ack_requested"]
0031         # For the day we want to parse the creation_date
0032         # from datetime import datetime
0033         # c = datetime.strptime(b, "%Y-%m-%dT%H:%M:%S.%f")
0034 
0035         # optional field
0036         try:
0037             self.processed = data["processed"]
0038         except KeyError:
0039             self.processed = 0