Removing existing backup layers and renaming current live layer in ArcSDE

المشرف العام

Administrator
طاقم الإدارة
Looking at the attached screenshot of Catalog, there are the file "CRT_CANAL" and many backups. The aim of this code is deleting old backups in the ArcSDE database,renaming the existing "CRT_CANAL" as backup + the current date (es CRT_CANAL_bck20151222) and copying the new layer in the database that will get the original name "CRT_CANAL" without date.

Running my code I got a generic error in the deleting layers section. So that the machine overcomes that part of the code and goes to the next stage renaming current live layer.

This is the message I get:

"start processing ea-wfs-canal_centreline_inspire...quick import success (C:\temp\wfs\ea-wfs-canal_centreline_inspire.gdb)count success (169) delete old backup layer ERROR: complete processing ea-wfs-canal_centreline_inspire (100000000) now called CRT_CANAL - 169 featuresImport(s) completeProcessing time: 32.5829999447 seconds"

This is the code:

# Check if backup layer exists in SDE and remove it if arcpy.ValidateTableName(layer_bck_delete): try: fcList = arcpy.ListFeatureClasses(layer_bck_delete) for fc in fcList: data_type = "FeatureClass" arcpy.Delete_management(fc, data_type) if debugMode: msg = msg + "delete old backup layer success" + "\n" except: msg = msg + "delete old backup layer ERROR: " + arcpy.GetMessages(2) + "\n" process = 0 if arcpy.Exists(layer_sde_output): if process == 1: # Rename current live layer try: arcpy.Rename_management(layer_sde_output, layer_bck, data_type) if debugMode: msg = msg + "create backup layer success" + "\n" except: msg = msg + "create backup layer ERROR: " + arcpy.GetMessages(2) + "\n" process = 0 if process == 1: # Import into SDE try: sdeLayer = sdeConnection + sdeOwner + wfsOutputName arcpy.CopyFeatures_management(gdbLayer, sdeLayer) if debugMode: msg = msg + "SDE import success" + "\n" except: msg = msg + "SDE import ERROR: " + arcpy.GetMessages(2) + "\n" process = 0Anyone can help me in correcting this code?

Reagrds to all the users and staff of StackExchange



أكثر...
 
أعلى