ExecuteWarning (arcpy)
Zusammenfassung
The ExecuteWarning exception class is raised when a geoprocessing tool encounters a warning, and the SetSeverityLevel function has updated the severity level to 1. Setting the severity level to 1 instructs arcpy to throw the ExecuteWarning execption when a warning is encountered.
Codebeispiel
ExecuteWarning exception example
The ExecuteWarning class is used below to specifically handle any geoprocessing tool warnings that result from DeleteFeatures.
import arcpy
try:
# If a tool produces a warning, it will throw an exception
#
arcpy.SetSeverityLevel(1)
# DeleteFeatures on a feature class will always return a warning
#
arcpy.DeleteFeatures_management("c:/base/transport.gdb/roads")
except arcpy.ExecuteWarning:
print arcpy.GetMessages()
Verwandte Themen
9/11/2013