GetSeverityLevel (arcpy)
摘要
返回严重性级别。严重性级别用于控制地理处理工具抛出异常的方式。
语法
GetSeverityLevel ()
数据类型 | 说明 |
Integer |
严重性级别。
|
代码实例
GetSeverityLevel 示例
使用 SetSeverityLevel 可强制工具在遇到工具警告时抛出异常。
import arcpy
fc_1 = 'c:/resources/resources.gdb/boundary'
fc_2 = 'c:/resources/resources.gdb/boundary2'
# Set the severity level to 1 (tool warnings will throw an exception)
arcpy.SetSeverityLevel(1)
print("Severity is set to : {0}".format(arcpy.GetSeverityLevel()))
try:
# FeatureCompare returns warning messages when a miscompare is
# found. This normally would not cause an exception, however, by
# setting the severity level to 1, all tool warnings will also
# return an exception.
arcpy.FeatureCompare_management(fc_1, fc_2, "OBJECTID")
except arcpy.ExecuteWarning:
print(arcpy.GetMessages(1))
except arcpy.ExecuteError:
print(arcpy.GetMessages(2))
相关主题
5/10/2014