Help interpreting a traceback

I have half a dozen timre scripts running on my gateway. In the last week 2 copies of my project were made on the gateway. I needed to make some changes to the scripts, and noticed the changes not taking. I disabled the project copies and now the scripts have completely crashed. Just about every script is reporting the some version of the following error to my logs with cahnges to the line called out:

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "", line 23, in SyntaxError: ("no viable alternative at input 'json'", ('', 463, 20, '\treturn stateimport json\n'))

I don't know where to begin troubleshooting this guy. Below is the script reporting the above traceback. I've removed a bunch of comments, but the 1st line of the code corresponds to line 23 of the script.

values = system.tag.readBlocking(tagPathUtil.mcrTagPaths) #Retireve tag values. (line 23)

valList = []						#Create an empty list object
for i in range(len(values)):		#For each index of an object in the list:
	if values[i].value:				#	If the value of the object in the list is 1
		valList.append(1)			#		Append 1 to the end of the list
	else:							#	Else if the value of the object in the list is a 0
		valList.append(0)			#		Append 0 to the end of the list
valList.append(system.date.now())	#Add a timestamp to the end of the list
packet = str(valList)				#Convert the list to a string for transmission (requested by MCR)

if mcrUtil.needContext():					#Check if new context is needed
	for server in mcrUtil.serverList:		#For each server in the server list, try to retrieve a context value
		mcrUtil.context = mcrUtil.mcrGetContext(server = server, repTags = tagPathUtil.mcrErrTags)
		if mcrUtil.context.good:			#If the context request is successful (status code 200)
			mcrUtil.lastGoodServer = server	#Set the last good server variable to the server requested
			break							#Exit the FOR loop on the first success

if mcrUtil.context == None:					#If the context variable is undefined after context retrieval report
	message = "Set parameter script ended early due to bad context."
	system.util.getLogger('Infrastructure').info(message)
	#quit()				

device = 'sPhenixPlcMon'				#The name of the device in the MCR Device Server
parameter = 'transFromPlcS'				#The http parameter to be set within the Device Server
ppmuser = '0'
params = {								#The dictionary of values
	'name': device, 
	'prop': parameter, 
	'ppmuser': ppmuser, 
	'context': mcrUtil.context.text,	#The context value retrieved in Step 3
	'value': packet						#The data string created in Step 2
	}

mcrUtil.mcrPutRequest(params = params, repTags = tagPathUtil.mcrErrTags, server = mcrUtil.lastGoodServer)

Please help, some of the most critical aspects of my system are down.
-Lee

This code and the error don't seem to line up.

Call support?

Yeah, I had the feeling. Thanks.

The content of the parse error suggests that you've accidentally deleted the newline before the import json.

1 Like

I figured it out, and am quite embarrassed. At some point while making changes I managed to copy one of my gateway scripts, in its entirety, to the end of an unused function at the bottom one of my project library files. This included the import json statement.

The library was the source of the error which wasn't evident by the contents of the log's traceback. Thankfully the Gateway Scripts tab pointed to the issue more directly. Thanks for taking the time to help, and sorry for the inconvenience. I'll be more thorough next time.