Does anyone have any examples of script tools used in an ArcGIS server geoprocessing service? I guess they have to be written differently to script tools in the desktop environment but can't find any documentation on them
import sys
import os
import traceback
import inspect
import arcgisscripting
class ErrorHandling(object):
def trace(self):
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
# script name + line number
line = tbinfo.split(", ")[1]
filename = inspect.getfile( inspect.currentframe() )
# Get Python syntax error
#
synerror = traceback.format_exc().splitlines()[-1]
return line, filename, synerror
if __name__ == '__main__':
try:
gp = arcgisscripting.create(9.3)
gp.overwriteoutput = 1
#
#!!!!! place python logic here !!!!!
#
except arcgisscripting.ExecuteError:
# Return GEOPROCESSING specific errors #
EH = ErrorHandling()
line, filename, err = EH.trace()
gp.adderror("Geoprocessing error on " + line + " of " + filename + " :")
for msg in range(0, gp.MessageCount):
if gp.GetSeverity(msg) == 2:
gp.AddReturnMessage(msg)
gp.AddError(gp.GetMessages(2))
except:
# Return any PYTHON or system specific errors #
EH = ErrorHandling()
line, filename, err = EH.trace()
gp.AddError("Python error on " + line + " of " + filename + " : with error - " + err)
finally:
del gp
import sys, string, os, arcgisscripting gp = arcgisscripting.create(9.3) gp.overwriteoutput = 1 # Script parameters Method = gp.GetParameterAsText(0) Binomial = gp.GetParameterAsText(1) Known_Location_Points = gp.GetParameter(2) Inferred_Species_Range = gp.GetParameter(3) Hydroshed_Layer = "Hydrosheds_Taiwan"