I got a problem with Delete_management when I use the FeatureclassToCoverage_conversion function. I don't know why in the gdb I use (arcpy.env.scratchGDB), while the Delete_management is working, the folder is not completely deleted : 2 lockers file stay in.
Here is the code I use (I reduced it to the minimum) :
import os import arcpy from os.path import join # User entries on ArcGIS out_cover = "C:\Users\user\coverage" in_lines = "C:\Users\user\lines.shp" in_points = "C:\Users\user\points.shp" # Unsplit the lines fusionned_lines = join(arcpy.env.scratchGDB, "fusionned_lines") arcpy.UnsplitLine_management(in_lines, fusionned_lines) # Copy the feature points = join(arcpy.env.scratchGDB, "points") arcpy.CopyFeatures_management(in_points, points) # List the feature classes to put in the coverage. points_and_lines = [points, fusionned_lines] # Create the coverage directory if needed. if not arcpy.Exists(out_cover): os.makedirs(out_cover) # Convert the feature class list into a coverage. arcpy.FeatureclassToCoverage_conversion(points_and_lines, out_cover) # The Delete_management of fusionned_lines and points is comparlsary, otherwise # it is impossible to delete the scratch workspace. arcpy.Delete_management(fusionned_lines) arcpy.Delete_management(points) # This delete does not work like I want : arcpy.Delete_management(arcpy.env.scratchGDB)
In the scratch.gdb folder I always have a locker for fusionned_lines and a locker for points. For the first treatment it doesn't matter, but because of that I can't execute the script more than once.
Moreover, if I don't add the line : arcpy.FeatureclassToCoverage_conversion(points_and_lines, out_cover), the scratchGDB delete correctly. So the problem definitely come from here, but I don't know why or how.