I wrote Python code that changes the state of a feature by ID. I am not using a Python Toolbox (.pyt). I wrote a python script and added it into a standard toolbox (.tbx). Using ArcGIS Desktop everything is OK. But when I published this code as geoprocessing service, it throws an exception.
What can I do?
Code:
import arcpy
import sys
"""The source code of the tool."""
copyFromLayer="Database ConnectionsSBGIS@connection.sdeuser.FeatureClass"
try:
arcpy.AddMessage("start working")
id=arcpy.GetParameterAsText(0)
state=arcpy.GetParameterAsText(1)
stateId=int(state)
count=0
cursor= arcpy.UpdateCursor(copyFromLayer)
arcpy.AddMessage("readed data")
for row in cursor:
if row.ID==id:
arcpy.AddMessage("find row")
row.STATEID=stateId
cursor.updateRow(row)
count=count+1
arcpy.AddMessage("ok")
arcpy.AddMessage("count of calculate rows = "+str(count))
arcpy.SetParameterAsText(0,"Result")
del cursor
except:
arcpy.AddError("error")
for er in arcpy.GetMessages():
arcpy.AddError(er)
Edit:
I wrote all steps one by one ,
- I created new toolbox and imported script that before I wrote,
- runed script on ArcMap and script runed very well ,
- I went to results panel and right click result and selected share as – Geoprocessing Service , after all published new service.
-
open service on web browser and filled input and executed job .
finally I got this messageesriJobMessageTypeInformative: Submitted. esriJobMessageTypeInformative: Executing... esriJobMessageTypeInformative: Executing (ParselStateChange): Script {A08A008E-0716-410A-A9E1-634DDD89B12D} 1 esriJobMessageTypeInformative: Start Time: Mon Feb 01 13:05:21 2016 esriJobMessageTypeInformative: Executing (Script): Script {A08A008E-0716-410A-A9E1-634DDD89B12D} 1 esriJobMessageTypeInformative: Start Time: Mon Feb 01 13:05:21 2016 esriJobMessageTypeInformative: Running script Script... esriJobMessageTypeInformative: start working esriJobMessageTypeError: error esriJobMessageTypeInformative: Completed script Script... esriJobMessageTypeError: Failed to execute (Script). esriJobMessageTypeInformative: Failed at Mon Feb 01 13:05:21 2016 (Elapsed Time: 0.00 seconds) esriJobMessageTypeError: Failed to execute (ParselStateChange). esriJobMessageTypeInformative: Failed at Mon Feb 01 13:05:21 2016 (Elapsed Time: 0.00 seconds) esriJobMessageTypeError: Failed.