mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
BBIM error handler - include commit hash
Include commit hash to the copied logs and add it to the startup error handler (https://imgur.com/9yVMBnR)
This commit is contained in:
@@ -305,7 +305,7 @@ ifeq ($(IS_STABLE), TRUE)
|
||||
else
|
||||
cd dist/blenderbim && $(SED) "s/0, 0, 0/$(VERSION_MAJOR), $(VERSION_MINOR), $(VERSION_PATCH), $(VERSION_DATE)/" __init__.py
|
||||
cd dist/blenderbim && $(SED) "s/0.0.0/$(VERSION).$(VERSION_DATE)/" blender_manifest.toml
|
||||
cd dist/blenderbim/bim && $(SED) "s/8888888/$(LAST_COMMIT_HASH)/" __init__.py
|
||||
cd dist/blenderbim && $(SED) "s/8888888/$(LAST_COMMIT_HASH)/" __init__.py
|
||||
cd dist && zip -r blenderbim-$(VERSION).$(VERSION_DATE)-$(PYVERSION)-$(PLATFORM).zip ./*
|
||||
endif
|
||||
rm -rf dist/blenderbim
|
||||
|
||||
@@ -32,6 +32,9 @@ import platform
|
||||
import traceback
|
||||
import webbrowser
|
||||
from collections import deque
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
|
||||
# NOTE: bl_info is superseded by blender_manifest.toml
|
||||
# if addon is installed as an extension (Blender 4.2+)
|
||||
@@ -47,6 +50,18 @@ bl_info = {
|
||||
"category": "System",
|
||||
}
|
||||
|
||||
last_commit_hash = "8888888"
|
||||
|
||||
|
||||
def get_last_commit_hash() -> Union[str, None]:
|
||||
# Using this weird way to write 8888888,
|
||||
# so makefile won't accidentally replace it here
|
||||
# we'll be able to distinguish commit hash from placeholder value.
|
||||
if last_commit_hash == str(8_888888):
|
||||
return None
|
||||
return last_commit_hash[:7]
|
||||
|
||||
|
||||
last_error = None
|
||||
last_actions: deque = deque(maxlen=10)
|
||||
|
||||
@@ -62,6 +77,7 @@ def get_debug_info():
|
||||
][0]
|
||||
]
|
||||
)
|
||||
|
||||
return {
|
||||
"os": platform.system(),
|
||||
"os_version": platform.version(),
|
||||
@@ -71,6 +87,7 @@ def get_debug_info():
|
||||
"processor": platform.processor(),
|
||||
"blender_version": bpy.app.version_string,
|
||||
"blenderbim_version": version,
|
||||
"blenderbim_commit_hash": get_last_commit_hash(),
|
||||
"last_actions": last_actions,
|
||||
"last_error": last_error,
|
||||
}
|
||||
@@ -93,6 +110,18 @@ if IN_BLENDER:
|
||||
# site.addsitedir(os.path.join(os.path.dirname(os.path.realpath(__file__)), "libs", "site", "packages"))
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "libs", "site", "packages"))
|
||||
|
||||
try:
|
||||
import git
|
||||
|
||||
# We can't just use __file__ as blenderbim/__init__.py is typically not symlinked
|
||||
# as Blender have errors symlinking main addon package file.
|
||||
path = Path(__file__).parent / "bim" / "__init__.py"
|
||||
path = path.resolve().parent
|
||||
repo = git.Repo(str(path), search_parent_directories=True)
|
||||
last_commit_hash = repo.head.object.hexsha
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
import ifcopenshell.api
|
||||
|
||||
@@ -152,7 +181,11 @@ if IN_BLENDER:
|
||||
box = layout.box()
|
||||
py = ".".join(info["python_version"].split(".")[0:2])
|
||||
b3d = ".".join(info["blender_version"].split(".")[0:2])
|
||||
box.label(text="System Information:")
|
||||
box.label(text=f"Blender {b3d} {info['os']} {info['machine']}", icon="BLENDER")
|
||||
blenderbim_version = info["blenderbim_version"]
|
||||
if commit_hash := info.get("blenderbim_commit_hash"):
|
||||
blenderbim_version += f"-{commit_hash}"
|
||||
box.label(text=f"Python {py} BBIM {info['blenderbim_version']}", icon="SCRIPTPLUGINS")
|
||||
layout.operator("bim.copy_debug_information", text="Copy Error Message To Clipboard")
|
||||
op = layout.operator("bim.open_uri", text="How Can I Fix This?")
|
||||
|
||||
@@ -253,17 +253,6 @@ def register():
|
||||
icon_preview.load(icon_name, icon_path, "IMAGE")
|
||||
|
||||
icons = icon_preview
|
||||
|
||||
global last_commit_hash
|
||||
try:
|
||||
import git
|
||||
|
||||
path = Path(__file__).resolve().parent
|
||||
repo = git.Repo(str(path), search_parent_directories=True)
|
||||
last_commit_hash = repo.head.object.hexsha
|
||||
except:
|
||||
pass
|
||||
|
||||
bpy.app.translations.register("blenderbim", translations_dict)
|
||||
|
||||
|
||||
|
||||
@@ -178,8 +178,8 @@ class IfcExporter:
|
||||
][0]
|
||||
]
|
||||
)
|
||||
if blenderbim.bim.last_commit_hash != "8888888":
|
||||
version += f"-{blenderbim.bim.last_commit_hash[:7]}"
|
||||
if commit_hash := tool.Blender.get_last_commit_hash():
|
||||
version += f"-{commit_hash}"
|
||||
return version
|
||||
|
||||
|
||||
|
||||
@@ -909,6 +909,18 @@ class Blender(blenderbim.core.tool.Blender):
|
||||
if child_obj:
|
||||
yield child_obj
|
||||
|
||||
@classmethod
|
||||
def get_last_commit_hash(cls) -> Union[str, None]:
|
||||
"""Get 8 symbols of last commit hash if it's present or return None otherwise."""
|
||||
commit_hash = blenderbim.bim.last_commit_hash
|
||||
|
||||
# Commit hash is unset - user is using __init__ from repo
|
||||
# without setting up git repository.
|
||||
if commit_hash == "8888888":
|
||||
return None
|
||||
|
||||
return commit_hash[:7]
|
||||
|
||||
@classmethod
|
||||
def get_blenderbim_version(cls):
|
||||
version = ".".join(
|
||||
@@ -921,8 +933,8 @@ class Blender(blenderbim.core.tool.Blender):
|
||||
][0]
|
||||
]
|
||||
)
|
||||
if blenderbim.bim.last_commit_hash != "8888888":
|
||||
version += f"-{blenderbim.bim.last_commit_hash[:7]}"
|
||||
if commit_hash := cls.get_last_commit_hash():
|
||||
version += f"-{commit_hash}"
|
||||
return version
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user