App: Simplify and fix code for ifcopenshell version check
This commit is contained in:
@@ -3702,24 +3702,23 @@ void Application::getVerboseCommonInfo(QTextStream& str, const std::map<std::str
|
||||
#endif
|
||||
str << "xerces-c " << fcXercescVersion << ", ";
|
||||
|
||||
const char* cmd = "import ifcopenshell\n"
|
||||
"version = ifcopenshell.version";
|
||||
PyObject * ifcopenshellVer = nullptr;
|
||||
|
||||
try {
|
||||
ifcopenshellVer = Base::Interpreter().getValue(cmd, "version");
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().log("%s (safe to ignore, unless using the BIM workbench and IFC).\n", e.what());
|
||||
}
|
||||
|
||||
if (ifcopenshellVer) {
|
||||
const char* ifcopenshellVerAsStr = PyUnicode_AsUTF8(ifcopenshellVer);
|
||||
|
||||
if (ifcopenshellVerAsStr) {
|
||||
str << "IfcOpenShell " << ifcopenshellVerAsStr << ", ";
|
||||
Base::PyGILStateLocker lock;
|
||||
Py::Module module(PyImport_ImportModule("ifcopenshell"), true);
|
||||
if (!module.isNull() && module.hasAttr("version")) {
|
||||
Py::String version(module.getAttr("version"));
|
||||
auto ver_str = static_cast<std::string>(version);
|
||||
str << "IfcOpenShell " << ver_str.c_str() << ", ";
|
||||
}
|
||||
Py_DECREF(ifcopenshellVer);
|
||||
else {
|
||||
Base::Console().log("Module 'ifcopenshell' not found (safe to ignore, unless using "
|
||||
"the BIM workbench and IFC).\n");
|
||||
}
|
||||
}
|
||||
catch (const Py::Exception&) {
|
||||
Base::PyGILStateLocker lock;
|
||||
Base::PyException e;
|
||||
Base::Console().log("%s\n", e.what());
|
||||
}
|
||||
|
||||
#if defined(HAVE_OCC_VERSION)
|
||||
|
||||
Reference in New Issue
Block a user