<?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: Script runs in ArcMap but fails in Geoprocessing Service in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-runs-in-arcmap-but-fails-in-geoprocessing/m-p/119791#M9411</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Please see next thread, thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Sep 2013 19:48:30 GMT</pubDate>
    <dc:creator>ionarawilson1</dc:creator>
    <dc:date>2013-09-03T19:48:30Z</dc:date>
    <item>
      <title>Script runs in ArcMap but fails in Geoprocessing Service</title>
      <link>https://community.esri.com/t5/python-questions/script-runs-in-arcmap-but-fails-in-geoprocessing/m-p/119787#M9407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This script works well when I run in in ArcMap, but when I create a geoprocessing service it fails. I have to create a geoprocessing service because I will use this in a Javascript webmap.&amp;nbsp; Do you guys have any idea why it fails?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, in the python script I am not adding any parameters because in the javascript, the edit tool automatically creates a window for the users to enter data when they digitize the data. And the Stewardship feature class that is being pulled from a SDE geodatabase now will be replaced by the same data in a feature service, so I am not sure if this is the right way to do it anyway. Should I test it now with data directly from a feature service or is it ok to do this way? And Is it ok not to have any parameters? Thank you for any help! I have never used geoprocessing services, so I am just learning and any help is appreciated. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# Stewardship_From_ModelBuilder2.py
# Created on: 2013-09-03 10:53:25.00000
#&amp;nbsp;&amp;nbsp; (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Set the necessary product code
# import arcinfo


# Import arcpy module
import arcpy
from arcpy import env


# Local variables:

Stewardship = "Database Connections\Connection to tfsgis-iisd01.sde\sars.DBO.Stewardship"
Stewardship_FeatureToPoint1 = "\\\\tfscs-fp03\\Users\\iwilson\\Documents\\ArcGIS\\Default.gdb\\Stewardship_FeatureToPoint1"
Counties = "D:\\ArcGISData\\SARS\\Python_10April2013\\SARS.gdb\\Counties"
# Process: Feature To Point
arcpy.FeatureToPoint_management(Stewardship, Stewardship_FeatureToPoint1, "CENTROID")
arcpy.MakeFeatureLayer_management("Counties", "Counties_lyr")
arcpy.MakeFeatureLayer_management("Stewardship", "Stewardship_lyr")
# Process: Select Layer By Location (2)feat
arcpy.SelectLayerByLocation_management("Counties_lyr", "CONTAINS", Stewardship_FeatureToPoint1, "", "NEW_SELECTION")

countycode = tuple(arcpy.da.SearchCursor("Counties_lyr", "FIPS_TXT"))[0][0]
urows = arcpy.da.UpdateCursor(Stewardship, "County")
for urow in urows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; urow[0] = countycode
&amp;nbsp;&amp;nbsp;&amp;nbsp; urows.updateRow(urow)

del urows, urow


import time
from datetime import datetime, date
#sim_date_counter = 1

with arcpy.da.UpdateCursor("Stewardship_lyr", ("FFY","DateStart")) as rows:
&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #get the value of the date

&amp;nbsp;&amp;nbsp;&amp;nbsp; FFY = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; FFYnumber = int(FFY)
&amp;nbsp;&amp;nbsp;&amp;nbsp; #convert to string
&amp;nbsp;&amp;nbsp;&amp;nbsp; DateStart = row[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; DateStartstr = str(DateStart)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(DateStartstr)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get only the month
&amp;nbsp;&amp;nbsp;&amp;nbsp; # To get only the first two characters:
&amp;nbsp;&amp;nbsp;&amp;nbsp; DateStart2 = DateStartstr[0:2]
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(DateStart2)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if "/" in DateStart2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # if for example 6/28/2013
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateStart3 = DateStart[0:1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FFYnumbercount = FFYnumber
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(DateStart3)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(FFYnumbercount)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if "/" not in DateStart2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # if for example 10/10/2013
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateStart4 = int(DateStart2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FFYnumbercount = FFYnumber + 1

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(DateStart4)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(FFYnumbercount)
&amp;nbsp;&amp;nbsp;&amp;nbsp; row[0] = str(FFYnumbercount)

&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Sep 2013 16:26:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-runs-in-arcmap-but-fails-in-geoprocessing/m-p/119787#M9407</guid>
      <dc:creator>ionarawilson1</dc:creator>
      <dc:date>2013-09-03T16:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Script runs in ArcMap but fails in Geoprocessing Service</title>
      <link>https://community.esri.com/t5/python-questions/script-runs-in-arcmap-but-fails-in-geoprocessing/m-p/119788#M9408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Do you know what the geoprocessing is failing on?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe you can add some messages to see where the script is running to.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Sep 2013 17:06:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-runs-in-arcmap-but-fails-in-geoprocessing/m-p/119788#M9408</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2013-09-03T17:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Script runs in ArcMap but fails in Geoprocessing Service</title>
      <link>https://community.esri.com/t5/python-questions/script-runs-in-arcmap-but-fails-in-geoprocessing/m-p/119789#M9409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How can I add a message to a geoprocessing service? I know I can it to a tool but I am not sure how to do that for a geoprocessing service. Here is the log info in the server. It seems it is not happy with the Stewardship feature class that is being used as the input for the feature to point function (right in the beggining of the script), which is the SDE feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; Traceback (most recent call last): File "D:\arcgisserver\directories\arcgissystem\arcgisinput\GeoprocessingTests\Stewardship.GPServer\extracted\v101\arcgis\Stewardship_From_ModelBuilder2.py", line 37, in arcpy.FeatureToPoint_management(Stewardship, Stewardship_FeatureToPoint1, "CENTROID") File "c:\program files\arcgis\server\arcpy\arcpy\management.py", line 2376, in FeatureToPoint raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset D:\arcgisserver\directories\arcgissystem\arcgisinput\GeoprocessingTests\Stewardship.GPServer\extracted\v101\ does not exist or is not supported Failed to execute (FeatureToPoint). Failed to execute (Stewardship). Failed to execute (Stewardship from Model Builder&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Sep 2013 17:52:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-runs-in-arcmap-but-fails-in-geoprocessing/m-p/119789#M9409</guid>
      <dc:creator>ionarawilson1</dc:creator>
      <dc:date>2013-09-03T17:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: Script runs in ArcMap but fails in Geoprocessing Service</title>
      <link>https://community.esri.com/t5/python-questions/script-runs-in-arcmap-but-fails-in-geoprocessing/m-p/119790#M9410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Let me create another thread with the whole geoprocessing script I want to publish and I will ask questions there. Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Sep 2013 19:38:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-runs-in-arcmap-but-fails-in-geoprocessing/m-p/119790#M9410</guid>
      <dc:creator>ionarawilson1</dc:creator>
      <dc:date>2013-09-03T19:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Script runs in ArcMap but fails in Geoprocessing Service</title>
      <link>https://community.esri.com/t5/python-questions/script-runs-in-arcmap-but-fails-in-geoprocessing/m-p/119791#M9411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Please see next thread, thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Sep 2013 19:48:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-runs-in-arcmap-but-fails-in-geoprocessing/m-p/119791#M9411</guid>
      <dc:creator>ionarawilson1</dc:creator>
      <dc:date>2013-09-03T19:48:30Z</dc:date>
    </item>
  </channel>
</rss>

