beremiz

SVGHMI: fix build exception when static file directory is missing
py2compat
17 months ago, Edouard Tisserant
5a17b0e7a360
Parents b7f5b640f805
Children cd5fbf238096
SVGHMI: fix build exception when static file directory is missing
--- a/svghmi/svghmi.py Thu Jan 09 09:46:43 2025 +0100
+++ b/svghmi/svghmi.py Thu Jan 09 17:09:00 2025 +0100
@@ -563,10 +563,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('("%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):