Unable to copy feature classes on ArcGIS Server 10.2.2

1075
10
11-13-2018 09:22 AM
AdamTaylor5
New Contributor II

I've been trying without success to transfer a functional script on my local drive to a shared server that my organization has read and write access to. The server is running ArcGIS Server 10.2.2, and my code is written in Python 2.7.10. I've noticed that the code hangs at a certain point, no errors or exceptions are thrown, the program just runs and chews up RAM until the process is cancelled. I let it run overnight and what should take under 20 seconds to complete still was not complete. 

My script's purpose is to update an existing feature class in an existing file geodatabase while creating several backups and zip files for export and storage elsewhere. The code gets hung up on the line where it is attempting to copy an XY layer into a feature class on a local drive it shares with the script. Code sample below (failure at bold face font):


locations_Layer = db + "\\" + "locations_Layer"


arcpy.MakeXYEventLayer_management(inFolder + "\\locations.txt", "X_COORDINATE", "Y_COORDINATE", locations_Layer, "PROJCS['NAD_1983_CSRS_New_Brunswick_Stereographic',GEOGCS['GCS_North_American_1983_CSRS',DATUM['D_North_American_1983_CSRS',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Double_Stereographic'],PARAMETER['False_Easting',2500000.0],PARAMETER['False_Northing',7500000.0],PARAMETER['Central_Meridian',-66.5],PARAMETER['Scale_Factor',0.999912],PARAMETER['Latitude_Of_Origin',46.5],UNIT['Meter',1.0]];-28216700 -23260100 10000;#;#;0.001;#;#;IsHighPrecision")


print "Make xy event layer completed"

arcpy.FeatureClassToFeatureClass_conversion (locations_Layer, db, 'civic_addresses')


print "XY to FC conversion completed"

This process works flawlessly on my machine when writing to local and shared drives, but when run from the server infrastructure the script fails to function at this point in the code. I can upload the whole script if necessary.

Any guidance would be appreciated.

0 Kudos
10 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Adam,

How is the db variable referencing the File Geodatabase?  Is it using a UNC path (i.e. \\fileshare\gis).  If so, can the ArcGIS Server machine access the File Geodatabase through the UNC path?

0 Kudos
AdamTaylor5
New Contributor II

Hi Jake,

Thanks for the suggestion. I think I see where you're coming from, and here are snippets from my code related to what you mentioned:

env.workspace = os.path.dirname(os.path.abspath(__file__))

workspace = os.path.dirname(os.path.abspath(__file__))

inFolder = workspace

arcpy.CreateFolder_management(workspace,'fgdb')

outLocation = workspace + "\\" + "fgdb"

 

outGDB = "geonb_gcadb-bdavg.gdb"

if arcpy.Exists(outLocation + "\\" + outGDB) == True:

    GDB = outLocation + "\\" + outGDB

    outLocation = str(GDB)

elif arcpy.Exists(outLocation + "\\" + outGDB) == False:

    GDB = arcpy.CreateFileGDB_management(outLocation, outGDB)

    GDB = outLocation + "\\" + outGDB

    outLocation = str(GDB)

 

db = outLocation

As for whether that uses the UNC path I'm honestly not sure. Elsewhere in the script I refer to 'off drive' locations using notation like the below, and it reads and copies those locations just fine. The following code precedes my problem code and executes properly:

zipOrig = '\\\\geoappcifs-test\\cifs-geoapp-test\\geonbdata\\CADB_update\\PLANETLOCN.zip'
shutil.copy2(zipOrig,workspace)
zip_folder = workspace + "\\" + "PLANETLOCN.zip"

Hope that helps.

0 Kudos
MichaelVolz
Esteemed Contributor

Do you have error trapping incorporated into your python script?  If so, maybe comment out the error trapping on the server and see if you get some message indicating an issue when the script crashes on the server?

0 Kudos
AdamTaylor5
New Contributor II

I'm relatively new at the language after having used it for a year, so I'm honestly not sure what you mean by error trapping. I could incorporate a try...except block on the problem area if that's what you are intending. Though I'm new at exception handling and the related syntax. 

0 Kudos
JakeSkinner
Esri Esteemed Contributor

I'm not sure what the __file__ variable is set to for your first two lines.  Try replacing those with the following to see if the script executes successfully:

env.workspace = '\\\\geoappcifs-test\\cifs-geoapp-test\\geonbdata\\CADB_update'
workspace = '\\\\geoappcifs-test\\cifs-geoapp-test\\geonbdata\\CADB_update'‍‍

Also, it's hard to find, but here is a post that describes how to post code.

0 Kudos
AdamTaylor5
New Contributor II

Good suggestion Jake, but hardcoding the file paths didn't solve the problem. I converted both entries to  "\\\\server\\folder" and the result was unchanged. As for that syntax I used, it is supposed to be a variable that represents the directory where the script (the "_file_") sits on disk, allowing the script to be moved around on disk and still function.

0 Kudos
JakeSkinner
Esri Esteemed Contributor

What is the error reported when the script fails?

0 Kudos
AdamTaylor5
New Contributor II

There isn't one: when run in the server environment it doesn't throw up errors, it just runs infinitely, chewing up RAM and doing nothing. I need to look into what Michael suggested and use error trapping, if I can figure out how that works.

0 Kudos
JakeSkinner
Esri Esteemed Contributor

You may also want to try the CopyFeatures function just to see if this makes a difference at all.

arcpy.CopyFeatures_management(locations_Layer, db + '\\civic_addresses')

0 Kudos