mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 21:38:51 +00:00
New debug feature to purge HDF5 cache in case the cache is corrupted.
This commit is contained in:
@@ -28,6 +28,7 @@ classes = (
|
|||||||
operator.PrintIfcFile,
|
operator.PrintIfcFile,
|
||||||
operator.PrintObjectPlacement,
|
operator.PrintObjectPlacement,
|
||||||
operator.ProfileImportIFC,
|
operator.ProfileImportIFC,
|
||||||
|
operator.PurgeHdf5Cache,
|
||||||
operator.PurgeIfcLinks,
|
operator.PurgeIfcLinks,
|
||||||
operator.RewindInspector,
|
operator.RewindInspector,
|
||||||
operator.SelectExpressFile,
|
operator.SelectExpressFile,
|
||||||
|
|||||||
@@ -328,3 +328,12 @@ class SelectExpressFile(bpy.types.Operator):
|
|||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
context.window_manager.fileselect_add(self)
|
context.window_manager.fileselect_add(self)
|
||||||
return {"RUNNING_MODAL"}
|
return {"RUNNING_MODAL"}
|
||||||
|
|
||||||
|
|
||||||
|
class PurgeHdf5Cache(bpy.types.Operator):
|
||||||
|
bl_idname = "bim.purge_hdf5_cache"
|
||||||
|
bl_label = "Purge HDF5 Cache"
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
core.purge_hdf5_cache(tool.Debug)
|
||||||
|
return {"FINISHED"}
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ class BIM_PT_debug(Panel):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.operator("bim.print_ifc_file")
|
row.operator("bim.print_ifc_file")
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.operator("bim.purge_hdf5_cache")
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.operator("bim.purge_ifc_links")
|
row.operator("bim.purge_ifc_links")
|
||||||
|
|
||||||
|
|||||||
@@ -19,3 +19,7 @@
|
|||||||
|
|
||||||
def parse_express(debug, filename):
|
def parse_express(debug, filename):
|
||||||
debug.add_schema_identifier(debug.load_express(filename))
|
debug.add_schema_identifier(debug.load_express(filename))
|
||||||
|
|
||||||
|
|
||||||
|
def purge_hdf5_cache(debug):
|
||||||
|
debug.purge_hdf5_cache()
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ class Context:
|
|||||||
class Debug:
|
class Debug:
|
||||||
def add_schema_identifier(cls, schema): pass
|
def add_schema_identifier(cls, schema): pass
|
||||||
def load_express(cls, filename): pass
|
def load_express(cls, filename): pass
|
||||||
|
def purge_hdf5_cache(cls): pass
|
||||||
|
|
||||||
|
|
||||||
@interface
|
@interface
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import os
|
||||||
import bpy
|
import bpy
|
||||||
import ifcopenshell.express
|
import ifcopenshell.express
|
||||||
import blenderbim.core.tool
|
import blenderbim.core.tool
|
||||||
@@ -32,3 +33,10 @@ class Debug(blenderbim.core.tool.Debug):
|
|||||||
schema = ifcopenshell.express.parse(filename)
|
schema = ifcopenshell.express.parse(filename)
|
||||||
ifcopenshell.register_schema(schema)
|
ifcopenshell.register_schema(schema)
|
||||||
return schema
|
return schema
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def purge_hdf5_cache(cls):
|
||||||
|
cache_dir = os.path.join(bpy.context.scene.BIMProperties.data_dir, "cache")
|
||||||
|
filelist = [f for f in os.listdir(cache_dir) if f.endswith(".h5")]
|
||||||
|
for f in filelist:
|
||||||
|
os.remove(os.path.join(cache_dir, f))
|
||||||
|
|||||||
@@ -25,3 +25,9 @@ class TestParseExpress:
|
|||||||
debug.load_express("filename").should_be_called().will_return("schema")
|
debug.load_express("filename").should_be_called().will_return("schema")
|
||||||
debug.add_schema_identifier("schema").should_be_called()
|
debug.add_schema_identifier("schema").should_be_called()
|
||||||
subject.parse_express(debug, "filename")
|
subject.parse_express(debug, "filename")
|
||||||
|
|
||||||
|
|
||||||
|
class TestPurgeHdf5Cache:
|
||||||
|
def test_run(self, debug):
|
||||||
|
debug.purge_hdf5_cache().should_be_called()
|
||||||
|
subject.purge_hdf5_cache(debug)
|
||||||
|
|||||||
@@ -43,3 +43,14 @@ class TestLoadExpress(NewFile):
|
|||||||
schema = subject.load_express(os.path.join(cwd, "..", "files", "test.exp"))
|
schema = subject.load_express(os.path.join(cwd, "..", "files", "test.exp"))
|
||||||
assert schema.schema_name == "IFCROGUE"
|
assert schema.schema_name == "IFCROGUE"
|
||||||
return schema
|
return schema
|
||||||
|
|
||||||
|
|
||||||
|
class TestPurgeHdf5Cache(NewFile):
|
||||||
|
def test_run(self):
|
||||||
|
cache_dir = os.path.join(bpy.context.scene.BIMProperties.data_dir, "cache")
|
||||||
|
test_file = os.path.join(cache_dir, "test.h5")
|
||||||
|
if not os.path.isfile(test_file):
|
||||||
|
fp = open(test_file, "x")
|
||||||
|
fp.close()
|
||||||
|
subject.purge_hdf5_cache()
|
||||||
|
assert not [f for f in os.listdir(cache_dir) if f.endswith(".h5")]
|
||||||
|
|||||||
Reference in New Issue
Block a user