Skip to content

Commit c38b80e

Browse files
authored
Update BatchRender.py
1 parent de6a848 commit c38b80e

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

BatchRender.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def handle_stdout(line):
275275
check_frame_status(line)
276276
global error_detected # We will track if an error occurred
277277
# You can add logic here to search for specific error keywords in the stdout output
278-
if "error" in line.lower(): # Check for errors in the output (adjust as needed)
278+
if "error" in line.lower() and "the specified module could not be found" not in line.lower(): # Check for errors in the output (adjust as needed)
279279
error_detected = True
280280
else:
281281
# Call a function to update progress bar if no error
@@ -288,8 +288,10 @@ def handle_stderr(line):
288288
output_text.yview(tk.END)
289289
global error_detected # We will track if an error occurred
290290
# You can add logic here to handle errors from stderr as well
291-
if "error" in line.lower(): # Check for errors in the stderr output (adjust as needed)
291+
if "error" in line.lower() and "the specified module could not be found" not in line.lower(): # Check for errors in the stderr output (adjust as needed)
292292
error_detected = True
293+
else:
294+
return
293295

294296
def check_frame_status(output_line):
295297
# Check if a frame started rendering
@@ -302,7 +304,7 @@ def check_frame_status(output_line):
302304
# For reuse rendering, check if "Frame: X" pattern is in the output
303305
if switch.get() == 1:
304306
# Look for the actual frame rendering line "Frame: X" (where X is the frame number)
305-
frame_match = re.search(r"Frame: (\d+)", output_line)
307+
frame_match = re.search(r"Frame: (\d+)", output_line) or re.search(r"Rendering frame (\d+)", output_line)
306308

307309
if frame_match:
308310
# Set the flag to True once we detect actual rendering frames
@@ -398,7 +400,23 @@ def update_progress(output_line, progressbar):
398400
# print(f"Updated progress to {progress}")
399401
except ValueError:
400402
pass # Handle the case where the conversion to int fail
401-
403+
# elif "Block" in output_line and "rendered by GPU" in output_line:
404+
elif "Block" in output_line:
405+
# try:
406+
407+
# Extract the percentage value
408+
block_info = output_line.split("Block ")[1].split(" ")[0]
409+
current_block, total_blocks = map(int, block_info.split('/'))
410+
# Convert the percentage to a value between 0 and 1
411+
percentage = (current_block / total_blocks) * 100
412+
progress = percentage / 100.0
413+
# Update the progress bar
414+
progressbar.configure(mode="determinate")
415+
progressbar.stop()
416+
progressbar.set(progress)
417+
# print(f"Updated progress to {progress}")
418+
# except ValueError:
419+
# pass # Handle the case where the conversion to int fail
402420
# After completing a frame or when rendering starts, set progress to indeterminate
403421
else:
404422
# If rendering is still in progress (e.g., processing next frame)
@@ -424,7 +442,7 @@ def extract_progress_from_line(line):
424442
# For example, you might use regular expressions to find the progress value
425443
# Customize this based on the format of your render output
426444

427-
progress_match = re.search(r"Progress: (\d+)%", line)
445+
progress_match = re.search(r"Progress: (\d+)%", line)
428446
if progress_match:
429447

430448
return int(progress_match.group(1)) / 100.0

0 commit comments

Comments
 (0)