ListFeatureClasses() fails since 10.2 upgrade

4365
5
12-12-2013 07:41 AM
deleted-user-zpcJw1u0IXiO
Occasional Contributor
Since upgrading to 10.2 the script I ran weekly for ArcSDE maintenance fails with an "Invalid floating point operation" error during the loop shown below:

# Get a list of all the datasets.
# First, get all the stand alone tables, feature classes and rasters.
dataList = arcpy.ListFeatureClasses() + arcpy.ListRasters()

# Next, for feature datasets get all of the featureclasses
# from the list and add them to the master list.
for dataset in arcpy.ListDatasets():
    print "Adding:", arcpy.ListFeatureClasses(feature_dataset=dataset)
    dataList += arcpy.ListFeatureClasses(feature_dataset=dataset)
# Execute the ReconcileVersions tool.
arcpy.ReconcileVersions_management(workspace,"ALL_VERSIONS","SDE.Default",verList,"NO_LOCK_ACQUIRED","NO_ABORT","BY_ATTRIBUTE","FAVOR_TARGET_VERSION","NO_POST","KEEP_VERSION")


I had inserted the print statement only for debugging purposes, and when I ran the script, the last few lines output by the statement were:

Adding: [u'bc.GIS_ADMIN.landuse_zoning']
Adding: [u'bc.GIS_ADMIN.dimensions', u'bc.GIS_ADMIN.dimension_2']
Adding: [u'bc.GIS_ADMIN.traffic_lights', u'bc.GIS_ADMIN.valves', u'bc.GIS_ADMIN.StormStructures', u'bc.GIS_ADMIN.signs', u'bc.GIS_ADMIN.sidewalks', u'bc.GIS_ADMIN.manholes', u'bc.GIS_ADMIN.light_standard', u'bc.GIS_ADMIN.hydro_pole', u'bc.GIS_ADMIN.hydrants', u'bc.GIS_ADMIN.decorative_light_standard', u'bc.GIS_ADMIN.curb_gutter', u'bc.GIS_ADMIN.culverts', u'bc.GIS_ADMIN.bridge']
Adding: []
Adding: []
Adding:

I'm puzzled as to why the loop prints two empty strings ([]) followed by nothing, just before raising the floating point error. All feature classes within feature datasets are successfully listed ahead of these empty ones in the print output. I suspect these blank lines might be the cause of the error, but I see lots of "Unknown function at" lines in the error details. I think it might be in the Reconcile where the error occurs.

Is there something I need to do to make this work, or in other words, enable 10.1 python code to run at 10.2?
Tags (2)
0 Kudos
5 Replies
Waan
by
Occasional Contributor

Justin, did you ever resolve what was going on with this? -W

0 Kudos
deleted-user-zpcJw1u0IXiO
Occasional Contributor

Hi Warren. I had posted another thread on this, and neglected to mention so on this one. My apologies for that. You can find the answered thread at ListFeatureClasses() or ListDatasets() fails since 10.2 upgrade‌, where you'll see it was an empty mosaic dataset that was found to be the troublemaker.

0 Kudos
Luke_Pinner
MVP Regular Contributor

Justin Kraemer wrote:

Hi Warren. I had posted another thread on this, and neglected to mention so on this one. My apologies for that. You can find the answered thread at ListFeatureClasses() or ListDatasets() fails since 10.2 upgrade, where you'll see it was an empty mosaic dataset that was found to be the troublemaker.

And this is why cross-posting is poor form...

0 Kudos
TimDine
Occasional Contributor II

Do you have any other datasets in your geodatabase that are not "Feature Datasets"?  Many types of things are in the high level group called Dataset.  I've tested the code on 10.2.1 and the last items that are displayed are "raster datasets" which if you change the code slightly to

print "Adding:", dataset, arcpy.ListFeatureClasses(feature_dataset=dataset)

you should be able to prove.  If you run ListFeatureClasses on a Raster Dataset there will be none and you'll get an empty list.

If you're getting an error is it possible yet another dataset type that is not in my test dataset does not fail quite so gracefully when you run ListFeatureClasses on it.

Try changing your ListDatasets line to be

for dataset in arcpy.ListDatasets("*", "Feature"):

ArcGIS Desktop ListDatasets

0 Kudos
XanderBakker
Esri Esteemed Contributor

Tim is right, you can have a raster dataset, in which you obviously won't find any featureclasses. You could try this:

import arcpy

# reference to you database
arcpy.env.workspace = r""

dataList = arcpy.ListTables()
dataList += arcpy.ListRasters()

fds = arcpy.ListDatasets(feature_type="Feature")
fds.append("")
for fd in fds:
    dataList += arcpy.ListFeatureClasses(feature_dataset=fd)

arcpy.ReconcileVersions_management(workspace,"ALL_VERSIONS","SDE.Default",verList,"NO_LOCK_ACQUIRED","NO_ABORT","BY_ATTRIBUTE","FAVOR_TARGET_VERSION","NO_POST","KEEP_VERSION")
0 Kudos