Select to view content in your preferred language

Unterminated string literal while running GP service

90
7
yesterday
wizgis
by
Frequent Contributor

Hi Community, 

We have a python script tool that runs successfully in ArcGIS Pro and we have published it to ArcGIS Enterprise successfully as a WebTool. 

On running the tool from REST endpoint we are getting the error of "Unterminated string literal". 

Attached is the screenshot.

Error_GP_1.png

Attaching snippet of script for reference.

Snippet_Script.png 

Any inputs on this would be appreciated.

0 Kudos
7 Replies
JoshuaBixby
MVP Esteemed Contributor

If you look at the error message, it is clear the line 74 in the error message is not the line 74 in the code snippet you posted.  Are you showing the code snippet from the Python file on ArcGIS Server or what you ran on Pro? 

wizgis
by
Frequent Contributor

@JoshuaBixby the code snippet is from Python file on Pro

0 Kudos
ModyBuchbinder
Esri Regular Contributor

The publish process change the script. You can find the published script under C:\arcgisserver\directories\arcgissystem\arcgisinput (after the changes)

Sometime the publishing process add some single quote somewhere (I have no idea why).

It is not supported to change the published script directly but if you go there, find the extra quote and delete it you should get it up and running.

Have fun

 

wizgis
by
Frequent Contributor

@ModyBuchbinder If i go to the path mentioned in the screenshot I don't see the python just a toolbox 

0 Kudos
wizgis
by
Frequent Contributor

@ModyBuchbinder & @JoshuaBixby 

As suggested, in ArcGIS Pro (ArcGIS Server & Pro are on the same machine) I went to the path mentioned in the screenshot and was able to add the toolbox in the catalog window.

I expanded the toolbox > right clicked on the script too > Edit and was able to remove the extra quotes however, now am getting the following error: 

Error_GP_new.png

 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

The call to Append is pretty straightforward, nothing obvious like a missing comma.  Two ideas come to mind:  1) the field_map object is somehow messed up and not being processed correctly, and 2) maybe it doesn't like the 2 optional arguments by position, so you could try them as named arguments.

0 Kudos
ModyBuchbinder
Esri Regular Contributor

Hi all

You used python toolbox where the python code is embedded into the toolbox.

I use simple toolbox where the tool is pointing (by reference) to the script (py separate file).

Then when you publish you get the same structure where you have a py file with the script.

It is easier to handle and you can use IDLE like pycharm that really help you get your code right.

Move to simple  py file mean only to copy the execute function into a different file and define new toolbox.

You might deleted something by mistake while editing the toolbox.

Sometime when there is a strange error the problem is really in one of the previous lines.

0 Kudos