Rebuild indexes tool hanging in Python but not ArcCatalog

4834
2
Jump to solution
03-06-2015 08:21 AM
AmyRoust
Occasional Contributor III

I'm using a Python script to do routine geodatabase maintenance overnight. Everything has functioned normally until this week, when it started to hang on rebuilding indexes for datasets owned by the geodatabase owner. I know that the Python syntax is correct, the unique parameters are correct, the database connection file with the permissions to rebuild the relevant datasets are correct.

If I manually run the rebuild indexes tool on this database in ArcCatalog, it works. But if I run it in Python, the script never completes. I'm not sure how to troubleshoot this because I can't see the normal processing log that you see in the processing window in ArcCatalog.

I have two questions for the user community:

1. Has anyone had an issue with arcpy.RebuildIndexes_management failing in Python 2.7.5 and ArcGIS 10.2.2?

2. Does anyone know how I can capture the processing window comments in Python? Even a simple print statement would be fine - I don't need it to write to a log file.

Thanks in advance for your thoughts!

0 Kudos
1 Solution

Accepted Solutions
AmyRoust
Occasional Contributor III

OK, with the help of Esri tech support, we found the root of the problem. It wasn't really an incorrect workspace type, but an issue with how the list of database objects was being created. I was using arcpy.da.Walk and an os module to build the list of feature classes inside datasets, and something was off with my syntax, which resulted in an empty list. When the analyze and re-index tools got the blank list, they correctly said that the Parameters are not valid.

As a side note, I found another error reporting tool that proved useful in troubleshooting with arcpy.GetMessages() didn't give me enough to go on. If you import the traceback module, you can use the following in your Exception clause:

error = traceback.format_exc()

print error

del error

View solution in original post

0 Kudos
2 Replies
AmyRoust
Occasional Contributor III

Update:

I was able to answer question 2 by including the following print statement in my Except clause for my Try function

print arcpy.GetMessages()

The error message is telling me that my database connection file is not a valid workspace. (Note that per another GeoNet Discussion, I tried hard-coding the actual location of the connection file in the C drive instead of putting in "Database Connection \\ Production_owner.sde"):

Executing: AnalyzeDatasets C:\Users\gisadmin\AppData\Roaming\ESRI\Desktop10.2\ArcCatalog\Production_owner.sde NO_SYSTEM # ANALYZE_BASE ANALYZE_DELTA ANALYZE_ARCHIVE

Start Time: Wed Mar 11 14:57:57 2015

Failed to execute. Parameters are not valid.

ERROR 000837: The workspace is not the correct workspace type.

Failed to execute (AnalyzeDatasets).

0 Kudos
AmyRoust
Occasional Contributor III

OK, with the help of Esri tech support, we found the root of the problem. It wasn't really an incorrect workspace type, but an issue with how the list of database objects was being created. I was using arcpy.da.Walk and an os module to build the list of feature classes inside datasets, and something was off with my syntax, which resulted in an empty list. When the analyze and re-index tools got the blank list, they correctly said that the Parameters are not valid.

As a side note, I found another error reporting tool that proved useful in troubleshooting with arcpy.GetMessages() didn't give me enough to go on. If you import the traceback module, you can use the following in your Exception clause:

error = traceback.format_exc()

print error

del error

0 Kudos