AnsweredAssumed Answered

Bad file descriptor error when Updating attributes

Question asked by ionarawilson on Jul 8, 2013
Latest reply on Jul 9, 2013 by ionarawilson
The user digitizes a polygon and with the record selected it adds attributes to the record with a toolbox. The script works well without the 5th parameter (PlanEQIP) but I get a strange error message when I have this parameter. Does anybody know what the problem would be? Would it be because the field is short integer but the parameter data type is set to long?

Thanks!

Here is part of the code:
################################################## # #Script:  Attribute Table for reporting (Stewardship) #  ##################################################  #Import modules import os, sys, arcpy, traceback, arcgisscripting  #Set Map Document mxd = arcpy.mapping.MapDocument("Current")  #Set Overwrite Option arcpy.env.overwriteOutput = True   df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]  gp = arcgisscripting.create(10.1) #del row #del rows try: #Sets parameters (attributes)     Status = gp.GetParameterAsText(0)     Office =  gp.GetParameterAsText(1)     Forester = gp.GetParameterAsText(2)     DateStart = gp.GetParameterAsText(3)     PlanEQIP = gp.GetParameter(4)      StatusDomain = {'Completed': 'C', 'Pending': 'P'}     StatusCode = StatusDomain[Status]      officeDomain = {'Alpine': 'AL', 'Austin': 'AU', 'Carthage': 'CA', 'Corpus Christi': 'CC', 'Conroe': 'CO', 'Crockett': 'CR',                       'Crockett':'CR', 'College Station': 'CS', 'Canyon': 'CY', 'Dallas': 'DA', 'El Paso': 'EP', 'Fort Worth': 'FW',                       'Gilmer': 'GI', 'Granbury': 'GR', 'Hamilton': 'HA', 'Henderson': 'HE'}     officeCode= officeDomain[Office]     foresterDomain = {'Brittany Compton': 'bcompton', 'Brian Pope': 'bpope', 'Buster Robinson': 'brobinson',                         'Clay Bales': 'cbales', 'Daniel Duncum': 'dduncum', 'Daniel Lewis': 'dlewis'}     foresterCode = foresterDomain[Forester]   #Create Update Cursor     #Create Update Cursor    #This pre with arcpy.da prevents data locks. Another way of doing is (but it does not prevent data locks)  ##    rows = arcpy.UpdateCursor("Stewardship") ##    for row in rows: ##        row.Office = officeCode ##        row.Forester = foresterCode ##        rows.updateRow(row)       with arcpy.da.UpdateCursor("Stewardship", ("Status", "Office", "Forester", "DateStart", "PlanEQIP")) as rows:         # row comes back as a tuple in the order specified here, so Office is row[0], Forester is row[1]         for row in rows:             row[0] = StatusCode             row[1] = officeCode             row[2] = foresterCode             row[3] = DateStart             row[4] = PlanEQIP             rows.updateRow(row) 


And here is the error

Executing: Stewardship32 Completed Carthage "Brian Pope" "7/8/2013 10:40:49 AM" 17 Start Time: Mon Jul 08 10:40:54 2013 Running script Stewardship32... updateParameters Execution Error: Runtime error  Traceback (most recent call last):   File "D:\ArcGISData\SARS\Python_10April2013\SARS.tbx#Stewardship32.UpdateParameters.py", line 3, in <module>   File "D:\ArcGISData\SARS\Python_10April2013\SARS.tbx#Stewardship32.UpdateParameters.py", line 10, in __init__ IOError: [Errno 9] Bad file descriptor  Failed to execute (Stewardship32). Failed at Mon Jul 08 10:40:54 2013 (Elapsed Time: 0.00 seconds)

Outcomes