bonsai web module #5178

Ping @Ziad-I just in case
This commit is contained in:
Andrej730
2024-08-14 16:24:41 +05:00
committed by Andrej
parent b15820dd10
commit db1f4d126a
2 changed files with 12 additions and 12 deletions
@@ -2,11 +2,11 @@ import sys
import os
import webbrowser
blenderbim_lib_path = os.environ.get("BLENDERBIM_LIB_PATH")
blenderbim_version = os.environ.get("BLENDERBIM_VERSION")
bonsai_lib_path = os.environ.get("BONSAI_LIB_PATH")
bonsai_version = os.environ.get("BONSAI_VERSION")
if blenderbim_lib_path:
sys.path.insert(0, blenderbim_lib_path)
if bonsai_lib_path:
sys.path.insert(0, bonsai_lib_path)
import argparse
from aiohttp import web
@@ -131,21 +131,21 @@ sio.register_namespace(BlenderNamespace("/blender"))
async def index(request):
with open("templates/index.html", "r") as f:
template = f.read()
html_content = pystache.render(template, {"port": sio_port, "version": blenderbim_version})
html_content = pystache.render(template, {"port": sio_port, "version": bonsai_version})
return web.Response(text=html_content, content_type="text/html")
async def gantt(request):
with open("templates/gantt.html", "r") as f:
template = f.read()
html_content = pystache.render(template, {"port": sio_port, "version": blenderbim_version})
html_content = pystache.render(template, {"port": sio_port, "version": bonsai_version})
return web.Response(text=html_content, content_type="text/html")
async def drawings(request):
with open("templates/drawings.html", "r") as f:
template = f.read()
html_content = pystache.render(template, {"port": sio_port, "version": blenderbim_version})
html_content = pystache.render(template, {"port": sio_port, "version": bonsai_version})
return web.Response(text=html_content, content_type="text/html")
+5 -5
View File
@@ -110,7 +110,7 @@ class Web(bonsai.core.tool.Web):
py_version = sys.version_info
if bpy.app.version >= (4, 2, 0):
blenderbim_lib_path = (
bonsai_lib_path = (
Path(bpy.utils.user_resource("EXTENSIONS"))
/ ".local"
/ "lib"
@@ -119,12 +119,12 @@ class Web(bonsai.core.tool.Web):
)
else:
addon = [a for a in addon_utils.modules() if a.bl_info["name"] == "Bonsai"][0]
blenderbim_path = os.path.dirname(addon.__file__)
blenderbim_lib_path = os.path.join(blenderbim_path, "libs", "site", "packages")
bonsai_path = os.path.dirname(addon.__file__)
bonsai_lib_path = os.path.join(bonsai_path, "libs", "site", "packages")
env = os.environ.copy()
env["BLENDERBIM_LIB_PATH"] = str(blenderbim_lib_path)
env["BLENDERBIM_VERSION"] = tool.Blender.get_bonsai_version()
env["BONSAI_LIB_PATH"] = str(bonsai_lib_path)
env["BONSAI_VERSION"] = tool.Blender.get_bonsai_version()
ws_process = subprocess.Popen(
[sys.executable, ws_path, "--p", str(port), "--host", "127.0.0.1"],