SVGHMI: fix build exception when static file directory is missing
authorEdouard Tisserant <edouard@beremiz.fr>
Thu, 09 Jan 2025 17:09:00 +0100 (2 months ago)
changeset 4083 6a8fd46e9980
parent 4082 3ef4b5b202fc
child 4084 b312fd26a6a9
SVGHMI: fix build exception when static file directory is missing
svghmi/svghmi.py
--- a/svghmi/svghmi.py	Fri Dec 20 14:37:10 2024 +0100
+++ b/svghmi/svghmi.py	Thu Jan 09 17:09:00 2025 +0100
@@ -574,10 +574,11 @@
         project_path = self.CTNPath()
         static_dir = os.path.join(project_path, "static") 
         static_files_pairs = []
-        for fname in os.listdir(static_dir):
-            undercover_fname = location_str+"_"+fname
-            static_files_pairs.append('(b"%s","%s")'%(fname, undercover_fname))
-            res += ((undercover_fname, open(os.path.join(static_dir, fname), "rb")),)
+        if os.path.exists(static_dir):
+            for fname in os.listdir(static_dir):
+                undercover_fname = location_str+"_"+fname
+                static_files_pairs.append('("%s","%s")'%(fname, undercover_fname))
+                res += ((undercover_fname, open(os.path.join(static_dir, fname), "rb")),)
         static_files = ",\n    ".join(static_files_pairs)
 
         if os.path.exists(svgfile):