I have a script that runs fine in ArcMap and when published to ArcGIS Server:
- it runs fine when using folder workspace i.e GDB database.
- fails when using ArcSDE workspace to connect to a RDBMS.
This is my script. The problematic line is indicated by a comment.
arcpy.env.overwriteOutput=True
arcpy.env.workspace= params[3].valueAsText
coverageDirName="tempCoverage"
coverageOutDir=tempfile.gettempdir()+"\\"+coverageDirName
arcpy.CreateFeatureclass_management(params[3].valueAsText, "points", "POINT")
arcpy.AddField_management("points","featureClassName","TEXT")
arcpy.AddField_management("points","OriginalOBJECTID","Integer")
linesObjIdFldMap = arcpy.FieldMap()
for fc in params[0].values:
linesObjIdFldMap.addInputField(fc,"OBJECTID")
linesObjectId=linesObjIdFldMap.outputField
linesObjectId.name="OriginalOBJECTID"
linesObjectId.type="Integer"
linesObjIdFldMap.outputField =linesObjectId
linesFeatureClassFldMap = arcpy.FieldMap()
linesFeatureClassFldMap.addInputField(params[0].values[0],"featureClassName")
linesFeatureClassName=linesFeatureClassFldMap.outputField
linesFeatureClassName.name="featureClassName"
linesFeatureClassFldMap.outputField =linesFeatureClassName
lineFieldMappings = arcpy.FieldMappings()
lineFieldMappings.addFieldMap(linesObjIdFldMap)
lineFieldMappings.addFieldMap(linesFeatureClassFldMap)
pointsObjIdFldMap = arcpy.FieldMap()
for fc in params[1].values:
pointsObjIdFldMap.addInputField((fc),"OBJECTID")
pointsObjectId=pointsObjIdFldMap.outputField
pointsObjectId.name="OriginalOBJECTID"
pointsObjectId.type="Integer"
pointsObjIdFldMap.outputField =pointsObjectId
pointsFeatureClassFldMap = arcpy.FieldMap()
pointsFeatureClassFldMap.addInputField(params[0].values[0],"featureClassName")
pointsFeatureClassName=pointsFeatureClassFldMap.outputField
pointsFeatureClassName.name="featureClassName"
pointsFeatureClassFldMap.outputField =pointsFeatureClassName
pointFieldMappings = arcpy.FieldMappings()
pointFieldMappings.addFieldMap(pointsFeatureClassFldMap)
pointFieldMappings.addFieldMap(pointsObjIdFldMap)
arcpy.Merge_management(params[0].values,"lines",lineFieldMappings)
arcpy.Append_management(params[1].values,"points","NO_TEST",pointFieldMappings)
inputFeatures="'{0}\\lines' ARC; '{0}\\points' POINT;".format(arcpy.env.workspace)
arcpy.FeatureclassToCoverage_conversion(in_features=inputFeatures,out_cover=coverageOutDir)
#arcpy.env.workspace=params[3].valueAsText
arcpy.FeatureClassToGeodatabase_conversion([coverageOutDir+"\\arc",coverageOutDir+"\\node"],params[3].valueAsText)
# this line throws error
result=arcpy.MakeFeatureLayer_management(in_features="tempCoverage_node", out_layer="nodes_lyr")
arcpy.SetParameter(4,result.getOutput(0))
result=arcpy.MakeFeatureLayer_management(in_features="tempCoverage_arc", out_layer="arcs_lyr")
arcpy.SetParameter(2,result.getOutput(0))
The environment is ArcGis Server 10.2.2 connecting to remote sde database.
The input workspace is set to the sde connection file located in the root drive (c:\data) with its permissions set to allow full control by ArcGis Server account.
I have tried forward slashes, double backslashes and concatenating the path for the in_features parameter instead of relying on the workspace variable, to no avail