From 3514dffbb5a919c75034f2aaf1c4b133316b3503 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20H=C3=B6ppner?= <jonas.hoeppner@garz-fricke.com>
Date: Wed, 23 Feb 2022 15:08:29 +0100
Subject: [PATCH] alphaplan_fwr.py: Silently ignore if 'output_dir is not set

---
 alphaplan_fwr.py | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/alphaplan_fwr.py b/alphaplan_fwr.py
index df428e0c..c1231431 100755
--- a/alphaplan_fwr.py
+++ b/alphaplan_fwr.py
@@ -228,13 +228,16 @@ def generate_fwr_articles(
         )
         jsonfile_uboot_name = "alphaplan-import-uboot-{}.json".format(machine)
         jsonfile_uboot_local = os.path.join(outlocal_dir, machine, jsonfile_uboot_name)
-        jsonfile_uboot_output = os.path.join(output_dir, machine, jsonfile_uboot_name)
         with open(jsonfile_uboot_local, "w", encoding="utf-8") as jsonfile:
             json.dump(data_uboot, jsonfile, indent=4)
 
-        shutil.copyfile(
-            jsonfile_uboot_local, jsonfile_uboot_output, follow_symlinks=True
-        )
+        if output_dir is not None:
+            jsonfile_uboot_output = os.path.join(
+                output_dir, machine, jsonfile_uboot_name
+            )
+            shutil.copyfile(
+                jsonfile_uboot_local, jsonfile_uboot_output, follow_symlinks=True
+            )
         # Send data object to AlphaPlan webservice
         ap_send_json(data_uboot)
 
@@ -242,10 +245,12 @@ def generate_fwr_articles(
     # Generate a json file from the dict/list structure for debugging
     jsonfile_name = "alphaplan-import-{}.json".format(machine)
     jsonfile_local = os.path.join(outlocal_dir, machine, jsonfile_name)
-    jsonfile_output = os.path.join(output_dir, machine, jsonfile_name)
     with open(jsonfile_local, "w", encoding="utf-8") as jsonfile:
         json.dump(data, jsonfile, indent=4)
-    # Copy file to release folder as the atrifacts have already been copied
-    shutil.copyfile(jsonfile_local, jsonfile_output, follow_symlinks=True)
+
+    if output_dir is not None:
+        # Copy file to release folder as the atrifacts have already been copied
+        jsonfile_output = os.path.join(output_dir, machine, jsonfile_name)
+        shutil.copyfile(jsonfile_local, jsonfile_output, follow_symlinks=True)
     # Send data object to AlphaPlan webservice
     ap_send_json(data)
-- 
GitLab