0

I have created a Geoprocessing service that is hosted on a server inside our firewall (ArcGIS Enterprise 10.6). The GP service adds messages via arcpy.AddMessage("msg").

Locally, I import the toolbox via arcpy.ImportToolbox("https://...") and execute the service. Everything runs to completion, but I would like to receive messages back from the service to my local python script.

Calling arcpy.GetMessages() from my local python script only returns local messages.

Is there anyway to get the messages from the server-side GP service?

Edit: when I run the GP service from ArcCatalog (as a tool) it returns all of the remote messages.

4
  • You have to enable messages in the Server and the service, but you can retrieve them through the REST API.
    – Vince
    Commented Feb 7, 2019 at 19:09
  • @Vince in the service parameters, Message Level = Info. Where do you enable messages in the Server?
    – Brad
    Commented Feb 7, 2019 at 19:12
  • You only need to set message level = info on the service to get AddMessage level messages to display.
    – KHibma
    Commented Feb 7, 2019 at 19:24
  • @KHibma messages do display if run via Desktop. When I import and run via python, no messages are returned from arcpy.GetMessages
    – Brad
    Commented Feb 7, 2019 at 19:28

1 Answer 1

1

To get the messages of the Geoprocessing Service, you need to do two things:

  1. Ensure you have a proper message level set on the service. AddMessage = Info, AddWarning = Warning, AddError = Error. (This traverses down, meaning Info will display warnings and errors).
  2. You need to perform GetMessage off the result of your execution.

From your question, you've stated you're calling arcpy.GetMessages(). You need to call GetMessages from the result of your execution.

From the using gp services with python help, you can see the execution is assigned to result and getMessages() is called from that. Of course you'd need to wrap this in a print statement: print(result.getMessages()

import arcpy
import time

arcpy.ImportToolbox("http://sampleserver1.arcgisonline.com/ArcGIS/services;Elevation/ESRI_Elevation_World", "viewshedAlias")

result = arcpy.Viewshed_viewshedAlias(r'c:\data\inputPoint.shp', "10000 Kilometers")

while result.status < 4:
       print result.status
       time.sleep(0.2)
print "Execution Finished"

result.getMessages()
arcpy.CopyFeatures_management(result.getOutput(0), 'localResult.shp')
1
  • I had 2 issues: 1) I was not calling GetMessages from the result (as you mentioned). 2) I was calling GetMessages before the result status was 4. so adding the "while" loop was also important.
    – Brad
    Commented Feb 11, 2019 at 12:18

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.