Raise exception if file does not exist
This commit is contained in:
+13
-5
@@ -24,14 +24,22 @@ class RunwareLoadMesh:
|
||||
RETURN_NAMES = ("Base64",)
|
||||
FUNCTION = "load_mesh"
|
||||
CATEGORY = "Runware"
|
||||
DESCRIPTION = "Load a 3D model file from a path or via upload. Base64 encodes and outputs as data URI. Connect to Runware 3D Inference Inputs meshFile."
|
||||
DESCRIPTION = "Load a 3D model file from a path or entering a path. Base64 encodes and outputs as data URI. Connect to Runware 3D Inference Inputs meshFile."
|
||||
|
||||
def load_mesh(self, file_path):
|
||||
if not file_path or not isinstance(file_path, str) or not file_path.strip():
|
||||
return ("",)
|
||||
full_path = os.path.expanduser(file_path.strip())
|
||||
if not os.path.isfile(full_path) or os.path.splitext(full_path)[1].lower() not in self.MESH_EXTENSIONS:
|
||||
path = (file_path or "").strip() if isinstance(file_path, str) else ""
|
||||
if not path:
|
||||
return ("",)
|
||||
full_path = os.path.expanduser(path)
|
||||
ext = os.path.splitext(full_path)[1].lower()
|
||||
if ext not in self.MESH_EXTENSIONS:
|
||||
raise ValueError(
|
||||
f"Runware Load Mesh: unsupported extension '{ext}'. Expected .glb or .ply."
|
||||
)
|
||||
if not os.path.isfile(full_path):
|
||||
raise FileNotFoundError(
|
||||
f"Runware Load Mesh: file not found: {full_path}"
|
||||
)
|
||||
with open(full_path, 'rb') as f:
|
||||
mesh_bytes = f.read()
|
||||
mesh_base64 = base64.b64encode(mesh_bytes).decode('utf-8')
|
||||
|
||||
@@ -17,7 +17,7 @@ class threeDInferenceInputs:
|
||||
}),
|
||||
"meshFile": ("STRING", {
|
||||
"default": "",
|
||||
"tooltip": "Base64 data URI of mesh file (.glb or .ply) from Runware Load Mesh, or media UUID from Runware Media Upload.",
|
||||
"tooltip": "Base64 data URI of mesh file (.glb or .ply) from Runware Load Mesh.",
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user