<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Publish ExtractData using python, works from Pro GUI, but not on the command line in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/publish-extractdata-using-python-works-from-pro/m-p/1141288#M51063</link>
    <description>&lt;P&gt;Is there code missing since...&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;inputaprx = 'TestExtract.aprx'&lt;/PRE&gt;&lt;P&gt;won't work on its own.&amp;nbsp; Either set the workspace or provide the full path to the project.&lt;/P&gt;&lt;P&gt;The python console inside pro and notebooks inside pro know about where things are (hence... CURRENT works)&lt;/P&gt;</description>
    <pubDate>Mon, 07 Feb 2022 18:09:04 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2022-02-07T18:09:04Z</dc:date>
    <item>
      <title>Publish ExtractData using python, works from Pro GUI, but not on the command line</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/publish-extractdata-using-python-works-from-pro/m-p/1141268#M51061</link>
      <description>&lt;P&gt;I'm trying to automate publishing the ExtractData task as Geoprocessing Service. To do this, I created a small Python Script which executes the ExtractData Tool and then it should publish the result object as a Geoproccesing Service. The input to the script comes from an ArcGIS Pro Project, I tried it with a layer from my Enterprise Geodatabase and with a layer from the default project file geodatabase. Everytime I run the script from the commandline, it fails with the Error 999999, however, when I run the script from the python console within ArcGIS Pro, it runs fine.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JolHempenius3_0-1644254017469.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33279i5FECCFE1CDEDB0BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JolHempenius3_0-1644254017469.png" alt="JolHempenius3_0-1644254017469.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, sys, getopt, os

#modify this function to run your toolbox

    # Run the tool and set to a result object
inputaprx = 'C:\\Users\\joelh\Documents\\ArcGIS\\Projects\\TestExtract\\TestExtract.aprx'
aprx = arcpy.mp.ArcGISProject(inputaprx)
#aprx = arcpy.mp.ArcGISProject("CURRENT") #voor gebruik in ArcGIS Pro
outputfile = 'C:\\Users\\joelh\Documents\\ArcGIS\\Projects\\TestExtract\\extract.zip'
mp = aprx.listMaps("*")[0]
layers = mp.listLayers("*")
sddraft = "testservice.sddraft"
sd = "testservice.sd"
serviceName = "ExtractData"
connection_file_path = "server.ags"
copyData = True
servicefolder = "Test"
summary  = "Extract Data"
tags = "Tag"
executionType =  "Asynchronous"
serverURL = "https://my.arcgis.enterprise/server"

    
arcpy.AddMessage("Executing Extract task")
result = arcpy.server.ExtractData(layers, layers[0], "File Geodatabase - GDB - .gdb", "ESRI GRID - GRID", "Same As Input", None, outputfile)
#result = arcpy.server.ExtractDataTask(layers, layers[0], "File Geodatabase - GDB - .gdb", "ESRI GRID - GRID", outputfile)
    
arcpy.AddMessage("Extract task message count {}".format(result.messageCount))
arcpy.AddMessage("Messages: {}".format(result.getMessages(0)))
arcpy.AddMessage("Warning Messages: {}".format(result.getMessages(1)))
arcpy.AddMessage("Error Messages: {}".format(result.getMessages(2)))

server_type = "FROM_CONNECTION_FILE"
analyzeMessages = arcpy.CreateGPSDDraft(
            result, sddraft, serviceName, server_type=server_type,connection_file_path = connection_file_path,
            copy_data_to_server=copyData, folder_name=servicefolder,
            summary=summary, tags=tags, executionType=executionType,
            resultMapServer=False, showMessages="INFO", maximumRecords=5000,
            minInstances=1, maxInstances=1, maxUsageTime=100, maxWaitTime=10,
            maxIdleTime=180)
arcpy.AddMessage("Messages {}".format(analyzeMessages))
if analyzeMessages['errors'] == {}:
    # Execute StageService
    arcpy.StageService_server(sddraft, sd)
arcpy.UploadServiceDefinition_server(sd, serverURL)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas why this script fails on the command line?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 15:42:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/publish-extractdata-using-python-works-from-pro/m-p/1141268#M51061</guid>
      <dc:creator>JoëlHempenius3</dc:creator>
      <dc:date>2022-02-09T15:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Publish ExtractData using python, works from Pro GUI, but not on the command line</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/publish-extractdata-using-python-works-from-pro/m-p/1141288#M51063</link>
      <description>&lt;P&gt;Is there code missing since...&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;inputaprx = 'TestExtract.aprx'&lt;/PRE&gt;&lt;P&gt;won't work on its own.&amp;nbsp; Either set the workspace or provide the full path to the project.&lt;/P&gt;&lt;P&gt;The python console inside pro and notebooks inside pro know about where things are (hence... CURRENT works)&lt;/P&gt;</description>
      <pubDate>Mon, 07 Feb 2022 18:09:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/publish-extractdata-using-python-works-from-pro/m-p/1141288#M51063</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-02-07T18:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Publish ExtractData using python, works from Pro GUI, but not on the command line</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/publish-extractdata-using-python-works-from-pro/m-p/1142139#M51161</link>
      <description>&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;Small mistake of me there, I tried it both with the full path to the Aprx file and this example I tried to see if a relative path would make a difference. It didn't however, so the question remains why it doesn't work from the command line.&lt;BR /&gt;I will correct the sample code to include the full path&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 15:40:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/publish-extractdata-using-python-works-from-pro/m-p/1142139#M51161</guid>
      <dc:creator>JoëlHempenius3</dc:creator>
      <dc:date>2022-02-09T15:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: Publish ExtractData using python, works from Pro GUI, but not on the command line</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/publish-extractdata-using-python-works-from-pro/m-p/1142168#M51167</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/server/stage-service.htm" target="_blank"&gt;Stage Service (Server)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The only thing I can see on a quick look is that your paths are still not specific&lt;/P&gt;&lt;P&gt;From their code example&lt;/P&gt;&lt;P&gt;arcpy.StageService_server(r"&lt;EM&gt;C:\Data\&lt;/EM&gt;World.sddraft", r"&lt;EM&gt;C:\Data\&lt;/EM&gt;World.sd")&lt;/P&gt;&lt;P&gt;Have you set your environment workspace somewhere so that the referenced files can be located? (eg arcpy.env.workspace = ....&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 16:05:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/publish-extractdata-using-python-works-from-pro/m-p/1142168#M51167</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-02-09T16:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: Publish ExtractData using python, works from Pro GUI, but not on the command line</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/publish-extractdata-using-python-works-from-pro/m-p/1142175#M51170</link>
      <description>&lt;P&gt;Fixed those as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still no luck:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JolHempenius3_0-1644423122553.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33505iC6817F5FC7E131ED/image-size/large?v=v2&amp;amp;px=999" role="button" title="JolHempenius3_0-1644423122553.png" alt="JolHempenius3_0-1644423122553.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It's now telling me there's an error somewhere, but I print both the messages from the Extract Task and from the staging and there isn't an error before it fails (or I need glasses, because I don't see it anymore)&lt;/P&gt;</description>
      <pubDate>Wed, 09 Feb 2022 16:14:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/publish-extractdata-using-python-works-from-pro/m-p/1142175#M51170</guid>
      <dc:creator>JoëlHempenius3</dc:creator>
      <dc:date>2022-02-09T16:14:00Z</dc:date>
    </item>
  </channel>
</rss>

