Script unable to overwrite feature class due to lock file

1380
3
03-23-2017 04:44 AM
TheoFaull
Occasional Contributor III

Hi,

We have a feature class which can be updated using a python script. I've included:

# Overwrite pre-existing files
arcpy.env.overwriteOutput = True

When ArcCatalog is open and I naviaget to the GeoDatabase with the feature class in it, a LOCK file is created. This however does not prevent the feature class from being overwritten.

However, when I drag the feature class into ArcMap, the LOCK file created from this DOES prevent the script from running. The feature class will not be overwritten if an ArcMap LOCK file is present on it.

How can I get around this? The feature class is due to be accessed 24/7 on a server. I want my script to run overnight to overwrite the feature class, but I'm worried the LOCK file will prevent.

Tags (2)
0 Kudos
3 Replies
JoshuaBixby
MVP Esteemed Contributor

It would be helpful if you could elaborate more about the script, or better yet share of the functional code.  What tool are you using to overwrite the feature class?  What, specifically, is the error message?  Is the script being run stand-alone or from within ArcMap or ArcCatalog?

0 Kudos
TheoFaull
Occasional Contributor III

Script is being run stand alone from the Python IDLE GUI.

# Display initiation message
print "Script started..."

# Import arcpy module
import arcpy

# Overwrite pre-existing files
arcpy.env.overwriteOutput = True

# Local variables:
Sheet1_ = "K:\\GIS2007\\scratchdata\\PropertyUpdate\\GIS Listing.xlsx\\Sheet1$"
Sheet1__Layer = "Sheet1$_Layer"
CuroProperties_gdb = "K:\\GIS2016\\GIS_Data\\Curo_data\\Property_data\\CuroProperties.gdb"
CuroProperties_All = "K:\\GIS2016\\GIS_Data\\Curo_data\\Property_data\\CuroProperties.gdb\\CuroProperties_All"

# Process: Make XY Event Layer
arcpy.MakeXYEventLayer_management(Sheet1_, "easting", "northing", Sheet1__Layer, "PROJCS['British_National_Grid',GEOGCS['GCS_OSGB_1936',DATUM['D_OSGB_1936',SPHEROID['Airy_1830',6377563.396,299.3249646]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',400000.0],PARAMETER['False_Northing',-100000.0],PARAMETER['Central_Meridian',-2.0],PARAMETER['Scale_Factor',0.9996012717],PARAMETER['Latitude_Of_Origin',49.0],UNIT['Meter',1.0]];-5220400 -15524400 10000;-100000 10000;-100000 10000;0.001;0.001;0.001;IsHighPrecision", "")

# Display XY Event Layer completion message
print "XY Event Layer completed, creating Curo Properties feature class..."

# Process: Feature Class to Feature Class
arcpy.FeatureClassToFeatureClass_conversion(Sheet1__Layer, CuroProperties_gdb, "CuroProperties_All", "", "prty_id \"prty_id\" true true false 255 Text 0 0 ,First,#,Sheet1$_Layer,prty_id,-1,-1;alt_prty_id \"alt_prty_id\" true true false 255 Text 0 0 ,First,#,Sheet1$_Layer,alt_prty_id,-1,-1;Title \"Title\" true true false 255 Text 0 0 ,First,#,Sheet1$_Layer,Title,-1,-1;.... *BLAH BLAH BLAH lots and lots of lines like this...!*

# Display completion message
print "Script finished"

So again, this works even when there is a ArcCatalog generated LOCK file present, but when the feature class that's being overwritten has an ArcMap LOCK file against it, the script won't work.

0 Kudos
TheoFaull
Occasional Contributor III

Script made with model builder. ArcGIS 10.4, Python 2.7.10

0 Kudos