I'm a beginner to Python coding and now working on a basic script program, where I'm using both Print and arcpy.AddMessage/arcpy.AddError in a standalone script for ArcMap or in Pythonwin. However, I'm having issues with how I can do this for arcpy.GetMessages in PythonWin to find a traceback error.
I tried using:
msgs = arcpy.GetMessages(2)
print (msgs)
arcpy.AddMessage(msgs)
But couldn't get any traceback message. Is there a code that helps show the traceback error in Pythonwin?
Full Script below:
import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.env.overwriteOutput = True
try:
# Sets the workspace evironment settings.
env.workspace = "E:/College/Penn State/GEOG 485/Lesson 1/Lesson1"
inRaster = "foxlake"
contourInterval = 25
baseContour = 0
outContours = "E:/College/Penn State/GEOG 485/Lesson 1/Lesson1/ContourFoxLake.shp"
arcpy.CheckOutExtension("Spatial")
arcpy.sa.Contour(inRaster, outContours, contourInterval, baseContour)
# Report a success message
print "Contour creation successful!"
arcpy.AddMessage("Contour creation successful!")
except:
# Report an error message
print "Failed to create the contour."
arcpy.AddError("Failed to create the contour.")
# Report any error messages that the Contour tool might have generated
msgs = arcpy.GetMessages(2)
print (msgs)
arcpy.AddMessage(msgs)