# 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")
Solved! Go to Solution.
Hi Justin,
Is the dataList used in a later part of your script? The ReconcileVersions tool does not use this list. It will use a list of versions that you have set to the variable 'verList'. If the dataList is not used in a later part of you script, you can comment it out and you should be able to reconcile all of your versions successfully.
# -*- coding: utf-8 -*- # --------------------------------------------------------------------------- # sde_maint.py # Created on: 2012-10-22 13:54:03.00000 # (generated by Justin) # Usage: # Description: runs Analyze, Compress, and Analyze on the specified # ArcSDE geodatabase # --------------------------------------------------------------------------- # Set the necessary product code #import arceditor #debugOn = True # Import arcpy module import arcpy, os, datetime, time, SynchronizeReplica from time import localtime, strftime # Script arguments ##Log_file = arcpy.GetParameterAsText(0) ##if Log_file == '#' or not Log_file: ## Log_file = "G:\\Administration\\Reconcile logs\\test5.log" # provide a default value if unspecified startTime = datetime.datetime.now() print startTime.strftime("%Y-%m-%d %H:%M:%S") debugOn = arcpy.GetParameter(1) if debugOn == '#' or not debugOn or (debugOn != 'y'): debugOn = bool(False) print 'Full SDE geodatabase maintenance begins...' else: debugOn = bool(True) print 'Debug mode is enabled. Partial SDE geodatabase maintenance begins...' gdb = arcpy.GetParameterAsText(0) if gdb == '#' or not gdb or (gdb != 'bc' and gdb != 'bc_dev' and gdb != 'bcwa'): gdb = 'bc_dev' # set the workspace #arcpy.env.workspace = 'Database Connections\\gis_admin@bc@winston.sde' if gdb != 'bcwa': arcpy.env.workspace = 'Database Connections\\sde@' + gdb + '@winston.sde' else: arcpy.env.workspace = 'Database Connections\\sde@' + gdb + '@WA-IO-TIMMY.sde' # set a variable for the workspace workspace = arcpy.env.workspace #admin_workspace = 'Database Connections\\sde@bc@winston.sde' # set up logfile parameters stateTableList = arcpy.ListTables("*statecount*") lineageTableList = arcpy.ListTables("*StateLineage*") logfilePath = 'C:\\Users\\kraemerj\\AppData\\Roaming\\ESRI\\Desktop10.1\\ArcToolbox\\My Toolboxes\\' logfile = logfilePath + gdb + '_compress_history.csv' if os.path.isfile(logfile): writeHeader = False else: writeHeader = True #if not debugOn: with open(logfile,'a') as f: if writeHeader: #Insert column headings f.write("DateTime,Status,StateCount,LineageCount\n") stateTableList = arcpy.ListTables("*statecount*") dateTime = time.strftime("%d %b %Y %H:%M:%S", localtime()) # Insert the date and time, and the compress status f.write(dateTime + ",pre,") for table in stateTableList: tabcur = arcpy.SearchCursor(workspace + os.sep + table) for t_row in tabcur: cntStates = t_row.getValue("StateCount") f.write(str(cntStates) + ",") lineageTableList = arcpy.ListTables("*StateLineage*") if len(lineageTableList) > 0: for table in lineageTableList: tabcur = arcpy.SearchCursor(workspace + os.sep + table) for t_row in tabcur: cntLineages = t_row.getValue("LineageCount") f.write(str(cntLineages) + "\n") del table else: f.write(str(0) + "\n") # this doesn't get written for whatever reason #block new connections to the database. arcpy.AcceptConnections(workspace, False) print 'Connections to ' + gdb + ' are now being blocked.' if not debugOn: #disconnect all users from the database. arcpy.DisconnectUser(workspace, "ALL") print 'Users have been disconnected.' now = datetime.datetime.now() print now.strftime("%Y-%m-%d %H:%M:%S"), "Finding versions and reconciling them..." # Process: Reconcile Versions # Get a list of versions to pass into the ReconcileVersions tool. Use a list comprehension to get a list of version names and make sure sde.default is not selected verList = arcpy.ListVersions(workspace) #for ver in verList: # print "Version:", ver # 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_OBJECT","FAVOR_TARGET_VERSION","NO_POST","KEEP_VERSION") arcpy.ReconcileVersions_management(workspace,"ALL_VERSIONS","SDE.Default",verList,"NO_LOCK_ACQUIRED","NO_ABORT","BY_ATTRIBUTE","FAVOR_TARGET_VERSION","NO_POST","KEEP_VERSION") now = datetime.datetime.now() print now.strftime("%Y-%m-%d %H:%M:%S"), "Reconcile complete for all",len(verList), "versions. Now synchronizing replicas..." replicaName = "GIS_ADMIN.BndFCs1way" now = datetime.datetime.now() print "Synchronizing 1-way replica " + replicaName + "..." SynchronizeReplica.SyncReplica(replicaName) replicaName = "GIS_ADMIN.BCmaintained2way" now = datetime.datetime.now() print now.strftime("%Y-%m-%d %H:%M:%S"), "1-way synchronization complete. Synchronizing 2-way replica " + replicaName + "..." SynchronizeReplica.SyncReplica(replicaName) now = datetime.datetime.now() print now.strftime("%Y-%m-%d %H:%M:%S"), "2-way synchronization complete. Now analyzing..." # RebuildIndexes was here pre-UC # Process: Analyze gdb arcpy.AnalyzeDatasets_management(workspace, "SYSTEM", dataList, "ANALYZE_BASE", "ANALYZE_DELTA", "ANALYZE_ARCHIVE") print "Analysis complete." # Process: Compress bc # Run the compress tool. if not debugOn: now = datetime.datetime.now() print now.strftime("%Y-%m-%d %H:%M:%S"), "Compressing..." arcpy.Compress_management(workspace) now = datetime.datetime.now() print now.strftime("%Y-%m-%d %H:%M:%S"), "Compression complete." # Update the logfile post-compress with open(logfile,'a') as f: dateTime = time.strftime("%d %b %Y %H:%M:%S", localtime()) # Insert the datetime and the compress status f.write(dateTime + ",post,") for table in stateTableList: tabcur = arcpy.SearchCursor(workspace + os.sep + table) for t_row in tabcur: cntStates = t_row.getValue("StateCount") f.write(str(cntStates) + ",") if len(lineageTableList) > 0: for table in lineageTableList: tabcur = arcpy.SearchCursor(workspace + os.sep + table) for t_row in tabcur: cntLineages = t_row.getValue("LineageCount") f.write(str(cntLineages) + "\n") del table else: f.write(str(0) + "\n") #this doesn't get written for whatever reason # pass in the list of datasets to the rebuild indexes and analyze datasets tools # Note: to use the "SYSTEM" option the user must be an administrator. print now.strftime("%Y-%m-%d %H:%M:%S"), "Re-indexing..." arcpy.RebuildIndexes_management(workspace, "SYSTEM", "", "ALL") print now.strftime("%Y-%m-%d %H:%M:%S"), "Indexes rebuilt." #Allow the database to begin accepting connections again if gdb != 'bcwa': arcpy.AcceptConnections('Database Connections\\sde@' + gdb + '@winston.sde', True) else: arcpy.AcceptConnections('Database Connections\\sde@' + gdb + '@WA-IO-TIMMY.sde', True) #now = datetime.datetime.now() print 'Connections to ' + gdb + ' are being accepted once again.' # Process: Re-analyze bc now = datetime.datetime.now() print now.strftime("%Y-%m-%d %H:%M:%S"), "Re-analyzing..." arcpy.AnalyzeDatasets_management(workspace, "SYSTEM", dataList, "ANALYZE_BASE", "ANALYZE_DELTA", "ANALYZE_ARCHIVE") now = datetime.datetime.now() print now.strftime("%Y-%m-%d %H:%M:%S"), "Maintenance complete!" elapsedTime = now - startTime seconds = elapsedTime.seconds minutes, seconds = divmod(seconds, 60) hours, minutes = divmod(minutes, 60) days, hours = divmod(hours, 24) if minutes == 1: print "Elapsed time:", "%d hours, %d minute, %d seconds" % (hours, minutes, seconds) else: print "Elapsed time:", "%d hours, %d minutes, %d seconds" % (hours, minutes, seconds)
arcpy.AnalyzeDatasets_management(workspace, "SYSTEM", dataList, "ANALYZE_BASE", "ANALYZE_DELTA", "ANALYZE_ARCHIVE")
Uncomment the lines defining this variable and re-run the script and see if you receive a new error message.
retval = convertArcObjectToPythonObject(gp.ReconcileVersions_management(*gp_fixargs((input_database, reconcile_mode, target_version, edit_versions, acquire_locks, abort_if_conflicts, conflict_definition, conflict_resolution, with_post, with_delete, out_log), True)))