Skip to content

Commit

Permalink
updated create grids function to remove lock files
Browse files Browse the repository at this point in the history
  • Loading branch information
osundwajeff committed Sep 18, 2024
1 parent f3db9fe commit 920f7e5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/qgis_gender_indicator_tool/jobs/create_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def create_grids(self, layer, output_dir, crs, merged_output_path):
# Check if the merged grid already exists
if os.path.exists(merged_output_path):
print(f"Merged grid already exists: {merged_output_path}")
return QgsVectorLayer(
merged_output_path, "merged_grid", "ogr"
) # Load the existing merged grid layer
return merged_output_path

layer = QgsVectorLayer(layer, "country_layer", "ogr")
if not layer.isValid():
Expand Down Expand Up @@ -118,4 +116,12 @@ def create_grids(self, layer, output_dir, crs, merged_output_path):
print(f"Merging grids into: {merged_output_path}")
merge_params = {"LAYERS": all_grids, "CRS": crs, "OUTPUT": merged_output_path}
merged_grid = processing.run("native:mergevectorlayers", merge_params)["OUTPUT"]
lock_files = [
f"{merged_output_path}-journal",
f"{merged_output_path}-wal",
f"{merged_output_path}-shm",
]
for lock_file in lock_files:
if os.path.exists(lock_file):
os.remove(lock_file)
return merged_grid

0 comments on commit 920f7e5

Please sign in to comment.