Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to get model builder to email me the results of processes at certain stages so that if there are issues I can remotely login and deal with them as I do with python scripts. I have a python based tool to email the results but don't see a way to get results from individual processes. You can right-click on a process in model builder and view results but how can I get this info to be passed into the email script?

Worst case scenario - I guess I can export the model to python and add the emailer script but is there an easier way?

enter image description here

Model Code -this is a simple model to test. The main model to use this on will run over a weekend or more as the raster-polygon take about 6 hours for some tiles.

# ---------------------------------------------------------------------------
# model_emailstatus.py
# Created on: 2011-10-11 16:28:25.00000
#   (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Load required toolboxes
arcpy.ImportToolbox("D:/SCRATCH/Projects/106/Toolbox.tbx")


# Local variables:
Key_Resource_Area_shp = "O:\\2011\\11\KeyResourceArea.shp"
Key_Resource_Separation_Area_shp = "O:\\2011\\1121\SeparationArea.shp"
Message = ""

This is what I want to fill...in python it would be just Message = arcpy.GetMessages() but what does the same thing in model builder?

Email = "georgec@xxxxxxxx"
Success = ""

How do I fill this with true/false depending on if the merge tool is successful or not?

KeyResourceArea_Merge = "C:\\Users\\georgec\\Documents\\ArcGIS\\Default.gdb\\KeyResourceArea_Merge"

# Process: Merge
arcpy.Merge_management(<snip>)

# Process: EmailStatus
arcpy.gp.toolbox = "D:/SCRATCH/Projects/106/Toolbox.tbx";
# Warning: the toolbox D:/SCRATCH/Projects/106/Toolbox.tbx DOES NOT have an alias. 
# Please assign this toolbox an alias to avoid tool name collisions
# And replace arcpy.gp.EmailStatus(...) with arcpy.EmailStatus_ALIAS(...)
arcpy.gp.EmailStatus(Message, Email, Success)

Best,

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

I'd probably ditch ModelBuilder, or at least call your models from Python, and use the logging module with an SMTPHandler to email you any critical messages.

share|improve this answer
    
yup...I just hope that I don't have to do this. Surely there must be a way to capture the progress info from a tool that is running in model builder? –  GeorgeC Oct 11 '11 at 6:54
4  
Normally (unless you are running a geoprocessing server tool) either it will run successfully or it will produce an exception. All you can really do is log everything and email the exceptions so you know that something went wrong. –  blah238 Oct 11 '11 at 7:21
add comment

I am in agreement with @Blah238 (best to do logging and emaiing via Python), but want to point out that there are a couple Python scripts on the ArcGIS Geoprocessing Resource Center that already have the bones of logging and emailing set up and may help jumpstart the process for you.

share|improve this answer
    
Thanks...I guess I'll just have to use python. I accepted blah238's answer as he responded first but Ryan thanks for the extra info. I have the python email tool already but the extra functions in the ESRI scripts will be useful. Best. –  GeorgeC Oct 12 '11 at 0:54
    
Agreed, I just wanted to pass along some links that might be helpful to other users, which don't fit nearly as well in the comments box. –  RyanDalton Oct 12 '11 at 14:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.