AnsweredAssumed Answered

Geoprocessing Python Scripts: How to work with directories and scratch?

Question asked by cprgeoadmin on Dec 1, 2013
Latest reply on Dec 2, 2013 by cprgeoadmin
I'm having some frustrating times with a GP script I'm trying to publish to my Ubuntu ArcGIS Server 10.2 machine.

The script works perfectly locally and publishes just fine, but when trying to use it in ArcGIS Desktop, it throws an immediate error:

Error executing tool.:  Traceback (most recent call last):   File "Z:\net\SITEHOST\gisdata\arcgisserver\directories\arcgissystem\arcgisinput\autoTransectFour.GPServer\extracted\v101\rq\atw.py", line 69, in <module>     arcpy.AddMessage(str(arcpy.Describe(g_ESRI_variable_2).extent) + " of the waterbodyBuffer")   File "Z:\arcgis\server\arcpy\arcpy\__init__.py", line 1234, in Describe     return gp.describe(value)   File "Z:\arcgis\server\arcpy\arcpy\geoprocessing\_base.py", line 374, in describe     self._gp.Describe(*gp_fixargs(args, True))) IOError: "%scratchFolder%\waterbodyBuffer" does not exist



I'm not including the whole script as it doesn't get far and the error seems to do with how I manage workspaces.

Imports import arcpy import gc import csv from arcpy import env from math import radians, tan, cos, fabs  ### INPUTS / OUTPUTS ### waterbodyPoly = arcpy.GetParameterAsText(0) transSpacing = float(arcpy.GetParameterAsText(1)) shorelineBuffer = float(arcpy.GetParameterAsText(2))   outTransect = arcpy.GetParameterAsText(3) outPoints = arcpy.GetParameterAsText(4) angleType = arcpy.GetParameterAsText(5) pathLines = arcpy.GetParameterAsText(6)  #arcpy.env.workspace = ws   ### VARIABLES ### kfPerimeter = shorelineBuffer - (transSpacing / 2) sRef = arcpy.Describe(waterbodyPoly).spatialReference  # Get start point from geometry boatStartPoint = arcpy.Point()  # Create Empty FCs arcpy.CreateFeatureclass_management(arcpy.env.scratchWorkspace, pathLines, "POLYLINE", spatial_reference = sRef) arcpy.AddMessage(str(arcpy.Describe(waterbodyPoly).extent) + " of the waterbodyPoly")  # Buffer Waterbody inwards by shorelineBuffer arcpy.Buffer_analysis(waterbodyPoly,"waterbodyBuffer",0.0 - shorelineBuffer) arcpy.AddMessage(str(arcpy.Describe("waterbodyBuffer").extent) + " of the waterbodyBuffer")  # 


There's a lot of bits and pieces in the ArcGIS help pages online for these things, but there's nothing I've found that very explicitly discusses how to structure and publish PYTHON scripts.

Links to better documentation or some pointers/tips/suggestions would be greatly appreciated!

Outcomes