Select to view content in your preferred language

Script runs in ArcMap but fails in Geoprocessing Service

708
4
09-03-2013 09:26 AM
ionarawilson1
Deactivated User
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.  Do you guys have any idea why it fails?



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.

# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# Stewardship_From_ModelBuilder2.py
# Created on: 2013-09-03 10:53:25.00000
#   (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:
    urow[0] = countycode
    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:
  for row in rows:
    #get the value of the date

    FFY = row[0]
    FFYnumber = int(FFY)
    #convert to string
    DateStart = row[1]
    DateStartstr = str(DateStart)
    arcpy.AddMessage(DateStartstr)
    # Get only the month
    # To get only the first two characters:
    DateStart2 = DateStartstr[0:2]
    arcpy.AddMessage(DateStart2)
    if "/" in DateStart2:
                # if for example 6/28/2013
            DateStart3 = DateStart[0:1]
            FFYnumbercount = FFYnumber
            arcpy.AddMessage(DateStart3)
            arcpy.AddMessage(FFYnumbercount)
    if "/" not in DateStart2:
         # if for example 10/10/2013
        DateStart4 = int(DateStart2)
        FFYnumbercount = FFYnumber + 1

        arcpy.AddMessage(DateStart4)
        arcpy.AddMessage(FFYnumbercount)
    row[0] = str(FFYnumbercount)

    rows.updateRow(row)

Tags (2)
0 Kudos
4 Replies
MichaelVolz
Esteemed Contributor
Do you know what the geoprocessing is failing on?

Maybe you can add some messages to see where the script is running to.
0 Kudos
ionarawilson1
Deactivated User
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.

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
0 Kudos
ionarawilson1
Deactivated User
Let me create another thread with the whole geoprocessing script I want to publish and I will ask questions there. Thanks
0 Kudos
ionarawilson1
Deactivated User
Please see next thread, thanks
0 Kudos