# 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")
Justin, did you ever resolve what was going on with this? -W
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.
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...
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
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")