Hi guys,
I am new to python , I am trying to read some data from CAD file using the below script , the script is works fine on Arcgis Pro 2.9.1 with no Errors But after publishing this to Arcgis server(10.9.1) as Geo-processing service and Submitting a job (post) the job fails and showing me the following :
my script :
# Import system modules
import arcpy
arcpy.env.workspace = arcpy.GetParameterAsText(0)
Request_ID = arcpy.GetParameterAsText(1)
print(arcpy.env.workspace)
# Step through each dataset in the list
for fd in arcpy.ListDatasets("*"):
layers = ["Polyline", "Polygon", "Point"]
for lyrGeom in layers:
print(lyrGeom)
CADlyr = fd + "_" + lyrGeom
CADSrs = fd + "/" + lyrGeom
print(CADlyr)
# Select the features on the drawing layer karar
arcpy.MakeFeatureLayer_management(CADSrs, CADlyr, "\"Layer\" = 'karar'")
with arcpy.da.SearchCursor(CADlyr,
["SHAPE@", "SHAPE@WKT", "OID@", "SHAPE@AREA", "SHAPE@LENGTH", "SHAPE@XY",
"Layer"]) as cursor:
for row in cursor:
print("Feature {}:".format(row[2]))
arcpy.AddMessage("Feature {}:".format(row[2]))
print("Value of Spatial Reference = {}".format(row[0].spatialReference.name))
sr = arcpy.SpatialReference(32637)
newG = row[0].projectAs(sr)
print (sr.name)
arcpy.SetParameterAsText(2, sr.name)
the problem at the "\"Layer\" = 'karar'" filter not accepted on runtime .
Reference of my code
any idea how to solve this ,
thanks for advance for your help,
Code formatting ... the Community Version - Esri Community
for line numbers etc
It sounds like you need to raw encode that line eg r"\some\path\some\file"
to ensure that the path is compliant with required specs.
Also don't mix "\" and "/" in paths as well
Thanks DanPatterson for your reply, I've tried to add r but also didn't work for me.
An EOL ( End of Line ) error indicates that the Python interpreter expected a particular character or set of characters to have occurred in a specific line of code, but that those characters were not found before the end of the line . This results in Python stopping the program execution and throwing a syntax error .
The SyntaxError: EOL while scanning string literal error in python occurs when while scanning a string of a program the python hit the end of the line due to the following reasons: