Hi to everybody,
I wrote a script that, daily, erases and recreates a bunch of layers (feature classes) and tables.
The script works pretty well and completes the process succesfully with no error messages, but...
... here and there (frankly I do not see a pattern in the system behaviour) hung up due to a lock in one of the layers supposed to be deleted.
I have to manually remove it: with ArcCatalog I just "manage" the layer's locks and remove the criminal one left by the previous script run.
I work with ArcGIS suite 10.1 (Desktop + SDE for SQLServer + Server)
Any idea?
Massimiliano
The piece of code I am posting is a failed attempt to remove the "hipothetical" lock programmatically...
...
# Process: Select
arcpy.AddMessage("13) Selecting Features from " + UQ_MP70temp + " to create " + UQ_MP70)
if arcpy.Exists(UQ_MP70):
arcpy.AddMessage(".13.a) Start Deleting process of " + UQ_MP70)
AF_workspace = workingGDB
user_name = "DBO"
AF_users = arcpy.ListUsers(AF_workspace)
icount = 0
for item in AF_users:
arcpy.AddMessage(str(item.ID) + " - " + item.Name + " - " + user_name + " - " + str(icount))
if icount == 0:
userid = item.ID
if item.Name == user_name and icount >= 1:
arcpy.DisconnectUser(AF_workspace, userid)
arcpy.AddMessage(".13.b) " + user_name + " successfully disconnected")
arcpy.AcceptConnections(AF_workspace, True)
arcpy.Delete_management(UQ_MP70)
arcpy.AddMessage(".13.c.1) UNLOCKED - " + UQ_MP70 + " successfully deleted")
else:
arcpy.Delete_management(UQ_MP70)
arcpy.AddMessage(".13.c.2) NO LOCK - " + UQ_MP70 + " successfully deleted")
icount = icount + 1
arcpy.Select_analysis(UQ_MP70temp, UQ_MP70, "FocosQueimadas_DBO_UQ_MP_co_15 = 3")