0

I have created a script for converting feature classes to coverage and it runs fine in arcmap. But after publishing and running it on the server, it fails to execute and returns the following error message:

"Unable to complete operation. Error executing tool.: Traceback (most recent call last): File "", line 154, in execute File "c:\program files\arcgis\server\arcpy\arcpy\conversion.py", line 1576, in FeatureclassToCoverage raise e RuntimeError: Object: Error in executing tool Failed to execute (CoverageArcsNodes). Failed to execute (Select Coverage Features)."

import arcpy
import tempfile
class Toolbox(object):
def __init__(self): 
 self.label = "Toolbox"
 self.alias = ""
 self.tools = [CoverageArcsNodes]
class CoverageArcsNodes(object):
def __init__(self):
 self.label = "Select Coverage Features"
 self.description = ""
 self.canRunInBackground = True
def getParameterInfo(self):
 param0 = arcpy.Parameter(
 displayName="Input Line Feature Classes",
 name="in_lineFeatures",
 datatype="GPFeatureLayer",
 parameterType="Required",
 direction="Input",
 multiValue=True
 ) 
 # Second parameter
 param1 = arcpy.Parameter(
 displayName="Input Point Feature Classes",
 name="in_pointFeatures",
 datatype="GPFeatureLayer",
 parameterType="Required",
 direction="Input",
 multiValue=True
 )
 params = [param0, param1]
 return params
def execute(self, params, messages):
 arcpy.env.workspace="C:\\Users\\DeveloperA\\Desktop\\SEMNAN DB\\SemnanDB.SDE.gdb"
 coverageOutDir= "C:\\Users\\DeveloperA\\Desktop\\tempCoverage"
 #lines
 #lineValues= params[0].valueAsText.split(";")
 lineValues= params[0].values
 layerCnt=1 
 for fc in lineValues: 
 layerName="layer"+str(layerCnt)
 arcpy.AddField_management(fc,"featureClassName","TEXT") 
 arcpy.MakeFeatureLayer_management(fc,layerName)
 arcpy.SelectLayerByAttribute_management(layerName)
 arcpy.AddMessage("workspace="+arcpy.env.workspace) 
 layerCnt=layerCnt+1
 #points 
 pointValues= params[1].values 
 for fc in pointValues: 
 layerName="layer"+str(layerCnt)
 arcpy.AddField_management(fc,"featureClassName","TEXT") 
 arcpy.MakeFeatureLayer_management(fc,layerName)
 arcpy.SelectLayerByAttribute_management(layerName) 
 layerCnt=layerCnt+1 
 arcpy.CreateFeatureclass_management(arcpy.env.workspace, "points", "POINT",params[1].values[0])
 arcpy.AddField_management("points","featureClassName","TEXT") 
 arcpy.AddField_management("points","OriginalOBJECTID","TEXT")
 linesObjIdFldMap = arcpy.FieldMap()
 linesObjIdFldMap.addInputField(params[0].values[0],"OBJECTID")
 linesObjIdFldMap.outputField.name="OriginalOBJECTID" 
 linesFeatureClassFldMap = arcpy.FieldMap()
 linesFeatureClassFldMap.addInputField(params[0].values[0],"featureClassName")
 linesFeatureClassFldMap.outputField.name="featureClassName" 
 lineFieldMappings = arcpy.FieldMappings()
 lineFieldMappings.addFieldMap(linesObjIdFldMap)
 lineFieldMappings.addFieldMap(linesFeatureClassFldMap)
 pointsObjIdFldMap = arcpy.FieldMap()
 pointsObjIdFldMap.addInputField(params[1].values[0],"OBJECTID")
 pointsObjIdFldMap.outputField.name="OriginalOBJECTID" 
 pointsFeatureClassFldMap = arcpy.FieldMap()
 pointsFeatureClassFldMap.addInputField(params[1].values[0],"featureClassName")
 pointsFeatureClassFldMap.outputField.name="featureClassName" 
 pointFieldMappings = arcpy.FieldMappings()
 pointFieldMappings.addTable(params[1].values[0])
 pointFieldMappings.addFieldMap(pointsObjIdFldMap)
 pointFieldMappings.addFieldMap(pointsFeatureClassFldMap) 
 arcpy.Merge_management(params[0].values,"lines",lineFieldMappings)
 arcpy.Append_management(params[1].values,"points","NO_TEST",pointFieldMappings) 
 arcpy.FeatureclassToCoverage_conversion(in_features="'"+arcpy.env.workspace+"\\lines' ARC;'"+arcpy.env.workspace+"\\points' POINT;",out_cover=coverageOutDir) 
 arcpy.MakeFeatureLayer_management(coverageOutDir+"\\arc","lines_layer")
 arcpy.SelectLayerByAttribute_management("lines_layer") 
 return

I am a total newbie this sort of stuff and I am totally confused how to proceed.

P.S my guess is that I have messed up the workspaces and paths (dunno how), either that or arcgis server does not support the tool because when I comment out the line that calls the arcpy.FeatureclassToCoverage_conversion tool the script executes with no errors.

asked Feb 6, 2016 at 12:54
6
  • I suggest publishing a script tool instead of Python toolbox as a GP service Commented Feb 6, 2016 at 17:17
  • You have a couple of indentation issues (maybe from pasting, but worth checking) class Toolbox(object): and class CoverageArcsNodes(object): should have the following def block indented further Commented Feb 6, 2016 at 20:07
  • @Midavalo Thanks for the comment. It's because of pasting of course. As I said, it runs fine in ArcMap. Commented Feb 7, 2016 at 5:50
  • @AlexTereshenkov Thanks for the comment. Do you mean a python tool? Not sure if that would make any difference. Worth a try though. :) Commented Feb 7, 2016 at 5:53
  • @AlexTereshenkov I didn't see an essential difference in two approaches. pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/… Also I am going to edit my question. Commented Feb 7, 2016 at 6:07

1 Answer 1

1

I changed this line arcpy.FeatureclassToCoverage_conversion(in_features="'"+arcpy.env.workspace+"\\lines' ARC;'"+arcpy.env.workspace+"\\points' POINT;",out_cover=coverageOutDir) to this

arcpy.FeatureclassToCoverage_conversion(in_features="'lines' ARC; 'points' POINT;",out_cover=coverageOutDir) 

and it worked. :)

answered Feb 8, 2016 at 14:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.