Python error when using the describe function

1492
2
07-19-2013 09:54 AM
EhrenHill
New Contributor
I'm getting the following error when I run my Python script tool on Personal and File Geodatabases that have more than one feature class in them on a 10.0 machine.  I tried debugging it today, but I am at a loss on what the issue could be. 

The error comes after this line right after the first else statement:   desc = arcpy.Describe(fc)
Any thoughts or suggestions would be great.  Thanks in advance.

Traceback (most recent call last):
  File "C:\test\Ehren\scripts\fieldList.py", line 138, in <module>
    desc = arcpy.Describe(fc)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 846, in Describe
    return gp.describe(*args)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 372, in describe
    self._gp.Describe(*gp_fixargs(args)))
RuntimeError: ERROR 999999: Error executing function.
ERROR 999999: Error executing function.

Here is the section of code causing the issue (I've also attached the entire python file):
#Checks for feature classes in personal geodatabases
            for workspace in workspaceList:
                #set environmental workspace to personal geodatabase
                arcpy.env.workspace = workspace
                for fc in arcpy.ListFeatureClasses():
                    ##try:
                    print "     Processing File: " + os.path.join(workspace, fc)
                    arcpy.AddMessage("     Processing File: " + os.path.join(workspace, fc))

                    #Setup variables for textToWriteList and check for valid metadata values
                    if arcpy.Describe(workspace).dataType == "Coverage" or arcpy.Describe(workspace).dataType == "CadDrawingDataset":
                        desc = arcpy.Describe(workspace + "/" + fc)
                    else:
                        desc = arcpy.Describe(fc)
                    fcPath = os.path.join(dir, subFolderName, workspace)
                    fcDataType = desc.dataType
                    fcShapeType = desc.shapeType
                    if arcpy.Describe(workspace).dataType == "Coverage" or arcpy.Describe(workspace).dataType == "CadDrawingDataset":
                        fcFeatureCount = str(arcpy.GetCount_management(workspace + "/" + fc))
                        fieldList = arcpy.ListFields(workspace + "/" + fc)
                    else:
                        fcFeatureCount = str(arcpy.GetCount_management(fc))
                        fieldList = arcpy.ListFields(fc)

                    fieldList = arcpy.ListFields(fc)
                    for field in fieldList:
                        fcFieldName = field.name
                        fcFieldType = field.type
                        fcFieldLength = field.length

                        #Create list to hold text values for writing to Excel                    
                        textToWriteList = [excelRow, fc, fcPath, fcDataType, fcShapeType, fcFeatureCount, fcFieldName, fcFieldType, fcFieldLength]
                        
                        #Start writing information on fc and fields to Excel
                        column = 0
                        for text in textToWriteList:                    
                            row = ws.row(excelRow)
                            if len(str(text)) > 32760:
                                text = "Value has too many characters to write"
                                row.write(column, text)
                                column = column + 1
                            else:
                                row.write(column, text)
                                column = column + 1
                
                        #Increment row counter by 1
                        excelRow = excelRow + 1
                        #set workspace back to original environmental workspace
                        arcpy.env.workspace = os.path.join(dir, subFolderName)
 
Tags (2)
0 Kudos
2 Replies
MathewCoyle
Frequent Contributor
What does your print message before that say you are processing?
                    print "     Processing File: " + os.path.join(workspace, fc)
                    arcpy.AddMessage("     Processing File: " + os.path.join(workspace, fc))


Is it always on the second loop or does it vary?
0 Kudos
EhrenHill
New Contributor
I think the figured out what the issue was.  Once I removed the line of code below, the describe function worked fine.  I think the line below was indented one tab too much and was resetting the workspace inside the loop.  I'm not sure why that line was in there anyway at this point, I think it had something to do with looping through a series of personal geodatabases.

#set workspace back to original environmental workspace
arcpy.env.workspace = os.path.join(dir, subFolderName)
0 Kudos