From edf56ca2892b5982b80d34a500639bedcfd4ced1 Mon Sep 17 00:00:00 2001 From: Danang Date: Mon, 10 Jun 2024 13:40:43 +0700 Subject: [PATCH 1/2] handle when cog conversion is failed --- django_project/cplus_api/utils/worker_analysis.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/django_project/cplus_api/utils/worker_analysis.py b/django_project/cplus_api/utils/worker_analysis.py index ed99076..49def54 100644 --- a/django_project/cplus_api/utils/worker_analysis.py +++ b/django_project/cplus_api/utils/worker_analysis.py @@ -356,13 +356,20 @@ def create_and_upload_output_layer( os.path.dirname(file_path), cog_name ) - subprocess.run( + result = subprocess.run( ( f"gdal_translate -of COG -co COMPRESS=DEFLATE" f" {file_path} {final_output_path}" ), - shell=True + shell=True, + capture_output=True ) + if result.returncode != 0: + logger.error(result.stderr) + logger.error(f"Failed coverting raster to COG: {file_path}") + if not os.path.exists(final_output_path): + # fallback to original file + final_output_path = file_path else: final_output_path = file_path output_layer = OutputLayer.objects.create( From e2af3bf345fd3d2d39174138deb545cf1bf36691 Mon Sep 17 00:00:00 2001 From: Danang Date: Mon, 10 Jun 2024 13:41:34 +0700 Subject: [PATCH 2/2] bump commit version --- django_project/version/commit.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_project/version/commit.txt b/django_project/version/commit.txt index b43dce5..71bd5e7 100644 --- a/django_project/version/commit.txt +++ b/django_project/version/commit.txt @@ -1 +1 @@ -a7139ef4365e4db8bcdc9b5eba8d83944d546100 +edf56ca2892b5982b80d34a500639bedcfd4ced1