0

I've recently inherited some old python scripts that contained ArcPy modules. I'm using version 10.0.

I am looking for an error messaging system that replaces arcpy.AddMessage()?

2
  • 2
    Where is open source in your question ?
    – gene
    Commented Feb 21, 2015 at 16:36
  • 5
    What is your ultimate goal? Are you running these scripts from an IDE or from the script tool? You could always use a print statement (e.g. print "There is a problem with %s" % someVariable).
    – Aaron
    Commented Feb 21, 2015 at 16:45

1 Answer 1

2

I assume you are trying to convert your scripts so that they can be used in open source software or with open source libraries, otherwise the question's title would not make too much sense to me.

First of all you have to be aware that arcpy.AddMessage solely makes sense in one specific context: when used in a script tool that is used within ArcGIS. It does not much more than a print statement, but it prints it to the tool’s interface instead of your console. So, if you are trying to convert your scripts using open source, then you would just have to replace these parts with a simple print statement (if running from the console or an IDE, if you are using a GUI library such as Tkinter or PyQt, then you would have to use different commands to display messages in your interface).

If you are addressing errors specifically then you would use your statement in a try/catch block or in a conditional statement (that addresses whatever fails).

Should you stick with Esri, then you could also use the arcpy.AddError command, but you have to be aware that unlike addMessage or addWarning this command will end your tool’s execution the second it appears! Therefore, be very careful to only use it when an error truly occurs, or your tool will crash (even though there might not have been an error at all).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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