Maintain Service Draft file after running "Stage Service" tool.

706
2
Jump to solution
04-17-2013 12:26 AM
TiagoRibeiro
Occasional Contributor
Hi guys,

In my model I have a "Stage Service" tool. The propose of the model is to push data into ArcGIS Online every week. This model will run automatically.
As it says in documentation, the draft file is deleted after the tool runs, but I wanted to preserve this file so that it can be used again. It's the only step missing on this model.
I can get around it by creating a python tool that verifies if the file exists, and if doesn't, copy it from another directory, but I was wondering if there's an "out-of-the-box" way to do it.

Any help will be appreciated.

Thanks
0 Kudos
1 Solution

Accepted Solutions
2 Replies
TiagoRibeiro
Occasional Contributor
So I kinda get around it. What I did is:
I Created this custom Python Tool...
import arcpy

mapDoc = arcpy.GetParameterAsText(0) 
service = arcpy.GetParameterAsText(1)
sddraft = 'C:\\GISData\\NIEA\\{}.sddraft'.format(service)

# create service definition draft
analysis = arcpy.mapping.CreateMapSDDraft(mapDoc, sddraft, service, 'MY_HOSTED_SERVICES')

# stage and upload the service if the sddraft analysis did not contain errors
if analysis['errors'] == {}:
    arcpy.SetParameterAsText(0, sddraft)
else: 
    arcpy.SetParameterAsText(0, sddraft)

... and the Service Definition Draft is created without a hitch.
Now I'm trying to pass the output SD draft to the Stage Service (Server) tool, inside the model, but I haven't yet been able to pass the output of the custom tool to the Stage Service tool.
The stage tool is expecting a file type input parameter, but even though I set the output of the custom tool to be a file, it's still not working...
There's a way around it, but it's not very "elegant". Use a preexisting SD Draft as the input of Stage Service tool, and have the custom tool just replace that sddraft file... any other ideas?
0 Kudos
TiagoRibeiro
Occasional Contributor
0 Kudos