Merge pull request #4782 from heewa/fix-startpage-dir-bug

Start: fix bug when custom folder doesn't exist
This commit is contained in:
Yorik van Havre
2021-05-11 12:10:59 +02:00
committed by GitHub

View File

@@ -415,15 +415,18 @@ def handle():
for cfolder in cfolders.split(";;"): # allow several paths separated by ;;
if not os.path.isdir(cfolder):
cfolder = os.path.dirname(cfolder)
SECTION_CUSTOM += encode("<h2>"+os.path.basename(os.path.normpath(cfolder))+"</h2>")
SECTION_CUSTOM += "<ul>"
for basename in os.listdir(cfolder):
filename = os.path.join(cfolder,basename)
SECTION_CUSTOM += encode(buildCard(filename,method="LoadCustom.py?filename="+str(dn)+"_"))
SECTION_CUSTOM += "</ul>"
# hide the custom section tooltip if custom section is set (users know about it if they enabled it)
HTML = HTML.replace("id=\"customtip\"","id=\"customtip\" style=\"display:none;\"")
dn += 1
if not os.path.exists(cfolder):
FreeCAD.Console.PrintWarning("Custom folder not found: %s" % cfolder)
else:
SECTION_CUSTOM += encode("<h2>"+os.path.basename(os.path.normpath(cfolder))+"</h2>")
SECTION_CUSTOM += "<ul>"
for basename in os.listdir(cfolder):
filename = os.path.join(cfolder,basename)
SECTION_CUSTOM += encode(buildCard(filename,method="LoadCustom.py?filename="+str(dn)+"_"))
SECTION_CUSTOM += "</ul>"
# hide the custom section tooltip if custom section is set (users know about it if they enabled it)
HTML = HTML.replace("id=\"customtip\"","id=\"customtip\" style=\"display:none;\"")
dn += 1
HTML = HTML.replace("SECTION_CUSTOM",SECTION_CUSTOM)
# build IMAGE_SRC paths