GetAllMessages

Resumen

Returns the message types, return codes, and message strings from the previously run tool.

Sintaxis

GetAllMessages ()
Valor de retorno
Tipo de datosExplicación
List

Returns a list of lists that includes by position: the type, return code, and message string.

The first item in each internal list is an integer representing the message type.

  • 0Informative message
  • 1Definition message
  • 2Start message
  • 3Stop message
  • 50Warning message
  • 100Error message
  • 101Empty message
  • 102Geodatabase error message
  • 200Abort message

The second item is an integer representing the message return code. If the message has an associated ID number, the item will be ID number. Error messages that do not have an ID will return -2147467259. All other messages will return a 0. The second item is the message string.

Muestra de código

GetAllMessages example

Print tool messages from different tools.

import arcpy
from pprint import pprint

arcpy.management.CreateSpatialReference()
pprint(arcpy.GetAllMessages(), width=120)

"""
[[0, 'Start Time: Wednesday, March 22, 2023 5:01:17 PM'],
 [0, 0, 'Spatial Reference = Unknown'],
 [0, 0, 'XY Domain (XMin,YMin XMax,YMax) = -450359962737.049,-450359962737.049 450359962737.049,450359962737.049'],
 [0, 0, 'Z Domain (Min,Max) = -100000,900719825474.099'],
 [0, 0, 'M Domain (Min,Max) = -100000,900719825474.099'],
 [3, 0, 'Succeeded at Wednesday, March 22, 2023 5:01:18 PM (Elapsed Time: 0.34 seconds)']]
"""

try:
    arcpy.management.CopyFeatures('c:/data/infc.shp', 'c:/data/infc.shp')
except arcpy.ExecuteError:
    pprint.pprint(arcpy.GetAllMessages(), width=100)

"""
[[2, 0, 'Start Time: Wednesday, March 22, 2023 5:06:14 PM'],
 [100, -2147467259, 'Failed to execute. Parameters are not valid.'],
 [100, 733, 'ERROR 000733: Output Feature Class: Same as input Input Features'],
 [100, -2147467259, 'Failed to execute (CopyFeatures).'],
 [3, 0, 'Failed at Wednesday, March 22, 2023 5:06:15 PM (Elapsed Time: 1.16 seconds)']]
"""

Temas relacionados