I am creating a webpage and want to use information from one view in another view. I'm generating javascript code via python but am having trouble with one of the strings I create causing a unexpected token illegal
syntax error.
I'm creating the string in python like this:
sep = max([len(k) for k in self.keys()])
infoString = "\n".join([("(%s)%s %s" % (k," "*(sep-len(k)),v)) for k,v in self.iteritems()])
GANTTBlock.setInfo("SIMPL-Task block representation:%s" % infoString)
Which ends up looking like this in js:
var SAT_2B = [
{label: "COMMRequest", times: [{"color":"Red", "label":"Task ID: 1", "starting_time":1420228800000, "ending_time":1420257600000, "TASKID":"1", "TASKCLASS":"COMM", "info":"SIMPL-Task block representation:(SCI_STORED_RAW) 0
(SEQUENCE_OVERRIDE)
(REQ_FILENAME) /Users/kerrywahl/Desktop/PlanningPersonelInterface/SIMPLCode/Input/Test/CYGNSS_MOC_COMM_Req_2015_001.txt
(RETRANSMIT)
(SCI_STORED_DDM) 0
(NOTES) Auto Generated NOMINAL COMM Request<req TASK_ID:1>
(ENG_STORED_NOM) 0
(IS_SIMPL_TASK) True
(RATE) HIGH_RATE
(DURATION) 500.0
(WINDOW_END) 2015-01-03 04:00:00.000000
(WINDOW_START) 2015-01-02 20:00:00.000000
(TASK_ID) 1
(TaskClass) COMM
(PASS_SETUP) AUTO
(PRIORITY) 5
(TASK_NAME) SAT_2B_COMM_NOMINAL_1_req
(PHASE) REQUEST
(ENG_STORED_DIAG) 0
(TYPE) NOMINAL
(SAT) 2B"}, {"color":"Red", "label":"Task ID: 6", "starting_time":1421092800000, "ending_time":1421121600000, "TASKID":"6", "TASKCLASS":"COMM", "info":"SIMPL-Task block representation:(SCI_STORED_RAW) 0
(SEQUENCE_OVERRIDE)
(REQ_FILENAME) /Users/kerrywahl/Desktop/PlanningPersonelInterface/SIMPLCode/Input/Test/CYGNSS_MOC_COMM_Req_2015_001.txt
(RETRANSMIT)
(SCI_STORED_DDM) 0
(NOTES) Auto Generated NOMINAL COMM Request<req TASK_ID:6>
(ENG_STORED_NOM) 0
(IS_SIMPL_TASK) True
(RATE) HIGH_RATE
(DURATION) 500.0
(WINDOW_END) 2015-01-13 04:00:00.000000
(WINDOW_START) 2015-01-12 20:00:00.000000
(TASK_ID) 6
(TaskClass) COMM
(PASS_SETUP) AUTO
(PRIORITY) 5
(TASK_NAME) SAT_2B_COMM_NOMINAL_6_req
(PHASE) REQUEST
(ENG_STORED_DIAG) 0
(TYPE) NOMINAL
(SAT) 2B"}]},
{label: "COMMPlan", times: []},
{label: "COMMOperation", times: []},
];
Based on the console, the error is occurring on the first line ({label: "COMMRequest", times: [{"color"...
). I tried changing the info
part of the string (everything that comes after "info":
) to just a regular "foo" string and then it worked fine. I tried removing the \n
but still got the error. I can't figure out what is causing the problem.
EDIT
It works fine if I only have one {}
inside the times:
part of the label, but breaks on the "TASKID"
part of the second {}
.