Add ability to ignore system builds

This commit is contained in:
Brett Williams
2025-03-01 00:37:11 -06:00
parent 1af4169447
commit e97e3d74c8
3 changed files with 94 additions and 79 deletions

View File

@@ -184,6 +184,12 @@ class SettingsWindow(QMainWindow):
installed_layout = QVBoxLayout()
self.installed_engines_table = EngineTableWidget()
installed_layout.addWidget(self.installed_engines_table)
engine_ignore_system_installs_checkbox = QCheckBox("Ignore system installs")
engine_ignore_system_installs_checkbox.setChecked(settings.value("engines_ignore_system_installs", False))
engine_ignore_system_installs_checkbox.stateChanged.connect(self.change_ignore_system_installs)
installed_layout.addWidget(engine_ignore_system_installs_checkbox)
installed_buttons_layout = QHBoxLayout()
launch_engine_button = QPushButton("Launch")
launch_engine_button.clicked.connect(self.launch_selected_engine)
@@ -226,7 +232,7 @@ class SettingsWindow(QMainWindow):
self.update_last_checked_label()
self.engines_last_update_label.setEnabled(at_least_one_downloadable)
engine_updates_layout.addWidget(self.engines_last_update_label)
self.check_for_new_engines_button = QPushButton("Check for New Versions")
self.check_for_new_engines_button = QPushButton("Check for New Versions...")
self.check_for_new_engines_button.setEnabled(at_least_one_downloadable)
self.check_for_new_engines_button.clicked.connect(self.check_for_new_engines)
engine_updates_layout.addWidget(self.check_for_new_engines_button)
@@ -239,6 +245,11 @@ class SettingsWindow(QMainWindow):
page.setLayout(layout)
return page
def change_ignore_system_installs(self, value):
settings.setValue("engines_ignore_system_installs", bool(value))
self.installed_engines_table.update_table()
def update_last_checked_label(self):
"""Retrieve the last check timestamp and return a human-friendly string."""
last_checked_str = settings.value("engines_last_update_time", None)
@@ -275,22 +286,27 @@ class SettingsWindow(QMainWindow):
os.path.join(os.path.join(os.path.expanduser(Config.upload_folder),
'engines')))
results = []
ignore_system = settings.value("engines_ignore_system_installs", False)
messagebox_shown = False
for engine in EngineManager.downloadable_engines():
if settings.value(f'engine_download-{engine.name()}', False):
update_result = EngineManager.update_engine(engine)
if update_result:
results.append(update_result)
result = EngineManager.is_engine_update_available(engine, ignore_system_installs=ignore_system)
if result:
result['name'] = engine.name()
msg_box = QMessageBox()
msg_box.setWindowTitle(f"{result['name']} ({result['version']}) Available")
msg_box.setText(f"A new version of {result['name']} is available ({result['version']}).\n\n"
f"Would you like to download it now?")
msg_box.setIcon(QMessageBox.Icon.Information)
msg_box.setStandardButtons(QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
msg_result = msg_box.exec()
messagebox_shown = True
if msg_result == QMessageBox.StandardButton.Yes:
EngineManager.download_engine(engine=engine.name(), version=result['version'], background=True,
ignore_system=ignore_system)
self.update_engine_download_status()
if results:
for result in results:
msg_box = QMessageBox()
msg_box.setWindowTitle(f"{result['name']} {result['version']} Available")
msg_box.setText(f"A new version of {result['name']} is available ({result['version']}). It will begin downloading now.")
msg_box.setIcon(QMessageBox.Icon.Information)
msg_box.setStandardButtons(QMessageBox.StandardButton.Ok)
msg_box.exec()
else:
if not messagebox_shown:
msg_box = QMessageBox()
msg_box.setWindowTitle("No Updates Available")
msg_box.setText("All your render engines are up-to-date.")
@@ -299,7 +315,16 @@ class SettingsWindow(QMainWindow):
msg_box.exec()
settings.setValue("engines_last_update_time", datetime.now().isoformat())
self.update_last_checked_label()
self.update_engine_download_status()
def update_engine_download_status(self):
running_tasks = [x for x in EngineManager.download_tasks if x.is_alive()]
if not running_tasks:
self.update_last_checked_label()
return
self.engines_last_update_label.setText(f"Downloading {running_tasks[0].engine} ({running_tasks[0].version})...")
class EngineTableWidget(QWidget):
def __init__(self):
@@ -315,20 +340,26 @@ class EngineTableWidget(QWidget):
layout = QVBoxLayout(self)
layout.addWidget(self.table)
self.raw_server_data = None
def showEvent(self, event):
"""Runs when the widget is about to be shown."""
self.update_table()
super().showEvent(event) # Ensure normal event processing
def update_table(self):
raw_server_data = RenderServerProxy(socket.gethostname()).get_renderer_info()
if not raw_server_data:
def update_table(self, use_cached=True):
if not self.raw_server_data or not use_cached:
self.raw_server_data = RenderServerProxy(socket.gethostname()).get_renderer_info()
if not self.raw_server_data:
return
table_data = [] # convert the data into a flat list
for _, engine_data in raw_server_data.items():
for _, engine_data in self.raw_server_data.items():
table_data.extend(engine_data['versions'])
if settings.value("engines_ignore_system_installs", False):
table_data = [x for x in table_data if x['type'] != 'system']
self.table.clear()
self.table.setRowCount(len(table_data))
self.table.setColumnCount(4)
@@ -364,6 +395,7 @@ class EngineTableWidget(QWidget):
return data
if __name__ == "__main__":
app = QApplication([])
window = SettingsWindow()