UpdateCursor in ArcGIS Geoprocessing service not working!

1367
2
09-07-2020 02:35 AM
AlexanderWinz1
New Contributor

Dear community,

I am working right now on one ExtractData Script for ArcGIS Server. I actually uses the "ExtractData" Tool form the server Tools.

Meanwhile this script create a zipfolder and within this zipfolder an geodatabase (in%Srcatch% of AGS). Now I try to Add a new Field to the FeatureClass to recalculate the subtypes of the fc. This works fine. When I try to use a update.cursor it works fine on my desktop, but as soon i publish it. I get an ERROR:

ARCGIS Server Manager:

Error executing tool. Model2 Job ID: jfcb1e7ba32e7428081ca616dbb174c06 : 1 Failed to execute (SubtypeExport). Failed to execute (Model2). Failed to execute (200820_SubtypeExport).

When I comment the UpdateCursor, my script works fine!

Line

def releaseDomains(output_gdb, output_feature_class_name):

arcpy.env.workspace = output_gdb
# Process: Add Field
arcpy.AddField_management(output_feature_class_name, "Oberkategorie_O", "TEXT", 9, "", "100", "Oberkategorie", "NULLABLE", "REQUIRED")
desc_lu = {}
domains = {}
for (key, value) in arcpy.da.ListSubtypes(output_feature_class_name).iteritems():
    desc_lu[key] = value['Name']

dropFields = ("Hauptkategorie_ST") #, "Biotopcodes_Unterkategorie")
subtypes = []
for h in desc_lu:
   subtypes.append(h)

for subt in subtypes:

try:
with arcpy.da.UpdateCursor(output_feature_class_name,("Hauptkategorie_ST", 
"Oberkategorie_O")) as cursor:
   for row in cursor:
      row[1] = (desc_lu[row[0]])
      cursor.updateRow(row)
except:

arcpy.ClearWorkspaceCache_management()

# Delete the old fields


arcpy.RemoveSubtype_management (output_feature_class_name, subtypes)
arcpy.DeleteField_management(output_feature_class_name, dropFields)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Any idea? I stuck since 2 weeks on this stup....problem.

Thanks,

Alex

( I attached the whole script)

0 Kudos
2 Replies
DavidPike
MVP Frequent Contributor

I'm guessing the indentation is just messed up from a copy/paste?

Is this published with full messaging enabled, and is this the error from running it on desktop aas a service, or on AGOL?

Maybe the feature is locked out and/or needs to be edit mode for the cursor operation, or you could try without the with statement and delete the cursor after?

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Without knowing the specific error causing the script to fail, it is difficult to guess what might be happening.  As David points out, you need more messages from the script.  Also, remove the try/except so that you can pass along the actual error.  Right now, you are hiding the same error message you need to debug.

0 Kudos