Select to view content in your preferred language

Getting internal tool messages in a script

215
1
3 weeks ago
ModyBuchbinder
Esri Regular Contributor

I have a script that uses gp tools that takes a long time.

The tool I am using is Build Overviews that can take long time but have many messages that showing the progress.

When I run this tool within python script, I do not see these messages.

I can only AddMessage before and after the tool.

Is there any way to send the message to the display even if it runs inside a script.

Thanks

0 Kudos
1 Reply
TonyAlmeida
MVP Regular Contributor

With straight python, I think your only option is to turn on "Open messages window automatically after running a tool"

Go to Project > Options > Geoprocessing and check "Open messages window automatically after running a tool".

 

Add something like this at the end of you script. 

arcpy.AddMessage("Starting long tool...")

try:
    arcpy.AddMessage("=== Tool Messages ===")
    arcpy.AddMessage(arcpy.GetMessages())        # All messages (info + warnings + errors)

except arcpy.ExecuteError:
    arcpy.AddError(arcpy.GetMessages(2))         # Only errors
0 Kudos