Skip to content

Commit

Permalink
bugfixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Baintner committed Jul 25, 2024
1 parent 433f429 commit bc0c2c7
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 65 deletions.
4 changes: 4 additions & 0 deletions custom_commands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
"""Insert your commands here."""
import bpy
from utils_common import print_utils

# Insert your code below.


print_utils.print_info("Custom commands executed.")
108 changes: 50 additions & 58 deletions renderrob.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,65 +287,58 @@ def _handle_output(self):
data = self.process.readAll()
output = data.data().decode()
color_format = QTextCharFormat()
if '\u001b' in output:
for line in output.splitlines():
back_color = print_utils.BASH_COLORS
info = back_color["BACK_CYAN"] + " " + back_color["FORE_BLACK"]
warning = back_color["BACK_YELLOW"] + " " + back_color["FORE_BLACK"]
error = back_color["BACK_RED"] + " " + back_color["FORE_WHITE"]
reset = back_color["RESET_ALL"]
if line.startswith(reset):
line = line.replace(reset, '')
color_format.setBackground(QColor(table_utils.COLORS["grey_light"]))
color_format.setForeground(QColor(table_utils.COLORS["grey_light"]))
if line.startswith(info):
line = line.replace(info, '')
color_format.setBackground(
QColor(table_utils.COLORS["blue_grey_lighter"]))
color_format.setForeground(QColor(Qt.black))
if line.startswith(warning):
line = line.replace(warning, '')
color_format.setBackground(QColor(table_utils.COLORS["yellow"]))
color_format.setForeground(QColor(Qt.black))

self.state_saver.table_to_state(self.table)
row_number = state_saver.find_job(
self.state_saver.state.render_jobs, self.active_render_job)

table_utils.color_row_background(self.table,
row_number,
QColor(table_utils.COLORS["yellow"]))
if line.startswith(error) or "blender.crash.txt" in line:
line = line.replace(error, '')
color_format.setBackground(QColor(table_utils.COLORS["red"]))
color_format.setForeground(QColor(table_utils.COLORS["grey_light"]))

self.state_saver.table_to_state(self.table)
row_number = state_saver.find_job(
self.state_saver.state.render_jobs, self.active_render_job)

table_utils.color_row_background(self.table,
row_number,
QColor(table_utils.COLORS["red"]))

# Only scroll down if user is at bottom.
if self.window.textBrowser.verticalScrollBar().value() > (
self.window.textBrowser.verticalScrollBar().maximum()) - 1500:
self.window.textBrowser.moveCursor(QTextCursor.End + 1)
self.window.textBrowser.setCurrentCharFormat(color_format)
self.window.textBrowser.insertPlainText(line.replace(reset, "") + "\n")

if line.endswith(reset):
line = line.replace(reset, '')
color_format.setBackground(QColor(52, 80, 100))
color_format.setForeground(QColor(table_utils.COLORS["grey_light"]))
else:
back_color = print_utils.BASH_COLORS
info = back_color["BACK_CYAN"] + " " + back_color["FORE_BLACK"]
warning = back_color["BACK_YELLOW"] + " " + back_color["FORE_BLACK"]
error = back_color["BACK_RED"] + " " + back_color["FORE_WHITE"]
reset = back_color["RESET_ALL"]
for line in output.splitlines():

if line.startswith(reset):
line = line.replace(reset, '')
color_format.setBackground(QColor(table_utils.COLORS["grey_light"]))
color_format.setForeground(QColor(table_utils.COLORS["grey_light"]))
if line.startswith(info):
line = line.replace(info, '')
color_format.setBackground(
QColor(table_utils.COLORS["blue_grey_lighter"]))
color_format.setForeground(QColor(Qt.black))
if line.startswith(warning):
line = line.replace(warning, '')
color_format.setBackground(QColor(table_utils.COLORS["yellow"]))
color_format.setForeground(QColor(Qt.black))

self.state_saver.table_to_state(self.table)
row_number = state_saver.find_job(
self.state_saver.state.render_jobs, self.active_render_job)

table_utils.color_row_background(self.table,
row_number,
QColor(table_utils.COLORS["yellow"]))
if line.startswith(error) or "blender.crash.txt" in line or line.startswith("Error:"):
line = line.replace(error, '')
color_format.setBackground(QColor(table_utils.COLORS["red"]))
color_format.setForeground(QColor(table_utils.COLORS["grey_light"]))

self.state_saver.table_to_state(self.table)
row_number = state_saver.find_job(
self.state_saver.state.render_jobs, self.active_render_job)

table_utils.color_row_background(self.table,
row_number,
QColor(table_utils.COLORS["red"]))

# Only scroll down if user is at bottom.
if self.window.textBrowser.verticalScrollBar().value() > (
self.window.textBrowser.verticalScrollBar().maximum()) - 1500:
self.window.textBrowser.verticalScrollBar().maximum()) - 1000:
self.window.textBrowser.moveCursor(QTextCursor.End)
self.window.textBrowser.setCurrentCharFormat(color_format)
self.window.textBrowser.insertPlainText(output)
self.window.textBrowser.insertPlainText(line.replace(reset, "") + "\n")

if line.endswith(reset):
line = line.replace(reset, '')
color_format.setBackground(QColor(52, 80, 100))
color_format.setForeground(QColor(table_utils.COLORS["grey_light"]))

# Find a more elegant way to do this.
if "Blender quit" in output:
Expand Down Expand Up @@ -689,15 +682,14 @@ def render_job(self, job: state_pb2.render_job) -> None: # pylint: disable=no-m
# Check if the file was converted to a relative path.
file_path = path_utils.get_abs_blend_path(
job.file, self.state_saver.state.settings.blender_files_path)
scene_command = f"-S {job.scene}" if job.scene else ""
scene_command = ["-S", job.scene] if job.scene else []
args = ["-b", file_path,
scene_command,
*scene_command,
"-o", snb.frame_path,
"-y",
"-F", ui_utils.FILE_FORMATS_COMMAND[job.file_format],
"--python-expr", inline_python,
]
args = [i for i in args if i]
args.extend(render_frame_command.split(" "))
self.process.setArguments(args)
# self.process.readyReadStandardOutput.connect(self._handle_output)
Expand Down
5 changes: 4 additions & 1 deletion utils_rr/table_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"blue_grey": 0x4f7997,
"blue_grey_darker": 0x345064,
"grey_light": 0x323639,
"grey_inactive": 0x2d2d2d,
"grey_inactive": 0x2b2b2b,
"grey_neutral": 0x222222,
"black_light": 0x22282b,
"black_dark": 0x242a2d,
Expand Down Expand Up @@ -295,6 +295,9 @@ def color_row_background(table_widget: QTableWidget, row_index: int, base_color:
if column_index in ui_utils.CHECKBOX_COLUMNS:
ui_utils.set_checkbox_background_color(
table_widget, row_index, column_index, color)
# if column_index in ui_utils.COMBOBOX_COLUMNS:
# ui_utils.set_combobox_background_color(
# table_widget, row_index, column_index, color)

# Check if the value in the numbers columns is valid.
if item and item.text() and (
Expand Down
11 changes: 5 additions & 6 deletions utils_rr/ui_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,12 @@ def set_checkbox_values(table: QTableWidget, row: int, values: list[bool]) -> No
checkbox_item.blockSignals(False)


def set_combobox_background_color(table: QTableWidget, row: int, color: QColor) -> None:
def set_combobox_background_color(table: QTableWidget, row: int, col: int, color: QColor) -> None:
"""Set color of comboboxes."""
for i in COMBOBOX_COLUMNS:
widget = table.cellWidget(row, i)
if widget:
widget.setStyleSheet(
f"QComboBox:drop-down {{background-color: {color.name()};}}")
widget = table.cellWidget(row, col)
if widget:
widget.setStyleSheet(
f"QComboBox:drop-down {{background-color: {color.name()};}}")


def set_checkbox_background_color(table: QTableWidget, row: int, col: int, color: QColor) -> None:
Expand Down

0 comments on commit bc0c2c7

Please sign in to comment.