From a6c394b9f6c158c0a5f4b8d719d86e20df97fa38 Mon Sep 17 00:00:00 2001
From: Tor-Einar Skog <tor-einar.skog@nibio.no>
Date: Tue, 19 Mar 2024 12:41:04 +0100
Subject: [PATCH] Add DEBUG option

---
 SEPTREFHUM.py | 10 +++++++---
 env-sample    |  5 ++++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/SEPTREFHUM.py b/SEPTREFHUM.py
index 0e1bb80..fb08d07 100755
--- a/SEPTREFHUM.py
+++ b/SEPTREFHUM.py
@@ -54,6 +54,9 @@ RR = os.getenv("RR")
 UM = os.getenv("UM")
 local_timezone = pytz.timezone(os.getenv("LOCAL_TIMEZONE"))
 
+DEBUG = False if os.getenv("DEBUG") is None or os.getenv("DEBUG").lower() == "false" else True
+
+
 # Iterate the set of hourly weather data files
 # 1. When's the latest wh_[DATE].nc file? - set earliest weather data file: start_date = [DATE]-2 days
 # --> If no wh_DATE.nc file exists, set start_date = None
@@ -70,9 +73,10 @@ if last_wh_date is not None:
 
 
 weatherdata_files = glob.glob(f"{infile_path}{filename_pattern}")
-#print(f"{infile_path}{filename_pattern}")
-#print("What are the weatherdata files?")
-#print(weatherdata_files)
+if DEBUG:
+    print(f"{infile_path}{filename_pattern}")
+    print("What are the weatherdata files?")
+    print(weatherdata_files)
 for file_path in sorted(weatherdata_files):
     # TODO: When filename/pattern is configurable: make the string search adaptable
     file_name = os.path.basename(file_path)
diff --git a/env-sample b/env-sample
index d35a556..81252ce 100644
--- a/env-sample
+++ b/env-sample
@@ -32,4 +32,7 @@ MAPSERVER_LOG_FILE=/foo/mapserver/log/SEPTREFHUM.log
 # Path to the temporary directory for writing temporary files and images. Must be writable by the user the web server is running as
 MAPSERVER_IMAGE_PATH=/foo/mapserver/tmp/
 # The value of the EXTENT parameter in Mapserver's mapfile. Units are DD (Decimal degrees)
-MAPSERVER_EXTENT="-1.5831861262936526 52.4465003983706595 39.2608060398730458 71.7683216082912736"
\ No newline at end of file
+MAPSERVER_EXTENT="-1.5831861262936526 52.4465003983706595 39.2608060398730458 71.7683216082912736"
+
+# Default value is false
+#DEBUG=True
\ No newline at end of file
-- 
GitLab