mirror of
https://github.com/blw1138/Zordon.git
synced 2026-04-25 13:54:55 -05:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f9b19587ba | |||
| 4704806472 | |||
| daf445ee9e | |||
| 574c6f0755 | |||
| 6bfa5629d5 | |||
| 05cd0470dd | |||
| 7827f73530 | |||
| 562cb23da3 | |||
| 6b68d42b93 | |||
| cdf4b2bbe1 | |||
| dc8f4d3e2a | |||
| 2548280dcc | |||
| 98ab837057 | |||
| 3fda87935e | |||
| e35a5a689c | |||
| dea7574888 | |||
| a19db9fcf7 | |||
| 80b0adb2ad | |||
| 18873cec6f |
@@ -0,0 +1,11 @@
|
|||||||
|
[flake8]
|
||||||
|
exclude =
|
||||||
|
src/engines/aerender
|
||||||
|
.git
|
||||||
|
build
|
||||||
|
dist
|
||||||
|
*.egg
|
||||||
|
venv
|
||||||
|
.venv
|
||||||
|
max-complexity = 10
|
||||||
|
max-line-length = 127
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
name: Create Executables
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
release:
|
||||||
|
- types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pyinstaller-build-windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Create Executables (Windows)
|
||||||
|
uses: sayyid5416/pyinstaller@v1
|
||||||
|
with:
|
||||||
|
python_ver: '3.11'
|
||||||
|
spec: 'client.spec'
|
||||||
|
requirements: 'requirements.txt'
|
||||||
|
upload_exe_with_name: 'Zordon'
|
||||||
|
pyinstaller-build-linux:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Create Executables (Linux)
|
||||||
|
uses: sayyid5416/pyinstaller@v1
|
||||||
|
with:
|
||||||
|
python_ver: '3.11'
|
||||||
|
spec: 'client.spec'
|
||||||
|
requirements: 'requirements.txt'
|
||||||
|
upload_exe_with_name: 'Zordon'
|
||||||
|
pyinstaller-build-macos:
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- name: Create Executables (macOS)
|
||||||
|
uses: sayyid5416/pyinstaller@v1
|
||||||
|
with:
|
||||||
|
python_ver: '3.11'
|
||||||
|
spec: 'client.spec'
|
||||||
|
requirements: 'requirements.txt'
|
||||||
|
upload_exe_with_name: 'Zordon'
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
name: Create Executable (Windows)
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
release:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
pyinstaller-build:
|
|
||||||
runs-on: windows-latest
|
|
||||||
steps:
|
|
||||||
- name: Create Executable (Windows)
|
|
||||||
uses: sayyid5416/pyinstaller@v1
|
|
||||||
with:
|
|
||||||
python_ver: '3.11'
|
|
||||||
spec: 'main.spec'
|
|
||||||
requirements: 'requirements.txt'
|
|
||||||
upload_exe_with_name: 'Zordon'
|
|
||||||
@@ -34,6 +34,7 @@ jobs:
|
|||||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||||
- name: Test with pytest
|
continue-on-error: false
|
||||||
run: |
|
# - name: Test with pytest
|
||||||
pytest
|
# run: |
|
||||||
|
# pytest
|
||||||
|
|||||||
@@ -6,3 +6,11 @@
|
|||||||
/dist/
|
/dist/
|
||||||
/build/
|
/build/
|
||||||
/.github/
|
/.github/
|
||||||
|
*.idea
|
||||||
|
.DS_Store
|
||||||
|
/venv/
|
||||||
|
.env
|
||||||
|
venv/
|
||||||
|
/.eggs/
|
||||||
|
/.ai/
|
||||||
|
/.github/
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
[MASTER]
|
[MASTER]
|
||||||
max-line-length = 120
|
max-line-length = 120
|
||||||
|
ignore-paths=^src/engines/aerender/
|
||||||
[MESSAGES CONTROL]
|
[MESSAGES CONTROL]
|
||||||
disable = missing-docstring, invalid-name, import-error, logging-fstring-interpolation
|
disable = missing-docstring, invalid-name, import-error, logging-fstring-interpolation
|
||||||
@@ -1,6 +1,15 @@
|
|||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
# Zordon
|
# Zordon
|
||||||
|
|
||||||
A tool designed for small render farms, such as those used in home studios or small businesses, to efficiently manage and run render jobs for Blender, FFMPEG, and other video renderers. It simplifies the process of distributing rendering tasks across multiple available machines, optimizing the rendering workflow for artists, animators, and video professionals.
|
A lightweight, zero-install, distributed rendering and management tool designed to streamline and optimize rendering workflows across multiple machines
|
||||||
|
|
||||||
|
## What is Zordon?
|
||||||
|
|
||||||
|
Zordon is tool designed for small render farms, such as those used in home studios or small businesses, to efficiently manage and run render jobs for Blender, FFMPEG, and other video renderers. It simplifies the process of distributing rendering tasks across multiple available machines, optimizing the rendering workflow for artists, animators, and video professionals.
|
||||||
|
|
||||||
|
|
||||||
Notice: This should be considered a beta and is meant for casual / hobbiest use. Do not use in mission critical environments!
|
Notice: This should be considered a beta and is meant for casual / hobbiest use. Do not use in mission critical environments!
|
||||||
|
|
||||||
|
|||||||
+120
@@ -0,0 +1,120 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
|
from server import start_server
|
||||||
|
from src.api.serverproxy_manager import ServerProxyManager
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Zordon CLI tool for preparing/submitting a render job",
|
||||||
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
||||||
|
)
|
||||||
|
|
||||||
|
# Required arguments
|
||||||
|
parser.add_argument("scene_file", help="Path to the scene file (e.g., .blend, .max, .mp4)")
|
||||||
|
parser.add_argument("engine", help="Desired render engine", choices=['blender', 'ffmpeg'])
|
||||||
|
|
||||||
|
# Frame range
|
||||||
|
parser.add_argument("--start", type=int, default=1, help="Start frame")
|
||||||
|
parser.add_argument("--end", type=int, default=1, help="End frame")
|
||||||
|
|
||||||
|
# Job metadata
|
||||||
|
parser.add_argument("--name", default=None, help="Job name")
|
||||||
|
|
||||||
|
# Output
|
||||||
|
parser.add_argument("--output", default="", help="Output path/pattern (e.g., /renders/frame_####.exr)")
|
||||||
|
|
||||||
|
# Target OS and Engine Version
|
||||||
|
parser.add_argument(
|
||||||
|
"--os",
|
||||||
|
choices=["any", "windows", "linux", "macos"],
|
||||||
|
default="any",
|
||||||
|
help="Target operating system for render workers"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--engine-version",
|
||||||
|
default="latest",
|
||||||
|
help="Required renderer/engine version number (e.g., '4.2', '5.0')"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Optional flags
|
||||||
|
parser.add_argument("--dry-run", action="store_true", help="Print job details without submitting")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Basic validation
|
||||||
|
if not os.path.exists(args.scene_file):
|
||||||
|
print(f"Error: Scene file '{args.scene_file}' not found!", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if args.start > args.end:
|
||||||
|
print("Error: Start frame cannot be greater than end frame!", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Calculate total frames
|
||||||
|
total_frames = len(range(args.start, args.end + 1))
|
||||||
|
job_name = args.name or os.path.basename(args.scene_file)
|
||||||
|
file_path = os.path.abspath(args.scene_file)
|
||||||
|
|
||||||
|
# Print job summary
|
||||||
|
print("Render Job Summary:")
|
||||||
|
print(f" Job Name : {job_name}")
|
||||||
|
print(f" Scene File : {file_path}")
|
||||||
|
print(f" Engine : {args.engine}")
|
||||||
|
print(f" Frames : {args.start}-{args.end} → {total_frames} frames")
|
||||||
|
print(f" Output Path : {args.output or '(default from scene)'}")
|
||||||
|
print(f" Target OS : {args.os}")
|
||||||
|
print(f" Engine Version : {args.engine_version}")
|
||||||
|
|
||||||
|
if args.dry_run:
|
||||||
|
print("\nDry run complete (no submission performed).")
|
||||||
|
return
|
||||||
|
|
||||||
|
local_hostname = socket.gethostname()
|
||||||
|
local_hostname = local_hostname + (".local" if not local_hostname.endswith(".local") else "")
|
||||||
|
found_proxy = ServerProxyManager.get_proxy_for_hostname(local_hostname)
|
||||||
|
|
||||||
|
is_connected = found_proxy.check_connection()
|
||||||
|
if not is_connected:
|
||||||
|
local_server_thread = threading.Thread(target=start_server, args=[True], daemon=True)
|
||||||
|
local_server_thread.start()
|
||||||
|
while not is_connected:
|
||||||
|
# todo: add timeout
|
||||||
|
# is_connected = found_proxy.check_connection()
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
new_job = {"name": job_name, "engine": args.engine}
|
||||||
|
response = found_proxy.post_job_to_server(file_path, [new_job])
|
||||||
|
if response and response.ok:
|
||||||
|
print(f"Uploaded to {found_proxy.hostname} successfully!")
|
||||||
|
running_job_data = response.json()[0]
|
||||||
|
job_id = running_job_data.get('id')
|
||||||
|
print(f"Job {job_id} Summary:")
|
||||||
|
print(f" Status : {running_job_data.get('status')}")
|
||||||
|
print(f" Engine : {running_job_data.get('engine')}-{running_job_data.get('engine_version')}")
|
||||||
|
|
||||||
|
print("\nWaiting for render to complete...")
|
||||||
|
percent_complete = 0.0
|
||||||
|
while percent_complete < 1.0:
|
||||||
|
# add checks for errors
|
||||||
|
time.sleep(1)
|
||||||
|
running_job_data = found_proxy.get_job_info(job_id)
|
||||||
|
percent_complete = running_job_data['percent_complete']
|
||||||
|
sys.stdout.write("\x1b[1A") # Move up 1
|
||||||
|
sys.stdout.write("\x1b[0J") # Clear from cursor to end of screen (optional)
|
||||||
|
print(f"Percent Complete: {percent_complete:.2%}")
|
||||||
|
sys.stdout.flush()
|
||||||
|
print("Finished rendering successfully!")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import logging
|
||||||
|
import threading
|
||||||
|
from collections import deque
|
||||||
|
|
||||||
|
from server import start_server
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
def __setup_buffer_handler():
|
||||||
|
# lazy load GUI frameworks
|
||||||
|
from PyQt6.QtCore import QObject, pyqtSignal
|
||||||
|
|
||||||
|
class BufferingHandler(logging.Handler, QObject):
|
||||||
|
new_record = pyqtSignal(str)
|
||||||
|
|
||||||
|
def __init__(self, capacity=100):
|
||||||
|
logging.Handler.__init__(self)
|
||||||
|
QObject.__init__(self)
|
||||||
|
self.buffer = deque(maxlen=capacity) # Define a buffer with a fixed capacity
|
||||||
|
|
||||||
|
def emit(self, record):
|
||||||
|
try:
|
||||||
|
msg = self.format(record)
|
||||||
|
self.buffer.append(msg) # Add message to the buffer
|
||||||
|
self.new_record.emit(msg) # Emit signal
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_buffer(self):
|
||||||
|
return list(self.buffer) # Return a copy of the buffer
|
||||||
|
|
||||||
|
buffer_handler = BufferingHandler()
|
||||||
|
buffer_handler.setFormatter(logging.getLogger().handlers[0].formatter)
|
||||||
|
new_logger = logging.getLogger()
|
||||||
|
new_logger.addHandler(buffer_handler)
|
||||||
|
return buffer_handler
|
||||||
|
|
||||||
|
|
||||||
|
def __show_gui(buffer_handler):
|
||||||
|
# lazy load GUI frameworks
|
||||||
|
from PyQt6.QtWidgets import QApplication
|
||||||
|
|
||||||
|
# load application
|
||||||
|
app: QApplication = QApplication(sys.argv)
|
||||||
|
if app.style().objectName() != 'macos':
|
||||||
|
app.setStyle('Fusion')
|
||||||
|
|
||||||
|
# configure main window
|
||||||
|
from src.ui.main_window import MainWindow
|
||||||
|
window: MainWindow = MainWindow()
|
||||||
|
window.buffer_handler = buffer_handler
|
||||||
|
window.show()
|
||||||
|
|
||||||
|
return app.exec()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import sys
|
||||||
|
|
||||||
|
local_server_thread = threading.Thread(target=start_server, args=[True], daemon=True)
|
||||||
|
local_server_thread.start()
|
||||||
|
__show_gui(__setup_buffer_handler())
|
||||||
|
sys.exit()
|
||||||
@@ -5,8 +5,10 @@ from PyInstaller.utils.hooks import collect_all
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import platform
|
import platform
|
||||||
sys.path.insert(0, os.path.abspath('.'))
|
src_path = os.path.abspath("src")
|
||||||
|
sys.path.insert(0, src_path)
|
||||||
from version import APP_NAME, APP_VERSION, APP_AUTHOR
|
from version import APP_NAME, APP_VERSION, APP_AUTHOR
|
||||||
|
sys.path.insert(0, os.path.abspath('.'))
|
||||||
|
|
||||||
datas = [('resources', 'resources'), ('src/engines/blender/scripts/', 'src/engines/blender/scripts')]
|
datas = [('resources', 'resources'), ('src/engines/blender/scripts/', 'src/engines/blender/scripts')]
|
||||||
binaries = []
|
binaries = []
|
||||||
@@ -16,7 +18,7 @@ datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
|
|||||||
|
|
||||||
|
|
||||||
a = Analysis(
|
a = Analysis(
|
||||||
['main.py'],
|
['client.py'],
|
||||||
pathex=[],
|
pathex=[],
|
||||||
binaries=binaries,
|
binaries=binaries,
|
||||||
datas=datas,
|
datas=datas,
|
||||||
@@ -26,7 +28,7 @@ a = Analysis(
|
|||||||
runtime_hooks=[],
|
runtime_hooks=[],
|
||||||
excludes=[],
|
excludes=[],
|
||||||
noarchive=False,
|
noarchive=False,
|
||||||
optimize=0,
|
optimize=1, # fyi: optim level 2 breaks on windows
|
||||||
)
|
)
|
||||||
pyz = PYZ(a.pure)
|
pyz = PYZ(a.pure)
|
||||||
|
|
||||||
@@ -40,7 +42,7 @@ if platform.system() == 'Darwin': # macOS
|
|||||||
name=APP_NAME,
|
name=APP_NAME,
|
||||||
debug=False,
|
debug=False,
|
||||||
bootloader_ignore_signals=False,
|
bootloader_ignore_signals=False,
|
||||||
strip=False,
|
strip=True,
|
||||||
upx=True,
|
upx=True,
|
||||||
console=False,
|
console=False,
|
||||||
disable_windowed_traceback=False,
|
disable_windowed_traceback=False,
|
||||||
@@ -55,7 +57,7 @@ if platform.system() == 'Darwin': # macOS
|
|||||||
a.datas,
|
a.datas,
|
||||||
strip=True,
|
strip=True,
|
||||||
name=f'{APP_NAME}.app',
|
name=f'{APP_NAME}.app',
|
||||||
icon=None,
|
icon='resources/Server.png',
|
||||||
bundle_identifier=None,
|
bundle_identifier=None,
|
||||||
version=APP_VERSION
|
version=APP_VERSION
|
||||||
)
|
)
|
||||||
@@ -87,7 +89,7 @@ elif platform.system() == 'Windows':
|
|||||||
name=APP_NAME,
|
name=APP_NAME,
|
||||||
debug=False,
|
debug=False,
|
||||||
bootloader_ignore_signals=False,
|
bootloader_ignore_signals=False,
|
||||||
strip=False,
|
strip=True,
|
||||||
upx=True,
|
upx=True,
|
||||||
console=False,
|
console=False,
|
||||||
disable_windowed_traceback=False,
|
disable_windowed_traceback=False,
|
||||||
@@ -108,7 +110,7 @@ else: # linux
|
|||||||
name=APP_NAME,
|
name=APP_NAME,
|
||||||
debug=False,
|
debug=False,
|
||||||
bootloader_ignore_signals=False,
|
bootloader_ignore_signals=False,
|
||||||
strip=False,
|
strip=True,
|
||||||
upx=True,
|
upx=True,
|
||||||
console=False,
|
console=False,
|
||||||
disable_windowed_traceback=False,
|
disable_windowed_traceback=False,
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 838 KiB |
+120
@@ -0,0 +1,120 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
|
from server import start_server
|
||||||
|
from src.api.serverproxy_manager import ServerProxyManager
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description="Zordon CLI tool for preparing/submitting a render job",
|
||||||
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
||||||
|
)
|
||||||
|
|
||||||
|
# Required arguments
|
||||||
|
parser.add_argument("scene_file", help="Path to the scene file (e.g., .blend, .max, .mp4)")
|
||||||
|
parser.add_argument("engine", help="Desired render engine", choices=['blender', 'ffmpeg'])
|
||||||
|
|
||||||
|
# Frame range
|
||||||
|
parser.add_argument("--start", type=int, default=1, help="Start frame")
|
||||||
|
parser.add_argument("--end", type=int, default=1, help="End frame")
|
||||||
|
|
||||||
|
# Job metadata
|
||||||
|
parser.add_argument("--name", default=None, help="Job name")
|
||||||
|
|
||||||
|
# Output
|
||||||
|
parser.add_argument("--output", default="", help="Output path/pattern (e.g., /renders/frame_####.exr)")
|
||||||
|
|
||||||
|
# Target OS and Engine Version
|
||||||
|
parser.add_argument(
|
||||||
|
"--os",
|
||||||
|
choices=["any", "windows", "linux", "macos"],
|
||||||
|
default="any",
|
||||||
|
help="Target operating system for render workers"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--engine-version",
|
||||||
|
default="latest",
|
||||||
|
help="Required renderer/engine version number (e.g., '4.2', '5.0')"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Optional flags
|
||||||
|
parser.add_argument("--dry-run", action="store_true", help="Print job details without submitting")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Basic validation
|
||||||
|
if not os.path.exists(args.scene_file):
|
||||||
|
print(f"Error: Scene file '{args.scene_file}' not found!", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if args.start > args.end:
|
||||||
|
print("Error: Start frame cannot be greater than end frame!", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# Calculate total frames
|
||||||
|
total_frames = len(range(args.start, args.end + 1))
|
||||||
|
job_name = args.name or os.path.basename(args.scene_file)
|
||||||
|
file_path = os.path.abspath(args.scene_file)
|
||||||
|
|
||||||
|
# Print job summary
|
||||||
|
print("Render Job Summary:")
|
||||||
|
print(f" Job Name : {job_name}")
|
||||||
|
print(f" Scene File : {file_path}")
|
||||||
|
print(f" Engine : {args.engine}")
|
||||||
|
print(f" Frames : {args.start}-{args.end} → {total_frames} frames")
|
||||||
|
print(f" Output Path : {args.output or '(default from scene)'}")
|
||||||
|
print(f" Target OS : {args.os}")
|
||||||
|
print(f" Engine Version : {args.engine_version}")
|
||||||
|
|
||||||
|
if args.dry_run:
|
||||||
|
print("\nDry run complete (no submission performed).")
|
||||||
|
return
|
||||||
|
|
||||||
|
local_hostname = socket.gethostname()
|
||||||
|
local_hostname = local_hostname + (".local" if not local_hostname.endswith(".local") else "")
|
||||||
|
found_proxy = ServerProxyManager.get_proxy_for_hostname(local_hostname)
|
||||||
|
|
||||||
|
is_connected = found_proxy.check_connection()
|
||||||
|
if not is_connected:
|
||||||
|
local_server_thread = threading.Thread(target=start_server, args=[True], daemon=True)
|
||||||
|
local_server_thread.start()
|
||||||
|
while not is_connected:
|
||||||
|
# todo: add timeout
|
||||||
|
# is_connected = found_proxy.check_connection()
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
new_job = {"name": job_name, "renderer": args.engine}
|
||||||
|
response = found_proxy.post_job_to_server(file_path, [new_job])
|
||||||
|
if response and response.ok:
|
||||||
|
print(f"Uploaded to {found_proxy.hostname} successfully!")
|
||||||
|
running_job_data = response.json()[0]
|
||||||
|
job_id = running_job_data.get('id')
|
||||||
|
print(f"Job {job_id} Summary:")
|
||||||
|
print(f" Status : {running_job_data.get('status')}")
|
||||||
|
print(f" Engine : {running_job_data.get('renderer')}-{running_job_data.get('renderer_version')}")
|
||||||
|
|
||||||
|
print("\nWaiting for render to complete...")
|
||||||
|
percent_complete = 0.0
|
||||||
|
while percent_complete < 1.0:
|
||||||
|
# add checks for errors
|
||||||
|
time.sleep(1)
|
||||||
|
running_job_data = found_proxy.get_job_info(job_id)
|
||||||
|
percent_complete = running_job_data['percent_complete']
|
||||||
|
sys.stdout.write("\x1b[1A") # Move up 1
|
||||||
|
sys.stdout.write("\x1b[0J") # Clear from cursor to end of screen (optional)
|
||||||
|
print(f"Percent Complete: {percent_complete:.2%}")
|
||||||
|
sys.stdout.flush()
|
||||||
|
print("Finished rendering successfully!")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
from src import init
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
import sys
|
|
||||||
sys.exit(init.run())
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[pytest]
|
||||||
|
norecursedirs = src/engines/aerender .git build dist *.egg venv .venv env .env __pycache__ .pytest_cache
|
||||||
+16
-34
@@ -1,38 +1,20 @@
|
|||||||
PyQt6>=6.6.1
|
PyQt6>=6.7.0
|
||||||
psutil>=5.9.8
|
psutil>=5.9.8
|
||||||
requests>=2.31.0
|
requests>=2.32.2
|
||||||
Pillow>=10.2.0
|
Pillow>=10.3.0
|
||||||
PyYAML>=6.0.1
|
PyYAML>=6.0.1
|
||||||
flask>=3.0.2
|
flask>=3.0.3
|
||||||
tqdm>=4.66.2
|
tqdm>=4.66.4
|
||||||
werkzeug>=3.0.1
|
werkzeug>=3.0.3
|
||||||
Pypubsub>=4.0.3
|
Pypubsub>=4.0.3
|
||||||
zeroconf>=0.131.0
|
zeroconf>=0.132.2
|
||||||
SQLAlchemy>=2.0.25
|
SQLAlchemy>=2.0.30
|
||||||
plyer>=2.1.0
|
plyer>=2.1.0
|
||||||
pytz>=2023.3.post1
|
rich>=13.7.1
|
||||||
future>=0.18.3
|
setuptools>=70.0.0
|
||||||
rich>=13.7.0
|
py-cpuinfo>=9.0.0
|
||||||
pytest>=8.0.0
|
requests-toolbelt>=1.0.0
|
||||||
numpy>=1.26.3
|
PyQt6-sip>=13.6.0
|
||||||
setuptools>=69.0.3
|
humanize>=4.12.1
|
||||||
pandas>=2.2.0
|
macholib>=1.16.3
|
||||||
matplotlib>=3.8.2
|
altgraph>=0.17.4
|
||||||
MarkupSafe>=2.1.4
|
|
||||||
dmglib>=0.9.5; sys_platform == 'darwin'
|
|
||||||
python-dateutil>=2.8.2
|
|
||||||
certifi>=2023.11.17
|
|
||||||
shiboken6>=6.6.1
|
|
||||||
Pygments>=2.17.2
|
|
||||||
cycler>=0.12.1
|
|
||||||
contourpy>=1.2.0
|
|
||||||
packaging>=23.2
|
|
||||||
fonttools>=4.47.2
|
|
||||||
Jinja2>=3.1.3
|
|
||||||
pyparsing>=3.1.1
|
|
||||||
kiwisolver>=1.4.5
|
|
||||||
attrs>=23.2.0
|
|
||||||
lxml>=5.1.0
|
|
||||||
click>=8.1.7
|
|
||||||
requests_toolbelt>=1.0.0
|
|
||||||
pyinstaller_versionfile>=2.1.1
|
|
||||||
@@ -1,5 +1,141 @@
|
|||||||
#!/usr/bin/env python3
|
import logging
|
||||||
from init import run
|
import multiprocessing
|
||||||
|
import os
|
||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
|
||||||
|
import cpuinfo
|
||||||
|
import psutil
|
||||||
|
|
||||||
|
from src.api.api_server import API_VERSION
|
||||||
|
from src.api.api_server import start_api_server
|
||||||
|
from src.api.preview_manager import PreviewManager
|
||||||
|
from src.api.serverproxy_manager import ServerProxyManager
|
||||||
|
from src.distributed_job_manager import DistributedJobManager
|
||||||
|
from src.engines.engine_manager import EngineManager
|
||||||
|
from src.render_queue import RenderQueue
|
||||||
|
from src.utilities.config import Config
|
||||||
|
from src.utilities.misc_helper import (get_gpu_info, system_safe_path, current_system_cpu, current_system_os,
|
||||||
|
current_system_os_version, current_system_cpu_brand, check_for_updates)
|
||||||
|
from src.utilities.zeroconf_server import ZeroconfServer
|
||||||
|
from src.version import APP_NAME, APP_VERSION, APP_REPO_NAME, APP_REPO_OWNER
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
def start_server(skip_updates=False) -> int:
|
||||||
|
"""Initializes the application and runs it.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
server_only: Run in server-only CLI mode. Default is False (runs in GUI mode).
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int: The exit status code.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def existing_process(process_name):
|
||||||
|
import psutil
|
||||||
|
current_pid = os.getpid()
|
||||||
|
current_process = psutil.Process(current_pid)
|
||||||
|
for proc in psutil.process_iter(['pid', 'name', 'ppid']):
|
||||||
|
proc_name = proc.info['name'].lower().rstrip('.exe')
|
||||||
|
if proc_name == process_name.lower() and proc.info['pid'] != current_pid:
|
||||||
|
if proc.info['pid'] == current_process.ppid():
|
||||||
|
continue # parent process
|
||||||
|
elif proc.info['ppid'] == current_pid:
|
||||||
|
continue # child process
|
||||||
|
else:
|
||||||
|
return proc # unrelated process
|
||||||
|
return None
|
||||||
|
|
||||||
|
# setup logging
|
||||||
|
logging.basicConfig(format='%(asctime)s: %(levelname)s: %(module)s: %(message)s', datefmt='%d-%b-%y %H:%M:%S',
|
||||||
|
level=Config.server_log_level.upper())
|
||||||
|
logging.getLogger("requests").setLevel(logging.WARNING) # suppress noisy requests/urllib3 logging
|
||||||
|
logging.getLogger("urllib3").setLevel(logging.WARNING)
|
||||||
|
|
||||||
|
# check for existing instance
|
||||||
|
existing_proc = existing_process(APP_NAME)
|
||||||
|
if existing_proc:
|
||||||
|
logger.fatal(f"Another instance of {APP_NAME} is already running (pid: {existing_proc.pid})")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# check for updates
|
||||||
|
if not skip_updates:
|
||||||
|
update_thread = threading.Thread(target=check_for_updates, args=(APP_REPO_NAME, APP_REPO_OWNER, APP_NAME,
|
||||||
|
APP_VERSION))
|
||||||
|
update_thread.start()
|
||||||
|
|
||||||
|
# main start
|
||||||
|
logger.info(f"Starting {APP_NAME} Render Server")
|
||||||
|
return_code = 0
|
||||||
|
try:
|
||||||
|
# Load Config YAML
|
||||||
|
Config.setup_config_dir()
|
||||||
|
Config.load_config(system_safe_path(os.path.join(Config.config_dir(), 'config.yaml')))
|
||||||
|
|
||||||
|
# configure default paths
|
||||||
|
EngineManager.engines_path = system_safe_path(
|
||||||
|
os.path.join(os.path.join(os.path.expanduser(Config.upload_folder),
|
||||||
|
'engines')))
|
||||||
|
os.makedirs(EngineManager.engines_path, exist_ok=True)
|
||||||
|
PreviewManager.storage_path = system_safe_path(
|
||||||
|
os.path.join(os.path.expanduser(Config.upload_folder), 'previews'))
|
||||||
|
|
||||||
|
# Debug info
|
||||||
|
logger.debug(f"Upload directory: {os.path.expanduser(Config.upload_folder)}")
|
||||||
|
logger.debug(f"Thumbs directory: {PreviewManager.storage_path}")
|
||||||
|
logger.debug(f"Engines directory: {EngineManager.engines_path}")
|
||||||
|
|
||||||
|
# Set up the RenderQueue object
|
||||||
|
RenderQueue.load_state(database_directory=system_safe_path(os.path.expanduser(Config.upload_folder)))
|
||||||
|
ServerProxyManager.subscribe_to_listener()
|
||||||
|
DistributedJobManager.subscribe_to_listener()
|
||||||
|
|
||||||
|
# get hostname
|
||||||
|
local_hostname = socket.gethostname()
|
||||||
|
|
||||||
|
# configure and start API server
|
||||||
|
api_server = threading.Thread(target=start_api_server, args=(local_hostname,))
|
||||||
|
api_server.daemon = True
|
||||||
|
api_server.start()
|
||||||
|
|
||||||
|
# start zeroconf server
|
||||||
|
ZeroconfServer.configure(f"_{APP_NAME.lower()}._tcp.local.", local_hostname, Config.port_number)
|
||||||
|
ZeroconfServer.properties = {'system_cpu': current_system_cpu(),
|
||||||
|
'system_cpu_brand': current_system_cpu_brand(),
|
||||||
|
'system_cpu_cores': multiprocessing.cpu_count(),
|
||||||
|
'system_os': current_system_os(),
|
||||||
|
'system_os_version': current_system_os_version(),
|
||||||
|
'system_memory': round(psutil.virtual_memory().total / (1024**3)), # in GB
|
||||||
|
'gpu_info': get_gpu_info(),
|
||||||
|
'api_version': API_VERSION}
|
||||||
|
ZeroconfServer.start()
|
||||||
|
logger.info(f"{APP_NAME} Render Server started - Hostname: {local_hostname}")
|
||||||
|
RenderQueue.start() # Start evaluating the render queue
|
||||||
|
|
||||||
|
# check for updates for render engines if configured or on first launch
|
||||||
|
# if Config.update_engines_on_launch or not EngineManager.get_engines():
|
||||||
|
# EngineManager.update_all_engines()
|
||||||
|
|
||||||
|
api_server.join()
|
||||||
|
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"Unhandled exception: {e}")
|
||||||
|
return_code = 1
|
||||||
|
finally:
|
||||||
|
# shut down gracefully
|
||||||
|
logger.info(f"{APP_NAME} Render Server is preparing to shut down")
|
||||||
|
try:
|
||||||
|
RenderQueue.prepare_for_shutdown()
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception(f"Exception during prepare for shutdown: {e}")
|
||||||
|
ZeroconfServer.stop()
|
||||||
|
logger.info(f"{APP_NAME} Render Server has shut down")
|
||||||
|
return sys.exit(return_code)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
run(server_only=True)
|
start_server()
|
||||||
+90
@@ -0,0 +1,90 @@
|
|||||||
|
# -*- mode: python ; coding: utf-8 -*-
|
||||||
|
from PyInstaller.utils.hooks import collect_all
|
||||||
|
|
||||||
|
# - get version from version file
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import platform
|
||||||
|
sys.path.insert(0, os.path.abspath('.'))
|
||||||
|
from version import APP_NAME, APP_VERSION, APP_AUTHOR
|
||||||
|
|
||||||
|
APP_NAME = APP_NAME + " Server"
|
||||||
|
datas = [('resources', 'resources'), ('src/engines/blender/scripts/', 'src/engines/blender/scripts')]
|
||||||
|
binaries = []
|
||||||
|
hiddenimports = ['zeroconf']
|
||||||
|
tmp_ret = collect_all('zeroconf')
|
||||||
|
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
|
||||||
|
|
||||||
|
|
||||||
|
a = Analysis(
|
||||||
|
['server.py'],
|
||||||
|
pathex=[],
|
||||||
|
binaries=binaries,
|
||||||
|
datas=datas,
|
||||||
|
hiddenimports=hiddenimports,
|
||||||
|
hookspath=[],
|
||||||
|
hooksconfig={},
|
||||||
|
runtime_hooks=[],
|
||||||
|
excludes=[],
|
||||||
|
noarchive=False,
|
||||||
|
optimize=1, # fyi: optim level 2 breaks on windows
|
||||||
|
)
|
||||||
|
pyz = PYZ(a.pure)
|
||||||
|
|
||||||
|
if platform.system() == 'Windows':
|
||||||
|
|
||||||
|
import pyinstaller_versionfile
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
version_file_path = os.path.join(tempfile.gettempdir(), 'versionfile.txt')
|
||||||
|
|
||||||
|
pyinstaller_versionfile.create_versionfile(
|
||||||
|
output_file=version_file_path,
|
||||||
|
version=APP_VERSION,
|
||||||
|
company_name=APP_AUTHOR,
|
||||||
|
file_description=APP_NAME,
|
||||||
|
internal_name=APP_NAME,
|
||||||
|
legal_copyright=f"© {APP_AUTHOR}",
|
||||||
|
original_filename=f"{APP_NAME}.exe",
|
||||||
|
product_name=APP_NAME
|
||||||
|
)
|
||||||
|
|
||||||
|
exe = EXE(
|
||||||
|
pyz,
|
||||||
|
a.scripts,
|
||||||
|
a.binaries,
|
||||||
|
a.datas,
|
||||||
|
[],
|
||||||
|
name=APP_NAME,
|
||||||
|
debug=False,
|
||||||
|
bootloader_ignore_signals=False,
|
||||||
|
strip=True,
|
||||||
|
upx=True,
|
||||||
|
console=True,
|
||||||
|
disable_windowed_traceback=False,
|
||||||
|
argv_emulation=False,
|
||||||
|
target_arch=None,
|
||||||
|
codesign_identity=None,
|
||||||
|
entitlements_file=None,
|
||||||
|
version=version_file_path
|
||||||
|
)
|
||||||
|
|
||||||
|
else: # linux / macOS
|
||||||
|
exe = EXE(
|
||||||
|
pyz,
|
||||||
|
a.scripts,
|
||||||
|
a.binaries,
|
||||||
|
a.datas,
|
||||||
|
[],
|
||||||
|
name=APP_NAME,
|
||||||
|
debug=False,
|
||||||
|
bootloader_ignore_signals=False,
|
||||||
|
strip=True,
|
||||||
|
upx=True,
|
||||||
|
console=False,
|
||||||
|
disable_windowed_traceback=False,
|
||||||
|
argv_emulation=False,
|
||||||
|
target_arch=None,
|
||||||
|
codesign_identity=None,
|
||||||
|
entitlements_file=None
|
||||||
|
)
|
||||||
@@ -38,7 +38,7 @@ def handle_uploaded_project_files(request, jobs_list, upload_directory):
|
|||||||
uploaded_project = request.files.get('file', None)
|
uploaded_project = request.files.get('file', None)
|
||||||
project_url = jobs_list[0].get('url', None)
|
project_url = jobs_list[0].get('url', None)
|
||||||
local_path = jobs_list[0].get('local_path', None)
|
local_path = jobs_list[0].get('local_path', None)
|
||||||
renderer = jobs_list[0].get('renderer')
|
engine_name = jobs_list[0]['engine_name']
|
||||||
downloaded_file_url = None
|
downloaded_file_url = None
|
||||||
|
|
||||||
if uploaded_project and uploaded_project.filename:
|
if uploaded_project and uploaded_project.filename:
|
||||||
@@ -55,7 +55,7 @@ def handle_uploaded_project_files(request, jobs_list, upload_directory):
|
|||||||
# Prepare the local filepath
|
# Prepare the local filepath
|
||||||
cleaned_path_name = jobs_list[0].get('name', os.path.splitext(referred_name)[0]).replace(' ', '-')
|
cleaned_path_name = jobs_list[0].get('name', os.path.splitext(referred_name)[0]).replace(' ', '-')
|
||||||
job_dir = os.path.join(upload_directory, '-'.join(
|
job_dir = os.path.join(upload_directory, '-'.join(
|
||||||
[datetime.now().strftime("%Y.%m.%d_%H.%M.%S"), renderer, cleaned_path_name]))
|
[datetime.now().strftime("%Y.%m.%d_%H.%M.%S"), engine_name, cleaned_path_name]))
|
||||||
os.makedirs(job_dir, exist_ok=True)
|
os.makedirs(job_dir, exist_ok=True)
|
||||||
project_source_dir = os.path.join(job_dir, 'source')
|
project_source_dir = os.path.join(job_dir, 'source')
|
||||||
os.makedirs(project_source_dir, exist_ok=True)
|
os.makedirs(project_source_dir, exist_ok=True)
|
||||||
@@ -133,7 +133,7 @@ def process_zipped_project(zip_path):
|
|||||||
|
|
||||||
logger.debug(f"Zip files: {project_files}")
|
logger.debug(f"Zip files: {project_files}")
|
||||||
|
|
||||||
# supported_exts = RenderWorkerFactory.class_for_name(renderer).engine.supported_extensions
|
# supported_exts = RenderWorkerFactory.class_for_name(engine).engine.supported_extensions
|
||||||
# if supported_exts:
|
# if supported_exts:
|
||||||
# project_files = [file for file in project_files if any(file.endswith(ext) for ext in supported_exts)]
|
# project_files = [file for file in project_files if any(file.endswith(ext) for ext in supported_exts)]
|
||||||
|
|
||||||
|
|||||||
+34
-21
@@ -11,6 +11,7 @@ import tempfile
|
|||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
import cpuinfo
|
||||||
import psutil
|
import psutil
|
||||||
import yaml
|
import yaml
|
||||||
from flask import Flask, request, send_file, after_this_request, Response, redirect, url_for
|
from flask import Flask, request, send_file, after_this_request, Response, redirect, url_for
|
||||||
@@ -23,15 +24,17 @@ from src.engines.engine_manager import EngineManager
|
|||||||
from src.render_queue import RenderQueue, JobNotFoundError
|
from src.render_queue import RenderQueue, JobNotFoundError
|
||||||
from src.utilities.config import Config
|
from src.utilities.config import Config
|
||||||
from src.utilities.misc_helper import system_safe_path, current_system_os, current_system_cpu, \
|
from src.utilities.misc_helper import system_safe_path, current_system_os, current_system_cpu, \
|
||||||
current_system_os_version, num_to_alphanumeric
|
current_system_os_version, num_to_alphanumeric, get_gpu_info
|
||||||
from src.utilities.status_utils import string_to_status
|
from src.utilities.status_utils import string_to_status
|
||||||
|
from src.version import APP_VERSION
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
server = Flask(__name__)
|
server = Flask(__name__)
|
||||||
ssl._create_default_https_context = ssl._create_unverified_context # disable SSL for downloads
|
ssl._create_default_https_context = ssl._create_unverified_context # disable SSL for downloads
|
||||||
|
|
||||||
|
API_VERSION = "1"
|
||||||
|
|
||||||
def start_server(hostname=None):
|
def start_api_server(hostname=None):
|
||||||
|
|
||||||
# get hostname
|
# get hostname
|
||||||
if not hostname:
|
if not hostname:
|
||||||
@@ -50,8 +53,11 @@ def start_server(hostname=None):
|
|||||||
flask_log.setLevel(Config.flask_log_level.upper())
|
flask_log.setLevel(Config.flask_log_level.upper())
|
||||||
|
|
||||||
logger.debug('Starting API server')
|
logger.debug('Starting API server')
|
||||||
server.run(host='0.0.0.0', port=server.config['PORT'], debug=Config.flask_debug_enable, use_reloader=False,
|
try:
|
||||||
threaded=True)
|
server.run(host=hostname, port=server.config['PORT'], debug=Config.flask_debug_enable, use_reloader=False,
|
||||||
|
threaded=True)
|
||||||
|
finally:
|
||||||
|
logger.debug('Stopping API server')
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
@@ -225,6 +231,7 @@ def status():
|
|||||||
"system_os": current_system_os(),
|
"system_os": current_system_os(),
|
||||||
"system_os_version": current_system_os_version(),
|
"system_os_version": current_system_os_version(),
|
||||||
"system_cpu": current_system_cpu(),
|
"system_cpu": current_system_cpu(),
|
||||||
|
"system_cpu_brand": cpuinfo.get_cpu_info()['brand_raw'],
|
||||||
"cpu_percent": psutil.cpu_percent(percpu=False),
|
"cpu_percent": psutil.cpu_percent(percpu=False),
|
||||||
"cpu_percent_per_cpu": psutil.cpu_percent(percpu=True),
|
"cpu_percent_per_cpu": psutil.cpu_percent(percpu=True),
|
||||||
"cpu_count": psutil.cpu_count(logical=False),
|
"cpu_count": psutil.cpu_count(logical=False),
|
||||||
@@ -233,7 +240,9 @@ def status():
|
|||||||
"memory_percent": psutil.virtual_memory().percent,
|
"memory_percent": psutil.virtual_memory().percent,
|
||||||
"job_counts": RenderQueue.job_counts(),
|
"job_counts": RenderQueue.job_counts(),
|
||||||
"hostname": server.config['HOSTNAME'],
|
"hostname": server.config['HOSTNAME'],
|
||||||
"port": server.config['PORT']
|
"port": server.config['PORT'],
|
||||||
|
"app_version": APP_VERSION,
|
||||||
|
"api_version": API_VERSION
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -331,8 +340,8 @@ def delete_job(job_id):
|
|||||||
# Engine Info and Management:
|
# Engine Info and Management:
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
|
|
||||||
@server.get('/api/renderer_info')
|
@server.get('/api/engine_info')
|
||||||
def renderer_info():
|
def engine_info():
|
||||||
response_type = request.args.get('response_type', 'standard')
|
response_type = request.args.get('response_type', 'standard')
|
||||||
if response_type not in ['full', 'standard']:
|
if response_type not in ['full', 'standard']:
|
||||||
raise ValueError(f"Invalid response_type: {response_type}")
|
raise ValueError(f"Invalid response_type: {response_type}")
|
||||||
@@ -370,19 +379,19 @@ def renderer_info():
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f'Error fetching details for {engine.name()} renderer: {e}')
|
logger.error(f"Error fetching details for engine '{engine.name()}': {e}")
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
renderer_data = {}
|
engine_data = {}
|
||||||
with concurrent.futures.ThreadPoolExecutor() as executor:
|
with concurrent.futures.ThreadPoolExecutor() as executor:
|
||||||
futures = {executor.submit(process_engine, engine): engine.name() for engine in EngineManager.supported_engines()}
|
futures = {executor.submit(process_engine, engine): engine.name() for engine in EngineManager.supported_engines()}
|
||||||
|
|
||||||
for future in concurrent.futures.as_completed(futures):
|
for future in concurrent.futures.as_completed(futures):
|
||||||
result = future.result()
|
result = future.result()
|
||||||
if result:
|
if result:
|
||||||
renderer_data.update(result)
|
engine_data.update(result)
|
||||||
|
|
||||||
return renderer_data
|
return engine_data
|
||||||
|
|
||||||
|
|
||||||
@server.get('/api/<engine_name>/is_available')
|
@server.get('/api/<engine_name>/is_available')
|
||||||
@@ -433,27 +442,31 @@ def delete_engine_download():
|
|||||||
(f"Error deleting {json_data.get('engine')} {json_data.get('version')}", 500)
|
(f"Error deleting {json_data.get('engine')} {json_data.get('version')}", 500)
|
||||||
|
|
||||||
|
|
||||||
@server.get('/api/renderer/<renderer>/args')
|
@server.get('/api/engine/<engine_name>/args')
|
||||||
def get_renderer_args(renderer):
|
def get_engine_args(engine_name):
|
||||||
try:
|
try:
|
||||||
renderer_engine_class = EngineManager.engine_with_name(renderer)
|
engine_class = EngineManager.engine_with_name(engine_name)
|
||||||
return renderer_engine_class().get_arguments()
|
return engine_class().get_arguments()
|
||||||
except LookupError:
|
except LookupError:
|
||||||
return f"Cannot find renderer '{renderer}'", 400
|
return f"Cannot find engine '{engine_name}'", 400
|
||||||
|
|
||||||
|
|
||||||
@server.get('/api/renderer/<renderer>/help')
|
@server.get('/api/engine/<engine_name>/help')
|
||||||
def get_renderer_help(renderer):
|
def get_engine_help(engine_name):
|
||||||
try:
|
try:
|
||||||
renderer_engine_class = EngineManager.engine_with_name(renderer)
|
engine_class = EngineManager.engine_with_name(engine_name)
|
||||||
return renderer_engine_class().get_help()
|
return engine_class().get_help()
|
||||||
except LookupError:
|
except LookupError:
|
||||||
return f"Cannot find renderer '{renderer}'", 400
|
return f"Cannot find engine '{engine_name}'", 400
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
# Miscellaneous:
|
# Miscellaneous:
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
|
@server.get('/api/heartbeat')
|
||||||
|
def heartbeat():
|
||||||
|
return datetime.now().isoformat(), 200
|
||||||
|
|
||||||
@server.post('/api/job/<job_id>/send_subjob_update_notification')
|
@server.post('/api/job/<job_id>/send_subjob_update_notification')
|
||||||
def subjob_update_notification(job_id):
|
def subjob_update_notification(job_id):
|
||||||
subjob_details = request.json
|
subjob_details = request.json
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class PreviewManager:
|
|||||||
_running_jobs = {}
|
_running_jobs = {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __generate_job_preview_worker(cls, job, replace_existing=False, max_width=320):
|
def __generate_job_preview_worker(cls, job, replace_existing=False, max_width=480):
|
||||||
|
|
||||||
# Determine best source file to use for thumbs
|
# Determine best source file to use for thumbs
|
||||||
job_file_list = job.file_list()
|
job_file_list = job.file_list()
|
||||||
|
|||||||
+24
-21
@@ -21,7 +21,6 @@ categories = [RenderStatus.RUNNING, RenderStatus.WAITING_FOR_SUBJOBS, RenderStat
|
|||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
OFFLINE_MAX = 4
|
OFFLINE_MAX = 4
|
||||||
LOOPBACK = '127.0.0.1'
|
|
||||||
|
|
||||||
|
|
||||||
class RenderServerProxy:
|
class RenderServerProxy:
|
||||||
@@ -46,6 +45,7 @@ class RenderServerProxy:
|
|||||||
self.system_cpu_count = None
|
self.system_cpu_count = None
|
||||||
self.system_os = None
|
self.system_os = None
|
||||||
self.system_os_version = None
|
self.system_os_version = None
|
||||||
|
self.system_api_version = None
|
||||||
|
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
# Basics / Connection:
|
# Basics / Connection:
|
||||||
@@ -54,14 +54,18 @@ class RenderServerProxy:
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<RenderServerProxy - {self.hostname}>"
|
return f"<RenderServerProxy - {self.hostname}>"
|
||||||
|
|
||||||
def connect(self):
|
def check_connection(self):
|
||||||
return self.status()
|
try:
|
||||||
|
return self.request("heartbeat").ok
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
def is_online(self):
|
def is_online(self):
|
||||||
if self.__update_in_background:
|
if self.__update_in_background:
|
||||||
return self.__offline_flags < OFFLINE_MAX
|
return self.__offline_flags < OFFLINE_MAX
|
||||||
else:
|
else:
|
||||||
return self.get_status() is not None
|
return self.check_connection()
|
||||||
|
|
||||||
def status(self):
|
def status(self):
|
||||||
if not self.is_online():
|
if not self.is_online():
|
||||||
@@ -100,8 +104,9 @@ class RenderServerProxy:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def request(self, payload, timeout=5):
|
def request(self, payload, timeout=5):
|
||||||
hostname = LOOPBACK if self.is_localhost else self.hostname
|
from src.api.api_server import API_VERSION
|
||||||
return requests.get(f'http://{hostname}:{self.port}/api/{payload}', timeout=timeout)
|
return requests.get(f'http://{self.hostname}:{self.port}/api/{payload}', timeout=timeout,
|
||||||
|
headers={"X-API-Version": str(API_VERSION)})
|
||||||
|
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
# Background Updates:
|
# Background Updates:
|
||||||
@@ -162,6 +167,7 @@ class RenderServerProxy:
|
|||||||
self.system_cpu_count = status['cpu_count']
|
self.system_cpu_count = status['cpu_count']
|
||||||
self.system_os = status['system_os']
|
self.system_os = status['system_os']
|
||||||
self.system_os_version = status['system_os_version']
|
self.system_os_version = status['system_os_version']
|
||||||
|
self.system_api_version = status['api_version']
|
||||||
return status
|
return status
|
||||||
|
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
@@ -199,7 +205,7 @@ class RenderServerProxy:
|
|||||||
if self.is_localhost:
|
if self.is_localhost:
|
||||||
jobs_with_path = [{'local_path': file_path, **item} for item in job_list]
|
jobs_with_path = [{'local_path': file_path, **item} for item in job_list]
|
||||||
job_data = json.dumps(jobs_with_path)
|
job_data = json.dumps(jobs_with_path)
|
||||||
url = urljoin(f'http://{LOOPBACK}:{self.port}', '/api/add_job')
|
url = urljoin(f'http://{self.hostname}:{self.port}', '/api/add_job')
|
||||||
headers = {'Content-Type': 'application/json'}
|
headers = {'Content-Type': 'application/json'}
|
||||||
return requests.post(url, data=job_data, headers=headers)
|
return requests.post(url, data=job_data, headers=headers)
|
||||||
|
|
||||||
@@ -241,32 +247,32 @@ class RenderServerProxy:
|
|||||||
Returns:
|
Returns:
|
||||||
Response: The response from the server.
|
Response: The response from the server.
|
||||||
"""
|
"""
|
||||||
hostname = LOOPBACK if self.is_localhost else self.hostname
|
return requests.post(f'http://{self.hostname}:{self.port}/api/job/{parent_id}/send_subjob_update_notification',
|
||||||
return requests.post(f'http://{hostname}:{self.port}/api/job/{parent_id}/send_subjob_update_notification',
|
|
||||||
json=subjob.json())
|
json=subjob.json())
|
||||||
|
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
# Renderers:
|
# Engines:
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
|
|
||||||
def is_engine_available(self, engine_name):
|
def is_engine_available(self, engine_name):
|
||||||
return self.request_data(f'{engine_name}/is_available')
|
return self.request_data(f'{engine_name}/is_available')
|
||||||
|
|
||||||
def get_all_engines(self):
|
def get_all_engines(self):
|
||||||
|
# todo: this doesnt work
|
||||||
return self.request_data('all_engines')
|
return self.request_data('all_engines')
|
||||||
|
|
||||||
def get_renderer_info(self, response_type='standard', timeout=5):
|
def get_engine_info(self, response_type='standard', timeout=5):
|
||||||
"""
|
"""
|
||||||
Fetches renderer information from the server.
|
Fetches engine information from the server.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
response_type (str, optional): Returns standard or full version of renderer info
|
response_type (str, optional): Returns standard or full version of engine info
|
||||||
timeout (int, optional): The number of seconds to wait for a response from the server. Defaults to 5.
|
timeout (int, optional): The number of seconds to wait for a response from the server. Defaults to 5.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict: A dictionary containing the renderer information.
|
dict: A dictionary containing the engine information.
|
||||||
"""
|
"""
|
||||||
all_data = self.request_data(f"renderer_info?response_type={response_type}", timeout=timeout)
|
all_data = self.request_data(f"engine_info?response_type={response_type}", timeout=timeout)
|
||||||
return all_data
|
return all_data
|
||||||
|
|
||||||
def delete_engine(self, engine, version, system_cpu=None):
|
def delete_engine(self, engine, version, system_cpu=None):
|
||||||
@@ -282,21 +288,18 @@ class RenderServerProxy:
|
|||||||
Response: The response from the server.
|
Response: The response from the server.
|
||||||
"""
|
"""
|
||||||
form_data = {'engine': engine, 'version': version, 'system_cpu': system_cpu}
|
form_data = {'engine': engine, 'version': version, 'system_cpu': system_cpu}
|
||||||
hostname = LOOPBACK if self.is_localhost else self.hostname
|
return requests.post(f'http://{self.hostname}:{self.port}/api/delete_engine', json=form_data)
|
||||||
return requests.post(f'http://{hostname}:{self.port}/api/delete_engine', json=form_data)
|
|
||||||
|
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
# Download Files:
|
# Download Files:
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
|
|
||||||
def download_all_job_files(self, job_id, save_path):
|
def download_all_job_files(self, job_id, save_path):
|
||||||
hostname = LOOPBACK if self.is_localhost else self.hostname
|
url = f"http://{self.hostname}:{self.port}/api/job/{job_id}/download_all"
|
||||||
url = f"http://{hostname}:{self.port}/api/job/{job_id}/download_all"
|
|
||||||
return self.__download_file_from_url(url, output_filepath=save_path)
|
return self.__download_file_from_url(url, output_filepath=save_path)
|
||||||
|
|
||||||
def download_job_file(self, job_id, job_filename, save_path):
|
def download_job_file(self, job_id, job_filename, save_path):
|
||||||
hostname = LOOPBACK if self.is_localhost else self.hostname
|
url = f"http://{self.hostname}:{self.port}/api/job/{job_id}/download?filename={job_filename}"
|
||||||
url = f"http://{hostname}:{self.port}/api/job/{job_id}/download?filename={job_filename}"
|
|
||||||
return self.__download_file_from_url(url, output_filepath=save_path)
|
return self.__download_file_from_url(url, output_filepath=save_path)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ class DistributedJobManager:
|
|||||||
logger.debug(f"New job output path: {output_path}")
|
logger.debug(f"New job output path: {output_path}")
|
||||||
|
|
||||||
# create & configure jobs
|
# create & configure jobs
|
||||||
worker = EngineManager.create_worker(renderer=new_job_attributes['renderer'],
|
worker = EngineManager.create_worker(engine_name=new_job_attributes['engine'],
|
||||||
input_path=loaded_project_local_path,
|
input_path=loaded_project_local_path,
|
||||||
output_path=output_path,
|
output_path=output_path,
|
||||||
engine_version=new_job_attributes.get('engine_version'),
|
engine_version=new_job_attributes.get('engine_version'),
|
||||||
@@ -303,14 +303,14 @@ class DistributedJobManager:
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
parent_worker (Worker): The parent job what we're creating the subjobs for.
|
parent_worker (Worker): The parent job what we're creating the subjobs for.
|
||||||
new_job_attributes (dict): Dict of desired attributes for new job (frame count, renderer, output path, etc)
|
new_job_attributes (dict): Dict of desired attributes for new job (frame count, engine, output path, etc)
|
||||||
project_path (str): The path to the project.
|
project_path (str): The path to the project.
|
||||||
system_os (str, optional): Required OS. Default is any.
|
system_os (str, optional): Required OS. Default is any.
|
||||||
specific_servers (list, optional): List of specific servers to split work between. Defaults to all found.
|
specific_servers (list, optional): List of specific servers to split work between. Defaults to all found.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Check availability
|
# Check availability
|
||||||
available_servers = specific_servers if specific_servers else cls.find_available_servers(parent_worker.renderer,
|
available_servers = specific_servers if specific_servers else cls.find_available_servers(parent_worker.engine_name,
|
||||||
system_os)
|
system_os)
|
||||||
# skip if theres no external servers found
|
# skip if theres no external servers found
|
||||||
external_servers = [x for x in available_servers if x['hostname'] != parent_worker.hostname]
|
external_servers = [x for x in available_servers if x['hostname'] != parent_worker.hostname]
|
||||||
@@ -354,7 +354,7 @@ class DistributedJobManager:
|
|||||||
subjob['parent'] = f"{parent_worker.id}@{parent_worker.hostname}"
|
subjob['parent'] = f"{parent_worker.id}@{parent_worker.hostname}"
|
||||||
subjob['start_frame'] = server_data['frame_range'][0]
|
subjob['start_frame'] = server_data['frame_range'][0]
|
||||||
subjob['end_frame'] = server_data['frame_range'][-1]
|
subjob['end_frame'] = server_data['frame_range'][-1]
|
||||||
subjob['engine_version'] = parent_worker.renderer_version
|
subjob['engine_version'] = parent_worker.engine_version
|
||||||
logger.debug(f"Posting subjob with frames {subjob['start_frame']}-"
|
logger.debug(f"Posting subjob with frames {subjob['start_frame']}-"
|
||||||
f"{subjob['end_frame']} to {server_hostname}")
|
f"{subjob['end_frame']} to {server_hostname}")
|
||||||
post_results = RenderServerProxy(server_hostname).post_job_to_server(
|
post_results = RenderServerProxy(server_hostname).post_job_to_server(
|
||||||
@@ -374,13 +374,15 @@ class DistributedJobManager:
|
|||||||
:param system_os: str, Restrict results to servers running a specific OS
|
:param system_os: str, Restrict results to servers running a specific OS
|
||||||
:return: A list of dictionaries with each dict containing hostname and cpu_count of available servers
|
:return: A list of dictionaries with each dict containing hostname and cpu_count of available servers
|
||||||
"""
|
"""
|
||||||
|
from api.api_server import API_VERSION
|
||||||
available_servers = []
|
available_servers = []
|
||||||
for hostname in ZeroconfServer.found_hostnames():
|
for hostname in ZeroconfServer.found_hostnames():
|
||||||
host_properties = ZeroconfServer.get_hostname_properties(hostname)
|
host_properties = ZeroconfServer.get_hostname_properties(hostname)
|
||||||
if not system_os or (system_os and system_os == host_properties.get('system_os')):
|
if host_properties.get('api_version') == API_VERSION:
|
||||||
response = RenderServerProxy(hostname).is_engine_available(engine_name)
|
if not system_os or (system_os and system_os == host_properties.get('system_os')):
|
||||||
if response and response.get('available', False):
|
response = RenderServerProxy(hostname).is_engine_available(engine_name)
|
||||||
available_servers.append(response)
|
if response and response.get('available', False):
|
||||||
|
available_servers.append(response)
|
||||||
|
|
||||||
return available_servers
|
return available_servers
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class AERender(BaseRenderEngine):
|
|||||||
def version(self):
|
def version(self):
|
||||||
version = None
|
version = None
|
||||||
try:
|
try:
|
||||||
render_path = self.renderer_path()
|
render_path = self.engine_path()
|
||||||
if render_path:
|
if render_path:
|
||||||
ver_out = subprocess.check_output([render_path, '-version'], timeout=SUBPROCESS_TIMEOUT)
|
ver_out = subprocess.check_output([render_path, '-version'], timeout=SUBPROCESS_TIMEOUT)
|
||||||
version = ver_out.decode('utf-8').split(" ")[-1].strip()
|
version = ver_out.decode('utf-8').split(" ")[-1].strip()
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ from src.engines.blender.blender_engine import Blender
|
|||||||
from src.engines.core.base_downloader import EngineDownloader
|
from src.engines.core.base_downloader import EngineDownloader
|
||||||
from src.utilities.misc_helper import current_system_os, current_system_cpu
|
from src.utilities.misc_helper import current_system_os, current_system_cpu
|
||||||
|
|
||||||
# url = "https://download.blender.org/release/"
|
url = "https://download.blender.org/release/"
|
||||||
url = "https://ftp.nluug.nl/pub/graphics/blender/release/" # much faster mirror for testing
|
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
supported_formats = ['.zip', '.tar.xz', '.dmg']
|
supported_formats = ['.zip', '.tar.xz', '.dmg']
|
||||||
@@ -88,8 +87,8 @@ class BlenderDownloader(EngineDownloader):
|
|||||||
threads = []
|
threads = []
|
||||||
results = [[] for _ in majors]
|
results = [[] for _ in majors]
|
||||||
|
|
||||||
def thread_function(major_version, index, system_os, cpu):
|
def thread_function(major_version, index, system_os_t, cpu_t):
|
||||||
results[index] = cls.__get_minor_versions(major_version, system_os, cpu)
|
results[index] = cls.__get_minor_versions(major_version, system_os_t, cpu_t)
|
||||||
|
|
||||||
for i, m in enumerate(majors):
|
for i, m in enumerate(majors):
|
||||||
thread = threading.Thread(target=thread_function, args=(m, i, system_os, cpu))
|
thread = threading.Thread(target=thread_function, args=(m, i, system_os, cpu))
|
||||||
@@ -126,7 +125,7 @@ class BlenderDownloader(EngineDownloader):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def download_engine(cls, version, download_location, system_os=None, cpu=None, timeout=120):
|
def download_engine(cls, version, download_location, system_os=None, cpu=None, timeout=120, progress_callback=None):
|
||||||
system_os = system_os or current_system_os()
|
system_os = system_os or current_system_os()
|
||||||
cpu = cpu or current_system_cpu()
|
cpu = cpu or current_system_cpu()
|
||||||
|
|
||||||
@@ -136,7 +135,7 @@ class BlenderDownloader(EngineDownloader):
|
|||||||
minor_versions = [x for x in cls.__get_minor_versions(major_version, system_os, cpu) if
|
minor_versions = [x for x in cls.__get_minor_versions(major_version, system_os, cpu) if
|
||||||
x['version'] == version]
|
x['version'] == version]
|
||||||
cls.download_and_extract_app(remote_url=minor_versions[0]['url'], download_location=download_location,
|
cls.download_and_extract_app(remote_url=minor_versions[0]['url'], download_location=download_location,
|
||||||
timeout=timeout)
|
timeout=timeout, progress_callback=progress_callback)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
logger.error("Cannot find requested engine")
|
logger.error("Cannot find requested engine")
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class Blender(BaseRenderEngine):
|
|||||||
def version(self):
|
def version(self):
|
||||||
version = None
|
version = None
|
||||||
try:
|
try:
|
||||||
render_path = self.renderer_path()
|
render_path = self.engine_path()
|
||||||
if render_path:
|
if render_path:
|
||||||
ver_out = subprocess.check_output([render_path, '-v'], timeout=SUBPROCESS_TIMEOUT,
|
ver_out = subprocess.check_output([render_path, '-v'], timeout=SUBPROCESS_TIMEOUT,
|
||||||
creationflags=_creationflags)
|
creationflags=_creationflags)
|
||||||
@@ -52,7 +52,7 @@ class Blender(BaseRenderEngine):
|
|||||||
def run_python_expression(self, project_path, python_expression, timeout=None):
|
def run_python_expression(self, project_path, python_expression, timeout=None):
|
||||||
if os.path.exists(project_path):
|
if os.path.exists(project_path):
|
||||||
try:
|
try:
|
||||||
return subprocess.run([self.renderer_path(), '-b', project_path, '--python-expr', python_expression],
|
return subprocess.run([self.engine_path(), '-b', project_path, '--python-expr', python_expression],
|
||||||
capture_output=True, timeout=timeout, creationflags=_creationflags)
|
capture_output=True, timeout=timeout, creationflags=_creationflags)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
err_msg = f"Error running python expression in blender: {e}"
|
err_msg = f"Error running python expression in blender: {e}"
|
||||||
@@ -69,7 +69,7 @@ class Blender(BaseRenderEngine):
|
|||||||
raise FileNotFoundError(f'Python script not found: {script_path}')
|
raise FileNotFoundError(f'Python script not found: {script_path}')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
command = [self.renderer_path(), '-b', '--python', script_path]
|
command = [self.engine_path(), '-b', '--python', script_path]
|
||||||
if project_path:
|
if project_path:
|
||||||
command.insert(2, project_path)
|
command.insert(2, project_path)
|
||||||
result = subprocess.run(command, capture_output=True, timeout=timeout, creationflags=_creationflags)
|
result = subprocess.run(command, capture_output=True, timeout=timeout, creationflags=_creationflags)
|
||||||
@@ -132,7 +132,7 @@ class Blender(BaseRenderEngine):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_arguments(self):
|
def get_arguments(self):
|
||||||
help_text = subprocess.check_output([self.renderer_path(), '-h'], creationflags=_creationflags).decode('utf-8')
|
help_text = subprocess.check_output([self.engine_path(), '-h'], creationflags=_creationflags).decode('utf-8')
|
||||||
lines = help_text.splitlines()
|
lines = help_text.splitlines()
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
@@ -179,7 +179,7 @@ class Blender(BaseRenderEngine):
|
|||||||
logger.error("GPU data not found in the output.")
|
logger.error("GPU data not found in the output.")
|
||||||
|
|
||||||
def supported_render_engines(self):
|
def supported_render_engines(self):
|
||||||
engine_output = subprocess.run([self.renderer_path(), '-E', 'help'], timeout=SUBPROCESS_TIMEOUT,
|
engine_output = subprocess.run([self.engine_path(), '-E', 'help'], timeout=SUBPROCESS_TIMEOUT,
|
||||||
capture_output=True, creationflags=_creationflags).stdout.decode('utf-8').strip()
|
capture_output=True, creationflags=_creationflags).stdout.decode('utf-8').strip()
|
||||||
render_engines = [x.strip() for x in engine_output.split('Blender Engine Listing:')[-1].strip().splitlines()]
|
render_engines = [x.strip() for x in engine_output.split('Blender Engine Listing:')[-1].strip().splitlines()]
|
||||||
return render_engines
|
return render_engines
|
||||||
|
|||||||
@@ -26,11 +26,17 @@ class BlenderRenderWorker(BaseRenderWorker):
|
|||||||
|
|
||||||
def generate_worker_subprocess(self):
|
def generate_worker_subprocess(self):
|
||||||
|
|
||||||
cmd = [self.renderer_path]
|
cmd = [self.engine_path]
|
||||||
if self.args.get('background', True): # optionally run render not in background
|
if self.args.get('background', True): # optionally run render not in background
|
||||||
cmd.append('-b')
|
cmd.append('-b')
|
||||||
cmd.append(self.input_path)
|
cmd.append(self.input_path)
|
||||||
|
|
||||||
|
# Set Render Engine
|
||||||
|
blender_engine = self.args.get('engine')
|
||||||
|
if blender_engine:
|
||||||
|
blender_engine = blender_engine.upper()
|
||||||
|
cmd.extend(['-E', blender_engine])
|
||||||
|
|
||||||
# Start Python expressions - # todo: investigate splitting into separate 'setup' script
|
# Start Python expressions - # todo: investigate splitting into separate 'setup' script
|
||||||
cmd.append('--python-expr')
|
cmd.append('--python-expr')
|
||||||
python_exp = 'import bpy; bpy.context.scene.render.use_overwrite = False;'
|
python_exp = 'import bpy; bpy.context.scene.render.use_overwrite = False;'
|
||||||
@@ -40,8 +46,7 @@ class BlenderRenderWorker(BaseRenderWorker):
|
|||||||
if custom_camera:
|
if custom_camera:
|
||||||
python_exp = python_exp + f"bpy.context.scene.camera = bpy.data.objects['{custom_camera}'];"
|
python_exp = python_exp + f"bpy.context.scene.camera = bpy.data.objects['{custom_camera}'];"
|
||||||
|
|
||||||
# Set Render Device (gpu/cpu/any)
|
# Set Render Device for Cycles (gpu/cpu/any)
|
||||||
blender_engine = self.args.get('engine', 'BLENDER_EEVEE').upper()
|
|
||||||
if blender_engine == 'CYCLES':
|
if blender_engine == 'CYCLES':
|
||||||
render_device = self.args.get('render_device', 'any').lower()
|
render_device = self.args.get('render_device', 'any').lower()
|
||||||
if render_device not in {'any', 'gpu', 'cpu'}:
|
if render_device not in {'any', 'gpu', 'cpu'}:
|
||||||
@@ -66,7 +71,7 @@ class BlenderRenderWorker(BaseRenderWorker):
|
|||||||
# Remove the extension only if it is not composed entirely of digits
|
# Remove the extension only if it is not composed entirely of digits
|
||||||
path_without_ext = main_part if not ext[1:].isdigit() else self.output_path
|
path_without_ext = main_part if not ext[1:].isdigit() else self.output_path
|
||||||
path_without_ext += "_"
|
path_without_ext += "_"
|
||||||
cmd.extend(['-E', blender_engine, '-o', path_without_ext, '-F', export_format])
|
cmd.extend(['-o', path_without_ext, '-F', export_format])
|
||||||
|
|
||||||
# set frame range
|
# set frame range
|
||||||
cmd.extend(['-s', self.start_frame, '-e', self.end_frame, '-a'])
|
cmd.extend(['-s', self.start_frame, '-e', self.end_frame, '-a'])
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class EngineDownloader:
|
|||||||
raise NotImplementedError(f"version_is_available_to_download not implemented for {cls.__class__.__name__}")
|
raise NotImplementedError(f"version_is_available_to_download not implemented for {cls.__class__.__name__}")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def download_engine(cls, version, download_location, system_os=None, cpu=None, timeout=120):
|
def download_engine(cls, version, download_location, system_os=None, cpu=None, timeout=120, progress_callback=None):
|
||||||
"""Downloads the requested version of the rendering engine to the given download location.
|
"""Downloads the requested version of the rendering engine to the given download location.
|
||||||
|
|
||||||
This method should be overridden in a subclass to implement the logic for downloading
|
This method should be overridden in a subclass to implement the logic for downloading
|
||||||
@@ -88,6 +88,7 @@ class EngineDownloader:
|
|||||||
system_os (str, optional): Desired OS ('linux', 'macos', 'windows'). Defaults to system os.
|
system_os (str, optional): Desired OS ('linux', 'macos', 'windows'). Defaults to system os.
|
||||||
cpu (str, optional): The CPU architecture for which to download the engine. Default is system cpu.
|
cpu (str, optional): The CPU architecture for which to download the engine. Default is system cpu.
|
||||||
timeout (int, optional): The maximum time in seconds to wait for the download. Default is 120 seconds.
|
timeout (int, optional): The maximum time in seconds to wait for the download. Default is 120 seconds.
|
||||||
|
progress_callback (callable, optional): A callback function that is called periodically with the current download progress.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
NotImplementedError: If the method is not overridden in a subclass.
|
NotImplementedError: If the method is not overridden in a subclass.
|
||||||
@@ -125,7 +126,7 @@ class EngineDownloader:
|
|||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def download_and_extract_app(cls, remote_url, download_location, timeout=120):
|
def download_and_extract_app(cls, remote_url, download_location, timeout=120, progress_callback=None):
|
||||||
"""Downloads an application from the given remote URL and extracts it to the specified location.
|
"""Downloads an application from the given remote URL and extracts it to the specified location.
|
||||||
|
|
||||||
This method handles the downloading of the application, supports multiple archive formats,
|
This method handles the downloading of the application, supports multiple archive formats,
|
||||||
@@ -136,6 +137,7 @@ class EngineDownloader:
|
|||||||
remote_url (str): The URL of the application to download.
|
remote_url (str): The URL of the application to download.
|
||||||
download_location (str): The directory where the application should be extracted.
|
download_location (str): The directory where the application should be extracted.
|
||||||
timeout (int, optional): The maximum time in seconds to wait for the download. Default is 120 seconds.
|
timeout (int, optional): The maximum time in seconds to wait for the download. Default is 120 seconds.
|
||||||
|
progress_callback (callable, optional): A callback function that is called periodically with the current download progress.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str: The path to the directory where the application was extracted.
|
str: The path to the directory where the application was extracted.
|
||||||
@@ -154,6 +156,8 @@ class EngineDownloader:
|
|||||||
and return without downloading or extracting.
|
and return without downloading or extracting.
|
||||||
- Temporary files created during the download process are cleaned up after completion.
|
- Temporary files created during the download process are cleaned up after completion.
|
||||||
"""
|
"""
|
||||||
|
if progress_callback:
|
||||||
|
progress_callback(0)
|
||||||
|
|
||||||
# Create a temp download directory
|
# Create a temp download directory
|
||||||
temp_download_dir = tempfile.mkdtemp()
|
temp_download_dir = tempfile.mkdtemp()
|
||||||
@@ -166,7 +170,7 @@ class EngineDownloader:
|
|||||||
|
|
||||||
if os.path.exists(os.path.join(download_location, output_dir_name)):
|
if os.path.exists(os.path.join(download_location, output_dir_name)):
|
||||||
logger.error(f"Engine download for {output_dir_name} already exists")
|
logger.error(f"Engine download for {output_dir_name} already exists")
|
||||||
return
|
return None
|
||||||
|
|
||||||
if not os.path.exists(temp_downloaded_file_path):
|
if not os.path.exists(temp_downloaded_file_path):
|
||||||
# Make a GET request to the URL with stream=True to enable streaming
|
# Make a GET request to the URL with stream=True to enable streaming
|
||||||
@@ -182,20 +186,26 @@ class EngineDownloader:
|
|||||||
progress_bar = tqdm(total=file_size, unit="B", unit_scale=True)
|
progress_bar = tqdm(total=file_size, unit="B", unit_scale=True)
|
||||||
|
|
||||||
# Open a file for writing in binary mode
|
# Open a file for writing in binary mode
|
||||||
|
total_saved = 0
|
||||||
with open(temp_downloaded_file_path, "wb") as file:
|
with open(temp_downloaded_file_path, "wb") as file:
|
||||||
for chunk in response.iter_content(chunk_size=1024):
|
for chunk in response.iter_content(chunk_size=1024):
|
||||||
if chunk:
|
if chunk:
|
||||||
# Write the chunk to the file
|
# Write the chunk to the file
|
||||||
file.write(chunk)
|
file.write(chunk)
|
||||||
|
total_saved += len(chunk)
|
||||||
# Update the progress bar
|
# Update the progress bar
|
||||||
progress_bar.update(len(chunk))
|
progress_bar.update(len(chunk))
|
||||||
|
if progress_callback:
|
||||||
|
percent = float(total_saved) / float(file_size)
|
||||||
|
progress_callback(percent)
|
||||||
|
|
||||||
# Close the progress bar
|
# Close the progress bar
|
||||||
|
progress_callback(1.0)
|
||||||
progress_bar.close()
|
progress_bar.close()
|
||||||
logger.info(f"Successfully downloaded {os.path.basename(temp_downloaded_file_path)}")
|
logger.info(f"Successfully downloaded {os.path.basename(temp_downloaded_file_path)}")
|
||||||
else:
|
else:
|
||||||
logger.error(f"Failed to download the file. Status code: {response.status_code}")
|
logger.error(f"Failed to download the file. Status code: {response.status_code}")
|
||||||
return
|
return None
|
||||||
|
|
||||||
os.makedirs(download_location, exist_ok=True)
|
os.makedirs(download_location, exist_ok=True)
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ SUBPROCESS_TIMEOUT = 5
|
|||||||
|
|
||||||
class BaseRenderEngine(object):
|
class BaseRenderEngine(object):
|
||||||
"""Base class for render engines. This class provides common functionality and structure for various rendering
|
"""Base class for render engines. This class provides common functionality and structure for various rendering
|
||||||
engines. Create subclasses and override the methods marked below to add additional renderers
|
engines. Create subclasses and override the methods marked below to add additional engines
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
install_paths (list): A list of default installation paths where the render engine
|
install_paths (list): A list of default installation paths where the render engine
|
||||||
@@ -24,13 +24,13 @@ class BaseRenderEngine(object):
|
|||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
|
|
||||||
def __init__(self, custom_path=None):
|
def __init__(self, custom_path=None):
|
||||||
self.custom_renderer_path = custom_path
|
self.custom_engine_path = custom_path
|
||||||
if not self.renderer_path() or not os.path.exists(self.renderer_path()):
|
if not self.engine_path() or not os.path.exists(self.engine_path()):
|
||||||
raise FileNotFoundError(f"Cannot find path to renderer for {self.name()} instance: {self.renderer_path()}")
|
raise FileNotFoundError(f"Cannot find path to engine for {self.name()} instance: {self.engine_path()}")
|
||||||
|
|
||||||
if not os.access(self.renderer_path(), os.X_OK):
|
if not os.access(self.engine_path(), os.X_OK):
|
||||||
logger.warning(f"Path is not executable. Setting permissions to 755 for {self.renderer_path()}")
|
logger.warning(f"Path is not executable. Setting permissions to 755 for {self.engine_path()}")
|
||||||
os.chmod(self.renderer_path(), 0o755)
|
os.chmod(self.engine_path(), 0o755)
|
||||||
|
|
||||||
def version(self):
|
def version(self):
|
||||||
"""Return the version number as a string.
|
"""Return the version number as a string.
|
||||||
@@ -60,7 +60,7 @@ class BaseRenderEngine(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_output_formats(cls):
|
def get_output_formats(cls):
|
||||||
"""Returns a list of available output formats supported by the renderer.
|
"""Returns a list of available output formats supported by the engine.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[str]: A list of strings representing the available output formats.
|
list[str]: A list of strings representing the available output formats.
|
||||||
@@ -83,20 +83,20 @@ class BaseRenderEngine(object):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
def get_help(self):
|
def get_help(self):
|
||||||
"""Retrieves the help documentation for the renderer.
|
"""Retrieves the help documentation for the engine.
|
||||||
|
|
||||||
This method runs the renderer's help command (default: '-h') and captures the output.
|
This method runs the engine's help command (default: '-h') and captures the output.
|
||||||
Override this method if the renderer uses a different help flag.
|
Override this method if the engine uses a different help flag.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str: The help documentation as a string.
|
str: The help documentation as a string.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
FileNotFoundError: If the renderer path is not found.
|
FileNotFoundError: If the engine path is not found.
|
||||||
"""
|
"""
|
||||||
path = self.renderer_path()
|
path = self.engine_path()
|
||||||
if not path:
|
if not path:
|
||||||
raise FileNotFoundError("renderer path not found")
|
raise FileNotFoundError(f"Engine path not found: {path}")
|
||||||
creationflags = subprocess.CREATE_NO_WINDOW if platform.system() == 'Windows' else 0
|
creationflags = subprocess.CREATE_NO_WINDOW if platform.system() == 'Windows' else 0
|
||||||
help_doc = subprocess.check_output([path, '-h'], stderr=subprocess.STDOUT,
|
help_doc = subprocess.check_output([path, '-h'], stderr=subprocess.STDOUT,
|
||||||
timeout=SUBPROCESS_TIMEOUT, creationflags=creationflags).decode('utf-8')
|
timeout=SUBPROCESS_TIMEOUT, creationflags=creationflags).decode('utf-8')
|
||||||
@@ -141,15 +141,15 @@ class BaseRenderEngine(object):
|
|||||||
# Do Not Override These Methods:
|
# Do Not Override These Methods:
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
|
|
||||||
def renderer_path(self):
|
def engine_path(self):
|
||||||
return self.custom_renderer_path or self.default_renderer_path()
|
return self.custom_engine_path or self.default_engine_path()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def name(cls):
|
def name(cls):
|
||||||
return str(cls.__name__).lower()
|
return str(cls.__name__).lower()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_renderer_path(cls):
|
def default_engine_path(cls):
|
||||||
path = None
|
path = None
|
||||||
try: # Linux and macOS
|
try: # Linux and macOS
|
||||||
path = subprocess.check_output(['which', cls.name()], timeout=SUBPROCESS_TIMEOUT).decode('utf-8').strip()
|
path = subprocess.check_output(['which', cls.name()], timeout=SUBPROCESS_TIMEOUT).decode('utf-8').strip()
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ class BaseRenderWorker(Base):
|
|||||||
date_created = Column(DateTime)
|
date_created = Column(DateTime)
|
||||||
start_time = Column(DateTime, nullable=True)
|
start_time = Column(DateTime, nullable=True)
|
||||||
end_time = Column(DateTime, nullable=True)
|
end_time = Column(DateTime, nullable=True)
|
||||||
renderer = Column(String)
|
engine_name = Column(String)
|
||||||
renderer_version = Column(String)
|
engine_version = Column(String)
|
||||||
renderer_path = Column(String)
|
engine_path = Column(String)
|
||||||
priority = Column(Integer)
|
priority = Column(Integer)
|
||||||
project_length = Column(Integer)
|
project_length = Column(Integer)
|
||||||
start_frame = Column(Integer)
|
start_frame = Column(Integer)
|
||||||
@@ -46,8 +46,6 @@ class BaseRenderWorker(Base):
|
|||||||
file_hash = Column(String)
|
file_hash = Column(String)
|
||||||
_status = Column(String)
|
_status = Column(String)
|
||||||
|
|
||||||
engine = None
|
|
||||||
|
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
# Required Overrides for Subclasses:
|
# Required Overrides for Subclasses:
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
@@ -57,7 +55,7 @@ class BaseRenderWorker(Base):
|
|||||||
|
|
||||||
if not ignore_extensions:
|
if not ignore_extensions:
|
||||||
if not any(ext in input_path for ext in self.engine.supported_extensions()):
|
if not any(ext in input_path for ext in self.engine.supported_extensions()):
|
||||||
err_meg = f'Cannot find valid project with supported file extension for {self.engine.name()} renderer'
|
err_meg = f"Cannot find valid project with supported file extension for '{self.engine.name()}'"
|
||||||
logger.error(err_meg)
|
logger.error(err_meg)
|
||||||
raise ValueError(err_meg)
|
raise ValueError(err_meg)
|
||||||
if not self.engine:
|
if not self.engine:
|
||||||
@@ -74,10 +72,10 @@ class BaseRenderWorker(Base):
|
|||||||
self.output_path = output_path
|
self.output_path = output_path
|
||||||
self.args = args or {}
|
self.args = args or {}
|
||||||
self.date_created = datetime.now()
|
self.date_created = datetime.now()
|
||||||
self.renderer = self.engine.name()
|
self.engine_name = self.engine.name()
|
||||||
self.renderer_path = engine_path
|
self.engine_path = engine_path
|
||||||
self.renderer_version = self.engine(engine_path).version()
|
self.engine_version = self.engine(engine_path).version()
|
||||||
self.custom_renderer_path = None
|
self.custom_engine_path = None
|
||||||
self.priority = priority
|
self.priority = priority
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.children = {}
|
self.children = {}
|
||||||
@@ -116,17 +114,17 @@ class BaseRenderWorker(Base):
|
|||||||
raise NotImplementedError("generate_worker_subprocess not implemented")
|
raise NotImplementedError("generate_worker_subprocess not implemented")
|
||||||
|
|
||||||
def _parse_stdout(self, line):
|
def _parse_stdout(self, line):
|
||||||
"""Parses a line of standard output from the renderer.
|
"""Parses a line of standard output from the engine.
|
||||||
|
|
||||||
This method should be overridden in a subclass to implement the logic for processing
|
This method should be overridden in a subclass to implement the logic for processing
|
||||||
and interpreting a single line of output from the renderer's standard output stream.
|
and interpreting a single line of output from the engine's standard output stream.
|
||||||
|
|
||||||
On frame completion, the subclass should:
|
On frame completion, the subclass should:
|
||||||
1. Update value of self.current_frame
|
1. Update value of self.current_frame
|
||||||
2. Call self._send_frame_complete_notification()
|
2. Call self._send_frame_complete_notification()
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
line (str): A line of text from the renderer's standard output.
|
line (str): A line of text from the engine's standard output.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
NotImplementedError: If the method is not overridden in a subclass.
|
NotImplementedError: If the method is not overridden in a subclass.
|
||||||
@@ -152,7 +150,7 @@ class BaseRenderWorker(Base):
|
|||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<Job id:{self.id} p{self.priority} {self.renderer}-{self.renderer_version} '{self.name}' status:{self.status.value}>"
|
return f"<Job id:{self.id} p{self.priority} {self.engine_name}-{self.engine_version} '{self.name}' status:{self.status.value}>"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def total_frames(self):
|
def total_frames(self):
|
||||||
@@ -215,7 +213,7 @@ class BaseRenderWorker(Base):
|
|||||||
self.errors.append(msg)
|
self.errors.append(msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
if not os.path.exists(self.renderer_path):
|
if not os.path.exists(self.engine_path):
|
||||||
self.status = RenderStatus.ERROR
|
self.status = RenderStatus.ERROR
|
||||||
msg = f'Cannot find render engine path for {self.engine.name()}'
|
msg = f'Cannot find render engine path for {self.engine.name()}'
|
||||||
logger.error(msg)
|
logger.error(msg)
|
||||||
@@ -269,14 +267,14 @@ class BaseRenderWorker(Base):
|
|||||||
logger.error(err_msg)
|
logger.error(err_msg)
|
||||||
self.errors.append(err_msg)
|
self.errors.append(err_msg)
|
||||||
|
|
||||||
# handle instances where renderer exits ok but doesnt generate files
|
# handle instances where engine exits ok but doesnt generate files
|
||||||
if not return_code and not file_count_has_increased:
|
if not return_code and not file_count_has_increased:
|
||||||
err_msg = (f"{self.engine.name()} render exited ok, but file count has not increased. "
|
err_msg = (f"{self.engine.name()} render exited ok, but file count has not increased. "
|
||||||
f"Count is still {len(self.file_list())}")
|
f"Count is still {len(self.file_list())}")
|
||||||
log_file.write(f'Error: {err_msg}\n\n')
|
log_file.write(f'Error: {err_msg}\n\n')
|
||||||
self.errors.append(err_msg)
|
self.errors.append(err_msg)
|
||||||
|
|
||||||
# only count the attempt as failed if renderer creates no output - reset counter on successful output
|
# only count the attempt as failed if engine creates no output - reset counter on successful output
|
||||||
failed_attempts = 0 if file_count_has_increased else failed_attempts + 1
|
failed_attempts = 0 if file_count_has_increased else failed_attempts + 1
|
||||||
|
|
||||||
def __run__wait_for_subjobs(self, logfile):
|
def __run__wait_for_subjobs(self, logfile):
|
||||||
@@ -302,7 +300,7 @@ class BaseRenderWorker(Base):
|
|||||||
with open(self.log_path(), "a") as log_file:
|
with open(self.log_path(), "a") as log_file:
|
||||||
|
|
||||||
self.log_and_print(f"{self.start_time.isoformat()} - Starting "
|
self.log_and_print(f"{self.start_time.isoformat()} - Starting "
|
||||||
f"{self.engine.name()} {self.renderer_version} render job for {self.name} "
|
f"{self.engine.name()} {self.engine_version} render job for {self.name} "
|
||||||
f"({self.input_path})", log_file)
|
f"({self.input_path})", log_file)
|
||||||
log_file.write(f"\n")
|
log_file.write(f"\n")
|
||||||
if not self.children:
|
if not self.children:
|
||||||
@@ -493,8 +491,8 @@ class BaseRenderWorker(Base):
|
|||||||
'file_hash': self.file_hash,
|
'file_hash': self.file_hash,
|
||||||
'percent_complete': self.percent_complete(),
|
'percent_complete': self.percent_complete(),
|
||||||
'file_count': len(self.file_list()),
|
'file_count': len(self.file_list()),
|
||||||
'renderer': self.renderer,
|
'engine': self.engine_name,
|
||||||
'renderer_version': self.renderer_version,
|
'engine_version': self.engine_version,
|
||||||
'errors': getattr(self, 'errors', None),
|
'errors': getattr(self, 'errors', None),
|
||||||
'start_frame': self.start_frame,
|
'start_frame': self.start_frame,
|
||||||
'end_frame': self.end_frame,
|
'end_frame': self.end_frame,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ logger = logging.getLogger()
|
|||||||
|
|
||||||
|
|
||||||
class EngineManager:
|
class EngineManager:
|
||||||
"""Class that manages different versions of installed renderers and handles fetching and downloading new versions,
|
"""Class that manages different versions of installed render engines and handles fetching and downloading new versions,
|
||||||
if possible.
|
if possible.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -23,6 +23,14 @@ class EngineManager:
|
|||||||
def supported_engines():
|
def supported_engines():
|
||||||
return [Blender, FFMPEG]
|
return [Blender, FFMPEG]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def downloadable_engines(cls):
|
||||||
|
return [engine for engine in cls.supported_engines() if hasattr(engine, "downloader") and engine.downloader()]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def active_downloads(cls) -> list:
|
||||||
|
return [x for x in cls.download_tasks if x.is_alive()]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def engine_with_name(cls, engine_name):
|
def engine_with_name(cls, engine_name):
|
||||||
for obj in cls.supported_engines():
|
for obj in cls.supported_engines():
|
||||||
@@ -30,7 +38,15 @@ class EngineManager:
|
|||||||
return obj
|
return obj
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_engines(cls, filter_name=None, include_corrupt=False):
|
def update_all_engines(cls):
|
||||||
|
for engine in cls.downloadable_engines():
|
||||||
|
update_available = cls.is_engine_update_available(engine)
|
||||||
|
if update_available:
|
||||||
|
update_available['name'] = engine.name()
|
||||||
|
cls.download_engine(engine.name(), update_available['version'], background=True)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_engines(cls, filter_name=None, include_corrupt=False, ignore_system=False):
|
||||||
|
|
||||||
if not cls.engines_path:
|
if not cls.engines_path:
|
||||||
raise FileNotFoundError("Engine path is not set")
|
raise FileNotFoundError("Engine path is not set")
|
||||||
@@ -63,13 +79,13 @@ class EngineManager:
|
|||||||
)
|
)
|
||||||
result_dict['path'] = path
|
result_dict['path'] = path
|
||||||
|
|
||||||
# fetch version number from binary - helps detect corrupted downloads
|
# fetch version number from binary - helps detect corrupted downloads - disabled due to perf issues
|
||||||
binary_version = eng(path).version()
|
# binary_version = eng(path).version()
|
||||||
if not binary_version:
|
# if not binary_version:
|
||||||
logger.warning(f"Possible corrupt {eng.name()} {result_dict['version']} install detected: {path}")
|
# logger.warning(f"Possible corrupt {eng.name()} {result_dict['version']} install detected: {path}")
|
||||||
if not include_corrupt:
|
# if not include_corrupt:
|
||||||
continue
|
# continue
|
||||||
result_dict['version'] = binary_version or 'error'
|
# result_dict['version'] = binary_version or 'error'
|
||||||
|
|
||||||
# Add the result dictionary to results if it matches the filter_name or if no filter is applied
|
# Add the result dictionary to results if it matches the filter_name or if no filter is applied
|
||||||
if not filter_name or filter_name == result_dict['engine']:
|
if not filter_name or filter_name == result_dict['engine']:
|
||||||
@@ -88,50 +104,51 @@ class EngineManager:
|
|||||||
'version': version or 'error',
|
'version': version or 'error',
|
||||||
'system_os': current_system_os(),
|
'system_os': current_system_os(),
|
||||||
'cpu': current_system_cpu(),
|
'cpu': current_system_cpu(),
|
||||||
'path': eng.default_renderer_path(),
|
'path': eng.default_engine_path(),
|
||||||
'type': 'system'
|
'type': 'system'
|
||||||
}
|
}
|
||||||
|
|
||||||
with concurrent.futures.ThreadPoolExecutor() as executor:
|
if not ignore_system:
|
||||||
futures = {
|
with concurrent.futures.ThreadPoolExecutor() as executor:
|
||||||
executor.submit(fetch_engine_details, eng, include_corrupt): eng.name()
|
futures = {
|
||||||
for eng in cls.supported_engines()
|
executor.submit(fetch_engine_details, eng, include_corrupt): eng.name()
|
||||||
if eng.default_renderer_path() and (not filter_name or filter_name == eng.name())
|
for eng in cls.supported_engines()
|
||||||
}
|
if eng.default_engine_path() and (not filter_name or filter_name == eng.name())
|
||||||
|
}
|
||||||
|
|
||||||
for future in concurrent.futures.as_completed(futures):
|
for future in concurrent.futures.as_completed(futures):
|
||||||
result = future.result()
|
result = future.result()
|
||||||
if result:
|
if result:
|
||||||
results.append(result)
|
results.append(result)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def all_versions_for_engine(cls, engine_name, include_corrupt=False):
|
def all_versions_for_engine(cls, engine_name, include_corrupt=False, ignore_system=False):
|
||||||
versions = cls.get_engines(filter_name=engine_name, include_corrupt=include_corrupt)
|
versions = cls.get_engines(filter_name=engine_name, include_corrupt=include_corrupt, ignore_system=ignore_system)
|
||||||
sorted_versions = sorted(versions, key=lambda x: x['version'], reverse=True)
|
sorted_versions = sorted(versions, key=lambda x: x['version'], reverse=True)
|
||||||
return sorted_versions
|
return sorted_versions
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def newest_engine_version(cls, engine, system_os=None, cpu=None):
|
def newest_engine_version(cls, engine, system_os=None, cpu=None, ignore_system=None):
|
||||||
system_os = system_os or current_system_os()
|
system_os = system_os or current_system_os()
|
||||||
cpu = cpu or current_system_cpu()
|
cpu = cpu or current_system_cpu()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
filtered = [x for x in cls.all_versions_for_engine(engine) if x['system_os'] == system_os and
|
filtered = [x for x in cls.all_versions_for_engine(engine, ignore_system=ignore_system)
|
||||||
x['cpu'] == cpu]
|
if x['system_os'] == system_os and x['cpu'] == cpu]
|
||||||
return filtered[0]
|
return filtered[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
logger.error(f"Cannot find newest engine version for {engine}-{system_os}-{cpu}")
|
logger.error(f"Cannot find newest engine version for {engine}-{system_os}-{cpu}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_version_downloaded(cls, engine, version, system_os=None, cpu=None):
|
def is_version_downloaded(cls, engine, version, system_os=None, cpu=None, ignore_system=False):
|
||||||
system_os = system_os or current_system_os()
|
system_os = system_os or current_system_os()
|
||||||
cpu = cpu or current_system_cpu()
|
cpu = cpu or current_system_cpu()
|
||||||
|
|
||||||
filtered = [x for x in cls.get_engines(filter_name=engine) if x['system_os'] == system_os and
|
filtered = [x for x in cls.get_engines(filter_name=engine, ignore_system=ignore_system) if
|
||||||
x['cpu'] == cpu and x['version'] == version]
|
x['system_os'] == system_os and x['cpu'] == cpu and x['version'] == version]
|
||||||
return filtered[0] if filtered else False
|
return filtered[0] if filtered else False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -164,7 +181,7 @@ class EngineManager:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def download_engine(cls, engine, version, system_os=None, cpu=None, background=False):
|
def download_engine(cls, engine, version, system_os=None, cpu=None, background=False, ignore_system=False):
|
||||||
|
|
||||||
engine_to_download = cls.engine_with_name(engine)
|
engine_to_download = cls.engine_with_name(engine)
|
||||||
existing_task = cls.get_existing_download_task(engine, version, system_os, cpu)
|
existing_task = cls.get_existing_download_task(engine, version, system_os, cpu)
|
||||||
@@ -172,10 +189,10 @@ class EngineManager:
|
|||||||
logger.debug(f"Already downloading {engine} {version}")
|
logger.debug(f"Already downloading {engine} {version}")
|
||||||
if not background:
|
if not background:
|
||||||
existing_task.join() # If download task exists, wait until it's done downloading
|
existing_task.join() # If download task exists, wait until it's done downloading
|
||||||
return
|
return None
|
||||||
elif not engine_to_download.downloader():
|
elif not engine_to_download.downloader():
|
||||||
logger.warning("No valid downloader for this engine. Please update this software manually.")
|
logger.warning("No valid downloader for this engine. Please update this software manually.")
|
||||||
return
|
return None
|
||||||
elif not cls.engines_path:
|
elif not cls.engines_path:
|
||||||
raise FileNotFoundError("Engines path must be set before requesting downloads")
|
raise FileNotFoundError("Engines path must be set before requesting downloads")
|
||||||
|
|
||||||
@@ -187,7 +204,7 @@ class EngineManager:
|
|||||||
return thread
|
return thread
|
||||||
|
|
||||||
thread.join()
|
thread.join()
|
||||||
found_engine = cls.is_version_downloaded(engine, version, system_os, cpu) # Check that engine downloaded
|
found_engine = cls.is_version_downloaded(engine, version, system_os, cpu, ignore_system) # Check that engine downloaded
|
||||||
if not found_engine:
|
if not found_engine:
|
||||||
logger.error(f"Error downloading {engine}")
|
logger.error(f"Error downloading {engine}")
|
||||||
return found_engine
|
return found_engine
|
||||||
@@ -213,41 +230,31 @@ class EngineManager:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def update_all_engines(cls):
|
def is_engine_update_available(cls, engine_class, ignore_system_installs=False):
|
||||||
def engine_update_task(engine_class):
|
logger.debug(f"Checking for updates to {engine_class.name()}")
|
||||||
logger.debug(f"Checking for updates to {engine_class.name()}")
|
latest_version = engine_class.downloader().find_most_recent_version()
|
||||||
latest_version = engine_class.downloader().find_most_recent_version()
|
|
||||||
|
|
||||||
if not latest_version:
|
if not latest_version:
|
||||||
logger.warning(f"Could not find most recent version of {engine.name()} to download")
|
logger.warning(f"Could not find most recent version of {engine_class.name()} to download")
|
||||||
return
|
return None
|
||||||
|
|
||||||
version_num = latest_version.get('version')
|
version_num = latest_version.get('version')
|
||||||
if cls.is_version_downloaded(engine_class.name(), version_num):
|
if cls.is_version_downloaded(engine_class.name(), version_num, ignore_system=ignore_system_installs):
|
||||||
logger.debug(f"Latest version of {engine_class.name()} ({version_num}) already downloaded")
|
logger.debug(f"Latest version of {engine_class.name()} ({version_num}) already downloaded")
|
||||||
return
|
return None
|
||||||
|
|
||||||
# download the engine
|
return latest_version
|
||||||
logger.info(f"Downloading latest version of {engine_class.name()} ({version_num})...")
|
|
||||||
cls.download_engine(engine=engine_class.name(), version=version_num, background=True)
|
|
||||||
|
|
||||||
logger.info(f"Checking for updates for render engines...")
|
|
||||||
threads = []
|
|
||||||
for engine in cls.supported_engines():
|
|
||||||
if engine.downloader():
|
|
||||||
thread = threading.Thread(target=engine_update_task, args=(engine,))
|
|
||||||
threads.append(thread)
|
|
||||||
thread.start()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_worker(cls, renderer, input_path, output_path, engine_version=None, args=None, parent=None, name=None):
|
def create_worker(cls, engine_name, input_path, output_path, engine_version=None, args=None, parent=None, name=None):
|
||||||
|
|
||||||
worker_class = cls.engine_with_name(renderer).worker_class()
|
worker_class = cls.engine_with_name(engine_name).worker_class()
|
||||||
|
|
||||||
# check to make sure we have versions installed
|
# check to make sure we have versions installed
|
||||||
all_versions = cls.all_versions_for_engine(renderer)
|
all_versions = cls.all_versions_for_engine(engine_name)
|
||||||
if not all_versions:
|
if not all_versions:
|
||||||
raise FileNotFoundError(f"Cannot find any installed {renderer} engines")
|
raise FileNotFoundError(f"Cannot find any installed '{engine_name}' engines")
|
||||||
|
|
||||||
# Find the path to the requested engine version or use default
|
# Find the path to the requested engine version or use default
|
||||||
engine_path = None
|
engine_path = None
|
||||||
@@ -259,9 +266,9 @@ class EngineManager:
|
|||||||
|
|
||||||
# Download the required engine if not found locally
|
# Download the required engine if not found locally
|
||||||
if not engine_path:
|
if not engine_path:
|
||||||
download_result = cls.download_engine(renderer, engine_version)
|
download_result = cls.download_engine(engine_name, engine_version)
|
||||||
if not download_result:
|
if not download_result:
|
||||||
raise FileNotFoundError(f"Cannot download requested version: {renderer} {engine_version}")
|
raise FileNotFoundError(f"Cannot download requested version: {engine_name} {engine_version}")
|
||||||
engine_path = download_result['path']
|
engine_path = download_result['path']
|
||||||
logger.info("Engine downloaded. Creating worker.")
|
logger.info("Engine downloaded. Creating worker.")
|
||||||
else:
|
else:
|
||||||
@@ -303,20 +310,28 @@ class EngineDownloadWorker(threading.Thread):
|
|||||||
self.version = version
|
self.version = version
|
||||||
self.system_os = system_os
|
self.system_os = system_os
|
||||||
self.cpu = cpu
|
self.cpu = cpu
|
||||||
|
self.percent_complete = 0
|
||||||
|
|
||||||
|
def _update_progress(self, current_progress):
|
||||||
|
self.percent_complete = current_progress
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
existing_download = EngineManager.is_version_downloaded(self.engine, self.version, self.system_os, self.cpu)
|
try:
|
||||||
if existing_download:
|
existing_download = EngineManager.is_version_downloaded(self.engine, self.version, self.system_os, self.cpu,
|
||||||
logger.info(f"Requested download of {self.engine} {self.version}, but local copy already exists")
|
ignore_system=True)
|
||||||
return existing_download
|
if existing_download:
|
||||||
|
logger.info(f"Requested download of {self.engine} {self.version}, but local copy already exists")
|
||||||
|
return existing_download
|
||||||
|
|
||||||
# Get the appropriate downloader class based on the engine type
|
# Get the appropriate downloader class based on the engine type
|
||||||
EngineManager.engine_with_name(self.engine).downloader().download_engine(
|
downloader = EngineManager.engine_with_name(self.engine).downloader()
|
||||||
self.version, download_location=EngineManager.engines_path, system_os=self.system_os, cpu=self.cpu,
|
downloader.download_engine( self.version, download_location=EngineManager.engines_path,
|
||||||
timeout=300)
|
system_os=self.system_os, cpu=self.cpu, timeout=300, progress_callback=self._update_progress)
|
||||||
|
except Exception as e:
|
||||||
# remove itself from the downloader list
|
logger.error(f"Error in download worker: {e}")
|
||||||
EngineManager.download_tasks.remove(self)
|
finally:
|
||||||
|
# remove itself from the downloader list
|
||||||
|
EngineManager.download_tasks.remove(self)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class FFMPEGDownloader(EngineDownloader):
|
|||||||
'windows': cls.__get_windows_versions}
|
'windows': cls.__get_windows_versions}
|
||||||
if not versions_per_os.get(system_os):
|
if not versions_per_os.get(system_os):
|
||||||
logger.error(f"Cannot find version list for {system_os}")
|
logger.error(f"Cannot find version list for {system_os}")
|
||||||
return
|
return None
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
all_versions = versions_per_os[system_os]()
|
all_versions = versions_per_os[system_os]()
|
||||||
@@ -144,7 +144,7 @@ class FFMPEGDownloader(EngineDownloader):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def download_engine(cls, version, download_location, system_os=None, cpu=None, timeout=120):
|
def download_engine(cls, version, download_location, system_os=None, cpu=None, timeout=120, progress_callback=None):
|
||||||
system_os = system_os or current_system_os()
|
system_os = system_os or current_system_os()
|
||||||
cpu = cpu or current_system_cpu()
|
cpu = cpu or current_system_cpu()
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ class FFMPEGDownloader(EngineDownloader):
|
|||||||
found_version = [item for item in cls.all_versions(system_os, cpu) if item['version'] == version]
|
found_version = [item for item in cls.all_versions(system_os, cpu) if item['version'] == version]
|
||||||
if not found_version:
|
if not found_version:
|
||||||
logger.error(f"Cannot find FFMPEG version {version} for {system_os} and {cpu}")
|
logger.error(f"Cannot find FFMPEG version {version} for {system_os} and {cpu}")
|
||||||
return
|
return None
|
||||||
|
|
||||||
# Platform specific naming cleanup
|
# Platform specific naming cleanup
|
||||||
remote_url = cls.__get_remote_url_for_version(version=version, system_os=system_os, cpu=cpu)
|
remote_url = cls.__get_remote_url_for_version(version=version, system_os=system_os, cpu=cpu)
|
||||||
@@ -162,7 +162,8 @@ class FFMPEGDownloader(EngineDownloader):
|
|||||||
# Download and extract
|
# Download and extract
|
||||||
try:
|
try:
|
||||||
logger.info(f"Requesting download of ffmpeg-{version}-{system_os}-{cpu}")
|
logger.info(f"Requesting download of ffmpeg-{version}-{system_os}-{cpu}")
|
||||||
cls.download_and_extract_app(remote_url=remote_url, download_location=download_location, timeout=timeout)
|
cls.download_and_extract_app(remote_url=remote_url, download_location=download_location, timeout=timeout,
|
||||||
|
progress_callback=progress_callback)
|
||||||
|
|
||||||
# naming cleanup to match existing naming convention
|
# naming cleanup to match existing naming convention
|
||||||
output_path = os.path.join(download_location, f'ffmpeg-{version}-{system_os}-{cpu}')
|
output_path = os.path.join(download_location, f'ffmpeg-{version}-{system_os}-{cpu}')
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class FFMPEG(BaseRenderEngine):
|
|||||||
return FFMPEGUI.get_options(self)
|
return FFMPEGUI.get_options(self)
|
||||||
|
|
||||||
def supported_extensions(self):
|
def supported_extensions(self):
|
||||||
help_text = (subprocess.check_output([self.renderer_path(), '-h', 'full'], stderr=subprocess.STDOUT,
|
help_text = (subprocess.check_output([self.engine_path(), '-h', 'full'], stderr=subprocess.STDOUT,
|
||||||
creationflags=_creationflags).decode('utf-8'))
|
creationflags=_creationflags).decode('utf-8'))
|
||||||
found = re.findall(r'extensions that .* is allowed to access \(default "(.*)"', help_text)
|
found = re.findall(r'extensions that .* is allowed to access \(default "(.*)"', help_text)
|
||||||
found_extensions = set()
|
found_extensions = set()
|
||||||
@@ -35,7 +35,7 @@ class FFMPEG(BaseRenderEngine):
|
|||||||
def version(self):
|
def version(self):
|
||||||
version = None
|
version = None
|
||||||
try:
|
try:
|
||||||
ver_out = subprocess.check_output([self.renderer_path(), '-version'], timeout=SUBPROCESS_TIMEOUT,
|
ver_out = subprocess.check_output([self.engine_path(), '-version'], timeout=SUBPROCESS_TIMEOUT,
|
||||||
creationflags=_creationflags).decode('utf-8')
|
creationflags=_creationflags).decode('utf-8')
|
||||||
match = re.match(r".*version\s*([\w.*]+)\W*", ver_out)
|
match = re.match(r".*version\s*([\w.*]+)\W*", ver_out)
|
||||||
if match:
|
if match:
|
||||||
@@ -82,7 +82,7 @@ class FFMPEG(BaseRenderEngine):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_encoders(self):
|
def get_encoders(self):
|
||||||
raw_stdout = subprocess.check_output([self.renderer_path(), '-encoders'], stderr=subprocess.DEVNULL,
|
raw_stdout = subprocess.check_output([self.engine_path(), '-encoders'], stderr=subprocess.DEVNULL,
|
||||||
timeout=SUBPROCESS_TIMEOUT, creationflags=_creationflags).decode('utf-8')
|
timeout=SUBPROCESS_TIMEOUT, creationflags=_creationflags).decode('utf-8')
|
||||||
pattern = r'(?P<type>[VASFXBD.]{6})\s+(?P<name>\S{2,})\s+(?P<description>.*)'
|
pattern = r'(?P<type>[VASFXBD.]{6})\s+(?P<name>\S{2,})\s+(?P<description>.*)'
|
||||||
encoders = [m.groupdict() for m in re.finditer(pattern, raw_stdout)]
|
encoders = [m.groupdict() for m in re.finditer(pattern, raw_stdout)]
|
||||||
@@ -94,7 +94,7 @@ class FFMPEG(BaseRenderEngine):
|
|||||||
|
|
||||||
def get_all_formats(self):
|
def get_all_formats(self):
|
||||||
try:
|
try:
|
||||||
formats_raw = subprocess.check_output([self.renderer_path(), '-formats'], stderr=subprocess.DEVNULL,
|
formats_raw = subprocess.check_output([self.engine_path(), '-formats'], stderr=subprocess.DEVNULL,
|
||||||
timeout=SUBPROCESS_TIMEOUT,
|
timeout=SUBPROCESS_TIMEOUT,
|
||||||
creationflags=_creationflags).decode('utf-8')
|
creationflags=_creationflags).decode('utf-8')
|
||||||
pattern = r'(?P<type>[DE]{1,2})\s+(?P<id>\S{2,})\s+(?P<name>.*)'
|
pattern = r'(?P<type>[DE]{1,2})\s+(?P<id>\S{2,})\s+(?P<name>.*)'
|
||||||
@@ -108,7 +108,7 @@ class FFMPEG(BaseRenderEngine):
|
|||||||
# Extract the common extension using regex
|
# Extract the common extension using regex
|
||||||
muxer_flag = 'muxer' if 'E' in ffmpeg_format['type'] else 'demuxer'
|
muxer_flag = 'muxer' if 'E' in ffmpeg_format['type'] else 'demuxer'
|
||||||
format_detail_raw = subprocess.check_output(
|
format_detail_raw = subprocess.check_output(
|
||||||
[self.renderer_path(), '-hide_banner', '-h', f"{muxer_flag}={ffmpeg_format['id']}"],
|
[self.engine_path(), '-hide_banner', '-h', f"{muxer_flag}={ffmpeg_format['id']}"],
|
||||||
creationflags=_creationflags).decode('utf-8')
|
creationflags=_creationflags).decode('utf-8')
|
||||||
pattern = r"Common extensions: (\w+)"
|
pattern = r"Common extensions: (\w+)"
|
||||||
common_extensions = re.findall(pattern, format_detail_raw)
|
common_extensions = re.findall(pattern, format_detail_raw)
|
||||||
@@ -121,7 +121,7 @@ class FFMPEG(BaseRenderEngine):
|
|||||||
return [x['id'] for x in self.get_all_formats() if 'E' in x['type'].upper()]
|
return [x['id'] for x in self.get_all_formats() if 'E' in x['type'].upper()]
|
||||||
|
|
||||||
def get_frame_count(self, path_to_file):
|
def get_frame_count(self, path_to_file):
|
||||||
raw_stdout = subprocess.check_output([self.renderer_path(), '-i', path_to_file, '-map', '0:v:0', '-c', 'copy',
|
raw_stdout = subprocess.check_output([self.engine_path(), '-i', path_to_file, '-map', '0:v:0', '-c', 'copy',
|
||||||
'-f', 'null', '-'], stderr=subprocess.STDOUT,
|
'-f', 'null', '-'], stderr=subprocess.STDOUT,
|
||||||
timeout=SUBPROCESS_TIMEOUT, creationflags=_creationflags).decode('utf-8')
|
timeout=SUBPROCESS_TIMEOUT, creationflags=_creationflags).decode('utf-8')
|
||||||
match = re.findall(r'frame=\s*(\d+)', raw_stdout)
|
match = re.findall(r'frame=\s*(\d+)', raw_stdout)
|
||||||
@@ -131,7 +131,7 @@ class FFMPEG(BaseRenderEngine):
|
|||||||
return -1
|
return -1
|
||||||
|
|
||||||
def get_arguments(self):
|
def get_arguments(self):
|
||||||
help_text = (subprocess.check_output([self.renderer_path(), '-h', 'long'], stderr=subprocess.STDOUT,
|
help_text = (subprocess.check_output([self.engine_path(), '-h', 'long'], stderr=subprocess.STDOUT,
|
||||||
creationflags=_creationflags).decode('utf-8'))
|
creationflags=_creationflags).decode('utf-8'))
|
||||||
lines = help_text.splitlines()
|
lines = help_text.splitlines()
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class FFMPEGRenderWorker(BaseRenderWorker):
|
|||||||
|
|
||||||
def generate_worker_subprocess(self):
|
def generate_worker_subprocess(self):
|
||||||
|
|
||||||
cmd = [self.renderer_path, '-y', '-stats', '-i', self.input_path]
|
cmd = [self.engine_path, '-y', '-stats', '-i', self.input_path]
|
||||||
|
|
||||||
# Resize frame
|
# Resize frame
|
||||||
if self.args.get('x_resolution', None) and self.args.get('y_resolution', None):
|
if self.args.get('x_resolution', None) and self.args.get('y_resolution', None):
|
||||||
|
|||||||
-156
@@ -1,156 +0,0 @@
|
|||||||
import logging
|
|
||||||
import multiprocessing
|
|
||||||
import os
|
|
||||||
import socket
|
|
||||||
import sys
|
|
||||||
import threading
|
|
||||||
from collections import deque
|
|
||||||
|
|
||||||
from src.api.api_server import start_server
|
|
||||||
from src.api.preview_manager import PreviewManager
|
|
||||||
from src.api.serverproxy_manager import ServerProxyManager
|
|
||||||
from src.distributed_job_manager import DistributedJobManager
|
|
||||||
from src.engines.engine_manager import EngineManager
|
|
||||||
from src.render_queue import RenderQueue
|
|
||||||
from src.utilities.config import Config
|
|
||||||
from src.utilities.misc_helper import system_safe_path, current_system_cpu, current_system_os, current_system_os_version
|
|
||||||
from src.utilities.zeroconf_server import ZeroconfServer
|
|
||||||
|
|
||||||
logger = logging.getLogger()
|
|
||||||
|
|
||||||
|
|
||||||
def run(server_only=False) -> int:
|
|
||||||
"""Initializes the application and runs it.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
server_only: Run in server-only CLI mode. Default is False (runs in GUI mode).
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
int: The exit status code.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# setup logging
|
|
||||||
logging.basicConfig(format='%(asctime)s: %(levelname)s: %(module)s: %(message)s', datefmt='%d-%b-%y %H:%M:%S',
|
|
||||||
level=Config.server_log_level.upper())
|
|
||||||
logging.getLogger("requests").setLevel(logging.WARNING) # suppress noisy requests/urllib3 logging
|
|
||||||
logging.getLogger("urllib3").setLevel(logging.WARNING)
|
|
||||||
|
|
||||||
# Setup logging for console ui
|
|
||||||
buffer_handler = __setup_buffer_handler() if not server_only else None
|
|
||||||
|
|
||||||
logger.info(f"Starting Zordon Render Server")
|
|
||||||
return_code = 0
|
|
||||||
try:
|
|
||||||
# Load Config YAML
|
|
||||||
Config.setup_config_dir()
|
|
||||||
Config.load_config(system_safe_path(os.path.join(Config.config_dir(), 'config.yaml')))
|
|
||||||
|
|
||||||
# configure default paths
|
|
||||||
EngineManager.engines_path = system_safe_path(
|
|
||||||
os.path.join(os.path.join(os.path.expanduser(Config.upload_folder),
|
|
||||||
'engines')))
|
|
||||||
os.makedirs(EngineManager.engines_path, exist_ok=True)
|
|
||||||
PreviewManager.storage_path = system_safe_path(
|
|
||||||
os.path.join(os.path.expanduser(Config.upload_folder), 'previews'))
|
|
||||||
|
|
||||||
# Debug info
|
|
||||||
logger.debug(f"Upload directory: {os.path.expanduser(Config.upload_folder)}")
|
|
||||||
logger.debug(f"Thumbs directory: {PreviewManager.storage_path}")
|
|
||||||
logger.debug(f"Engines directory: {EngineManager.engines_path}")
|
|
||||||
|
|
||||||
# Set up the RenderQueue object
|
|
||||||
RenderQueue.load_state(database_directory=system_safe_path(os.path.expanduser(Config.upload_folder)))
|
|
||||||
ServerProxyManager.subscribe_to_listener()
|
|
||||||
DistributedJobManager.subscribe_to_listener()
|
|
||||||
|
|
||||||
# check for updates for render engines if configured or on first launch
|
|
||||||
if Config.update_engines_on_launch or not EngineManager.get_engines():
|
|
||||||
EngineManager.update_all_engines()
|
|
||||||
|
|
||||||
# get hostname
|
|
||||||
local_hostname = socket.gethostname()
|
|
||||||
local_hostname = local_hostname + (".local" if not local_hostname.endswith(".local") else "")
|
|
||||||
|
|
||||||
# configure and start API server
|
|
||||||
api_server = threading.Thread(target=start_server, args=(local_hostname,))
|
|
||||||
api_server.daemon = True
|
|
||||||
api_server.start()
|
|
||||||
|
|
||||||
# start zeroconf server
|
|
||||||
ZeroconfServer.configure("_zordon._tcp.local.", local_hostname, Config.port_number)
|
|
||||||
ZeroconfServer.properties = {'system_cpu': current_system_cpu(),
|
|
||||||
'system_cpu_cores': multiprocessing.cpu_count(),
|
|
||||||
'system_os': current_system_os(),
|
|
||||||
'system_os_version': current_system_os_version()}
|
|
||||||
ZeroconfServer.start()
|
|
||||||
logger.info(f"Zordon Render Server started - Hostname: {local_hostname}")
|
|
||||||
RenderQueue.start() # Start evaluating the render queue
|
|
||||||
|
|
||||||
# start in gui or server only (cli) mode
|
|
||||||
logger.debug(f"Launching in {'server only' if server_only else 'GUI'} mode")
|
|
||||||
if server_only: # CLI only
|
|
||||||
api_server.join()
|
|
||||||
else: # GUI
|
|
||||||
return_code = __show_gui(buffer_handler)
|
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
pass
|
|
||||||
except Exception as e:
|
|
||||||
logging.error(f"Unhandled exception: {e}")
|
|
||||||
return_code = 1
|
|
||||||
finally:
|
|
||||||
# shut down gracefully
|
|
||||||
logger.info(f"Zordon Render Server is preparing to shut down")
|
|
||||||
try:
|
|
||||||
RenderQueue.prepare_for_shutdown()
|
|
||||||
except Exception as e:
|
|
||||||
logger.exception(f"Exception during prepare for shutdown: {e}")
|
|
||||||
ZeroconfServer.stop()
|
|
||||||
logger.info(f"Zordon Render Server has shut down")
|
|
||||||
return sys.exit(return_code)
|
|
||||||
|
|
||||||
|
|
||||||
def __setup_buffer_handler():
|
|
||||||
# lazy load GUI frameworks
|
|
||||||
from PyQt6.QtCore import QObject, pyqtSignal
|
|
||||||
|
|
||||||
class BufferingHandler(logging.Handler, QObject):
|
|
||||||
new_record = pyqtSignal(str)
|
|
||||||
|
|
||||||
def __init__(self, capacity=100):
|
|
||||||
logging.Handler.__init__(self)
|
|
||||||
QObject.__init__(self)
|
|
||||||
self.buffer = deque(maxlen=capacity) # Define a buffer with a fixed capacity
|
|
||||||
|
|
||||||
def emit(self, record):
|
|
||||||
try:
|
|
||||||
msg = self.format(record)
|
|
||||||
self.buffer.append(msg) # Add message to the buffer
|
|
||||||
self.new_record.emit(msg) # Emit signal
|
|
||||||
except RuntimeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_buffer(self):
|
|
||||||
return list(self.buffer) # Return a copy of the buffer
|
|
||||||
|
|
||||||
buffer_handler = BufferingHandler()
|
|
||||||
buffer_handler.setFormatter(logging.getLogger().handlers[0].formatter)
|
|
||||||
new_logger = logging.getLogger()
|
|
||||||
new_logger.addHandler(buffer_handler)
|
|
||||||
return buffer_handler
|
|
||||||
|
|
||||||
|
|
||||||
def __show_gui(buffer_handler):
|
|
||||||
# lazy load GUI frameworks
|
|
||||||
from PyQt6.QtWidgets import QApplication
|
|
||||||
|
|
||||||
# load application
|
|
||||||
app: QApplication = QApplication(sys.argv)
|
|
||||||
|
|
||||||
# configure main window
|
|
||||||
from src.ui.main_window import MainWindow
|
|
||||||
window: MainWindow = MainWindow()
|
|
||||||
window.buffer_handler = buffer_handler
|
|
||||||
window.show()
|
|
||||||
|
|
||||||
return app.exec()
|
|
||||||
+2
-2
@@ -46,7 +46,7 @@ class RenderQueue:
|
|||||||
try:
|
try:
|
||||||
not_started = cls.jobs_with_status(RenderStatus.NOT_STARTED, priority_sorted=True)
|
not_started = cls.jobs_with_status(RenderStatus.NOT_STARTED, priority_sorted=True)
|
||||||
for job in not_started:
|
for job in not_started:
|
||||||
if cls.is_available_for_job(job.renderer, job.priority):
|
if cls.is_available_for_job(job.engine_name, job.priority):
|
||||||
cls.start_job(job)
|
cls.start_job(job)
|
||||||
|
|
||||||
scheduled = cls.jobs_with_status(RenderStatus.SCHEDULED, priority_sorted=True)
|
scheduled = cls.jobs_with_status(RenderStatus.SCHEDULED, priority_sorted=True)
|
||||||
@@ -145,7 +145,7 @@ class RenderQueue:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def renderer_instances(cls):
|
def renderer_instances(cls):
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
all_instances = [x.renderer for x in cls.running_jobs()]
|
all_instances = [x.engine_name for x in cls.running_jobs()]
|
||||||
return Counter(all_instances)
|
return Counter(all_instances)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from PyQt6.QtCore import Qt
|
|||||||
from PyQt6.QtGui import QPixmap
|
from PyQt6.QtGui import QPixmap
|
||||||
from PyQt6.QtWidgets import QDialog, QVBoxLayout, QLabel, QDialogButtonBox, QHBoxLayout
|
from PyQt6.QtWidgets import QDialog, QVBoxLayout, QLabel, QDialogButtonBox, QHBoxLayout
|
||||||
|
|
||||||
from version import *
|
from src.version import *
|
||||||
|
|
||||||
|
|
||||||
class AboutDialog(QDialog):
|
class AboutDialog(QDialog):
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ from requests import Response
|
|||||||
|
|
||||||
from src.api.server_proxy import RenderServerProxy
|
from src.api.server_proxy import RenderServerProxy
|
||||||
from src.engines.engine_manager import EngineManager
|
from src.engines.engine_manager import EngineManager
|
||||||
from src.ui.engine_help_viewer import EngineHelpViewer
|
from src.ui.engine_help_window import EngineHelpViewer
|
||||||
from src.utilities.zeroconf_server import ZeroconfServer
|
from src.utilities.zeroconf_server import ZeroconfServer
|
||||||
|
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ class NewRenderJobForm(QWidget):
|
|||||||
self.notes_group = None
|
self.notes_group = None
|
||||||
self.frame_rate_input = None
|
self.frame_rate_input = None
|
||||||
self.resolution_x_input = None
|
self.resolution_x_input = None
|
||||||
self.renderer_group = None
|
self.engine_group = None
|
||||||
self.output_settings_group = None
|
self.output_settings_group = None
|
||||||
self.resolution_y_input = None
|
self.resolution_y_input = None
|
||||||
self.project_path = project_path
|
self.project_path = project_path
|
||||||
@@ -34,17 +34,17 @@ class NewRenderJobForm(QWidget):
|
|||||||
self.load_file_group = None
|
self.load_file_group = None
|
||||||
self.current_engine_options = None
|
self.current_engine_options = None
|
||||||
self.file_format_combo = None
|
self.file_format_combo = None
|
||||||
self.renderer_options_layout = None
|
self.engine_options_layout = None
|
||||||
self.cameras_list = None
|
self.cameras_list = None
|
||||||
self.cameras_group = None
|
self.cameras_group = None
|
||||||
self.renderer_version_combo = None
|
self.engine_version_combo = None
|
||||||
self.worker_thread = None
|
self.worker_thread = None
|
||||||
self.msg_box = None
|
self.msg_box = None
|
||||||
self.engine_help_viewer = None
|
self.engine_help_viewer = None
|
||||||
self.raw_args = None
|
self.raw_args = None
|
||||||
self.submit_progress_label = None
|
self.submit_progress_label = None
|
||||||
self.submit_progress = None
|
self.submit_progress = None
|
||||||
self.renderer_type = None
|
self.engine_type = None
|
||||||
self.process_label = None
|
self.process_label = None
|
||||||
self.process_progress_bar = None
|
self.process_progress_bar = None
|
||||||
self.splitjobs_same_os = None
|
self.splitjobs_same_os = None
|
||||||
@@ -62,13 +62,13 @@ class NewRenderJobForm(QWidget):
|
|||||||
|
|
||||||
# Job / Server Data
|
# Job / Server Data
|
||||||
self.server_proxy = RenderServerProxy(socket.gethostname())
|
self.server_proxy = RenderServerProxy(socket.gethostname())
|
||||||
self.renderer_info = None
|
self.engine_info = None
|
||||||
self.project_info = None
|
self.project_info = None
|
||||||
|
|
||||||
# Setup
|
# Setup
|
||||||
self.setWindowTitle("New Job")
|
self.setWindowTitle("New Job")
|
||||||
self.setup_ui()
|
self.setup_ui()
|
||||||
self.update_renderer_info()
|
self.update_engine_info()
|
||||||
self.setup_project()
|
self.setup_project()
|
||||||
|
|
||||||
# get renderer info in bg thread
|
# get renderer info in bg thread
|
||||||
@@ -182,33 +182,33 @@ class NewRenderJobForm(QWidget):
|
|||||||
# add group to layout
|
# add group to layout
|
||||||
main_layout.addWidget(self.output_settings_group)
|
main_layout.addWidget(self.output_settings_group)
|
||||||
|
|
||||||
# Renderer Group
|
# Engine Group
|
||||||
self.renderer_group = QGroupBox("Renderer Settings")
|
self.engine_group = QGroupBox("Engine Settings")
|
||||||
renderer_group_layout = QVBoxLayout(self.renderer_group)
|
engine_group_layout = QVBoxLayout(self.engine_group)
|
||||||
renderer_layout = QHBoxLayout()
|
engine_layout = QHBoxLayout()
|
||||||
renderer_layout.addWidget(QLabel("Renderer:"))
|
engine_layout.addWidget(QLabel("Engine:"))
|
||||||
self.renderer_type = QComboBox()
|
self.engine_type = QComboBox()
|
||||||
self.renderer_type.currentIndexChanged.connect(self.renderer_changed)
|
self.engine_type.currentIndexChanged.connect(self.engine_changed)
|
||||||
renderer_layout.addWidget(self.renderer_type)
|
engine_layout.addWidget(self.engine_type)
|
||||||
# Version
|
# Version
|
||||||
renderer_layout.addWidget(QLabel("Version:"))
|
engine_layout.addWidget(QLabel("Version:"))
|
||||||
self.renderer_version_combo = QComboBox()
|
self.engine_version_combo = QComboBox()
|
||||||
self.renderer_version_combo.addItem('latest')
|
self.engine_version_combo.addItem('latest')
|
||||||
renderer_layout.addWidget(self.renderer_version_combo)
|
engine_layout.addWidget(self.engine_version_combo)
|
||||||
renderer_group_layout.addLayout(renderer_layout)
|
engine_group_layout.addLayout(engine_layout)
|
||||||
# dynamic options
|
# dynamic options
|
||||||
self.renderer_options_layout = QVBoxLayout()
|
self.engine_options_layout = QVBoxLayout()
|
||||||
renderer_group_layout.addLayout(self.renderer_options_layout)
|
engine_group_layout.addLayout(self.engine_options_layout)
|
||||||
# Raw Args
|
# Raw Args
|
||||||
raw_args_layout = QHBoxLayout(self.renderer_group)
|
raw_args_layout = QHBoxLayout(self.engine_group)
|
||||||
raw_args_layout.addWidget(QLabel("Raw Args:"))
|
raw_args_layout.addWidget(QLabel("Raw Args:"))
|
||||||
self.raw_args = QLineEdit()
|
self.raw_args = QLineEdit()
|
||||||
raw_args_layout.addWidget(self.raw_args)
|
raw_args_layout.addWidget(self.raw_args)
|
||||||
args_help_button = QPushButton("?")
|
args_help_button = QPushButton("?")
|
||||||
args_help_button.clicked.connect(self.args_help_button_clicked)
|
args_help_button.clicked.connect(self.args_help_button_clicked)
|
||||||
raw_args_layout.addWidget(args_help_button)
|
raw_args_layout.addWidget(args_help_button)
|
||||||
renderer_group_layout.addLayout(raw_args_layout)
|
engine_group_layout.addLayout(raw_args_layout)
|
||||||
main_layout.addWidget(self.renderer_group)
|
main_layout.addWidget(self.engine_group)
|
||||||
|
|
||||||
# Cameras Group
|
# Cameras Group
|
||||||
self.cameras_group = QGroupBox("Cameras")
|
self.cameras_group = QGroupBox("Cameras")
|
||||||
@@ -240,28 +240,28 @@ class NewRenderJobForm(QWidget):
|
|||||||
self.submit_progress_label.setHidden(True)
|
self.submit_progress_label.setHidden(True)
|
||||||
main_layout.addWidget(self.submit_progress_label)
|
main_layout.addWidget(self.submit_progress_label)
|
||||||
|
|
||||||
self.toggle_renderer_enablement(False)
|
self.toggle_engine_enablement(False)
|
||||||
|
|
||||||
def update_renderer_info(self):
|
def update_engine_info(self):
|
||||||
# get the renderer info and add them all to the ui
|
# get the engine info and add them all to the ui
|
||||||
self.renderer_info = self.server_proxy.get_renderer_info(response_type='full')
|
self.engine_info = self.server_proxy.get_engine_info(response_type='full')
|
||||||
self.renderer_type.addItems(self.renderer_info.keys())
|
self.engine_type.addItems(self.engine_info.keys())
|
||||||
# select the best renderer for the file type
|
# select the best engine for the file type
|
||||||
engine = EngineManager.engine_for_project_path(self.project_path)
|
engine = EngineManager.engine_for_project_path(self.project_path)
|
||||||
self.renderer_type.setCurrentText(engine.name().lower())
|
self.engine_type.setCurrentText(engine.name().lower())
|
||||||
# refresh ui
|
# refresh ui
|
||||||
self.renderer_changed()
|
self.engine_changed()
|
||||||
|
|
||||||
def renderer_changed(self):
|
def engine_changed(self):
|
||||||
# load the version numbers
|
# load the version numbers
|
||||||
current_renderer = self.renderer_type.currentText().lower() or self.renderer_type.itemText(0)
|
current_engine = self.engine_type.currentText().lower() or self.engine_type.itemText(0)
|
||||||
self.renderer_version_combo.clear()
|
self.engine_version_combo.clear()
|
||||||
self.renderer_version_combo.addItem('latest')
|
self.engine_version_combo.addItem('latest')
|
||||||
self.file_format_combo.clear()
|
self.file_format_combo.clear()
|
||||||
if current_renderer:
|
if current_engine:
|
||||||
renderer_vers = [version_info['version'] for version_info in self.renderer_info[current_renderer]['versions']]
|
engine_vers = [version_info['version'] for version_info in self.engine_info[current_engine]['versions']]
|
||||||
self.renderer_version_combo.addItems(renderer_vers)
|
self.engine_version_combo.addItems(engine_vers)
|
||||||
self.file_format_combo.addItems(self.renderer_info[current_renderer]['supported_export_formats'])
|
self.file_format_combo.addItems(self.engine_info[current_engine]['supported_export_formats'])
|
||||||
|
|
||||||
def update_server_list(self):
|
def update_server_list(self):
|
||||||
clients = ZeroconfServer.found_hostnames()
|
clients = ZeroconfServer.found_hostnames()
|
||||||
@@ -278,7 +278,7 @@ class NewRenderJobForm(QWidget):
|
|||||||
# UI stuff on main thread
|
# UI stuff on main thread
|
||||||
self.process_progress_bar.setHidden(False)
|
self.process_progress_bar.setHidden(False)
|
||||||
self.process_label.setHidden(False)
|
self.process_label.setHidden(False)
|
||||||
self.toggle_renderer_enablement(False)
|
self.toggle_engine_enablement(False)
|
||||||
|
|
||||||
output_name, _ = os.path.splitext(os.path.basename(self.scene_file_input.text()))
|
output_name, _ = os.path.splitext(os.path.basename(self.scene_file_input.text()))
|
||||||
output_name = output_name.replace(' ', '_')
|
output_name = output_name.replace(' ', '_')
|
||||||
@@ -296,8 +296,8 @@ class NewRenderJobForm(QWidget):
|
|||||||
self.render_name_input.setText(directory)
|
self.render_name_input.setText(directory)
|
||||||
|
|
||||||
def args_help_button_clicked(self):
|
def args_help_button_clicked(self):
|
||||||
url = (f'http://{self.server_proxy.hostname}:{self.server_proxy.port}/api/renderer/'
|
url = (f'http://{self.server_proxy.hostname}:{self.server_proxy.port}/api/engine/'
|
||||||
f'{self.renderer_type.currentText()}/help')
|
f'{self.engine_type.currentText()}/help')
|
||||||
self.engine_help_viewer = EngineHelpViewer(url)
|
self.engine_help_viewer = EngineHelpViewer(url)
|
||||||
self.engine_help_viewer.show()
|
self.engine_help_viewer.show()
|
||||||
|
|
||||||
@@ -306,20 +306,20 @@ class NewRenderJobForm(QWidget):
|
|||||||
def post_get_project_info_update(self):
|
def post_get_project_info_update(self):
|
||||||
"""Called by the GetProjectInfoWorker - Do not call directly."""
|
"""Called by the GetProjectInfoWorker - Do not call directly."""
|
||||||
try:
|
try:
|
||||||
# Set the best renderer we can find
|
# Set the best engine we can find
|
||||||
input_path = self.scene_file_input.text()
|
input_path = self.scene_file_input.text()
|
||||||
engine = EngineManager.engine_for_project_path(input_path)
|
engine = EngineManager.engine_for_project_path(input_path)
|
||||||
|
|
||||||
engine_index = self.renderer_type.findText(engine.name().lower())
|
engine_index = self.engine_type.findText(engine.name().lower())
|
||||||
if engine_index >= 0:
|
if engine_index >= 0:
|
||||||
self.renderer_type.setCurrentIndex(engine_index)
|
self.engine_type.setCurrentIndex(engine_index)
|
||||||
else:
|
else:
|
||||||
self.renderer_type.setCurrentIndex(0) #todo: find out why we don't have renderer info yet
|
self.engine_type.setCurrentIndex(0) #todo: find out why we don't have engine info yet
|
||||||
# not ideal but if we don't have the renderer info we have to pick something
|
# not ideal but if we don't have the engine info we have to pick something
|
||||||
|
|
||||||
# cleanup progress UI
|
# cleanup progress UI
|
||||||
self.load_file_group.setHidden(True)
|
self.load_file_group.setHidden(True)
|
||||||
self.toggle_renderer_enablement(True)
|
self.toggle_engine_enablement(True)
|
||||||
|
|
||||||
# Load scene data
|
# Load scene data
|
||||||
self.start_frame_input.setValue(self.project_info.get('frame_start'))
|
self.start_frame_input.setValue(self.project_info.get('frame_start'))
|
||||||
@@ -347,9 +347,9 @@ class NewRenderJobForm(QWidget):
|
|||||||
self.cameras_group.setHidden(True)
|
self.cameras_group.setHidden(True)
|
||||||
|
|
||||||
# Dynamic Engine Options
|
# Dynamic Engine Options
|
||||||
clear_layout(self.renderer_options_layout) # clear old options
|
clear_layout(self.engine_options_layout) # clear old options
|
||||||
# dynamically populate option list
|
# dynamically populate option list
|
||||||
system_info = self.renderer_info.get(engine.name(), {}).get('system_info', {})
|
system_info = self.engine_info.get(engine.name(), {}).get('system_info', {})
|
||||||
self.current_engine_options = engine.ui_options(system_info=system_info)
|
self.current_engine_options = engine.ui_options(system_info=system_info)
|
||||||
for option in self.current_engine_options:
|
for option in self.current_engine_options:
|
||||||
h_layout = QHBoxLayout()
|
h_layout = QHBoxLayout()
|
||||||
@@ -363,15 +363,15 @@ class NewRenderJobForm(QWidget):
|
|||||||
else:
|
else:
|
||||||
text_box = QLineEdit()
|
text_box = QLineEdit()
|
||||||
h_layout.addWidget(text_box)
|
h_layout.addWidget(text_box)
|
||||||
self.renderer_options_layout.addLayout(h_layout)
|
self.engine_options_layout.addLayout(h_layout)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def toggle_renderer_enablement(self, enabled=False):
|
def toggle_engine_enablement(self, enabled=False):
|
||||||
"""Toggle on/off all the render settings"""
|
"""Toggle on/off all the render settings"""
|
||||||
self.project_group.setHidden(not enabled)
|
self.project_group.setHidden(not enabled)
|
||||||
self.output_settings_group.setHidden(not enabled)
|
self.output_settings_group.setHidden(not enabled)
|
||||||
self.renderer_group.setHidden(not enabled)
|
self.engine_group.setHidden(not enabled)
|
||||||
self.notes_group.setHidden(not enabled)
|
self.notes_group.setHidden(not enabled)
|
||||||
if not enabled:
|
if not enabled:
|
||||||
self.cameras_group.setHidden(True)
|
self.cameras_group.setHidden(True)
|
||||||
@@ -386,7 +386,7 @@ class NewRenderJobForm(QWidget):
|
|||||||
self.submit_progress_label.setHidden(True)
|
self.submit_progress_label.setHidden(True)
|
||||||
self.process_progress_bar.setHidden(True)
|
self.process_progress_bar.setHidden(True)
|
||||||
self.process_label.setHidden(True)
|
self.process_label.setHidden(True)
|
||||||
self.toggle_renderer_enablement(True)
|
self.toggle_engine_enablement(True)
|
||||||
|
|
||||||
self.msg_box = QMessageBox()
|
self.msg_box = QMessageBox()
|
||||||
if not error_string:
|
if not error_string:
|
||||||
@@ -450,8 +450,8 @@ class SubmitWorker(QThread):
|
|||||||
try:
|
try:
|
||||||
hostname = self.window.server_input.currentText()
|
hostname = self.window.server_input.currentText()
|
||||||
job_json = {'owner': psutil.Process().username() + '@' + socket.gethostname(),
|
job_json = {'owner': psutil.Process().username() + '@' + socket.gethostname(),
|
||||||
'renderer': self.window.renderer_type.currentText().lower(),
|
'engine': self.window.engine_type.currentText().lower(),
|
||||||
'engine_version': self.window.renderer_version_combo.currentText(),
|
'engine_version': self.window.engine_version_combo.currentText(),
|
||||||
'args': {'raw': self.window.raw_args.text(),
|
'args': {'raw': self.window.raw_args.text(),
|
||||||
'export_format': self.window.file_format_combo.currentText()},
|
'export_format': self.window.file_format_combo.currentText()},
|
||||||
'output_path': self.window.render_name_input.text(),
|
'output_path': self.window.render_name_input.text(),
|
||||||
@@ -464,8 +464,8 @@ class SubmitWorker(QThread):
|
|||||||
'name': self.window.render_name_input.text()}
|
'name': self.window.render_name_input.text()}
|
||||||
|
|
||||||
# get the dynamic args
|
# get the dynamic args
|
||||||
for i in range(self.window.renderer_options_layout.count()):
|
for i in range(self.window.engine_options_layout.count()):
|
||||||
item = self.window.renderer_options_layout.itemAt(i)
|
item = self.window.engine_options_layout.itemAt(i)
|
||||||
layout = item.layout() # get the layout
|
layout = item.layout() # get the layout
|
||||||
for x in range(layout.count()):
|
for x in range(layout.count()):
|
||||||
z = layout.itemAt(x)
|
z = layout.itemAt(x)
|
||||||
@@ -497,7 +497,7 @@ class SubmitWorker(QThread):
|
|||||||
job_list = [job_json]
|
job_list = [job_json]
|
||||||
|
|
||||||
# presubmission tasks
|
# presubmission tasks
|
||||||
engine = EngineManager.engine_with_name(self.window.renderer_type.currentText().lower())
|
engine = EngineManager.engine_with_name(self.window.engine_type.currentText().lower())
|
||||||
input_path = engine().perform_presubmission_tasks(input_path)
|
input_path = engine().perform_presubmission_tasks(input_path)
|
||||||
# submit
|
# submit
|
||||||
err_msg = ""
|
err_msg = ""
|
||||||
@@ -93,7 +93,7 @@ class EngineBrowserWindow(QMainWindow):
|
|||||||
def update_table(self):
|
def update_table(self):
|
||||||
|
|
||||||
def update_table_worker():
|
def update_table_worker():
|
||||||
raw_server_data = RenderServerProxy(self.hostname).get_renderer_info()
|
raw_server_data = RenderServerProxy(self.hostname).get_engine_info()
|
||||||
if not raw_server_data:
|
if not raw_server_data:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -128,18 +128,18 @@ class EngineBrowserWindow(QMainWindow):
|
|||||||
self.launch_button.setEnabled(is_localhost(self.hostname))
|
self.launch_button.setEnabled(is_localhost(self.hostname))
|
||||||
|
|
||||||
def update_download_status(self):
|
def update_download_status(self):
|
||||||
running_tasks = [x for x in EngineManager.download_tasks if x.is_alive()]
|
running_tasks = EngineManager.active_downloads()
|
||||||
hide_progress = not bool(running_tasks)
|
hide_progress = not bool(running_tasks)
|
||||||
self.progress_bar.setHidden(hide_progress)
|
self.progress_bar.setHidden(hide_progress)
|
||||||
self.progress_label.setHidden(hide_progress)
|
self.progress_label.setHidden(hide_progress)
|
||||||
# Update the status labels
|
# Update the status labels
|
||||||
if len(EngineManager.download_tasks) == 0:
|
if len(running_tasks) == 0:
|
||||||
new_status = ""
|
new_status = ""
|
||||||
elif len(EngineManager.download_tasks) == 1:
|
elif len(running_tasks) == 1:
|
||||||
task = EngineManager.download_tasks[0]
|
task = running_tasks[0]
|
||||||
new_status = f"Downloading {task.engine.capitalize()} {task.version}..."
|
new_status = f"Downloading {task.engine.capitalize()} {task.version}..."
|
||||||
else:
|
else:
|
||||||
new_status = f"Downloading {len(EngineManager.download_tasks)} engines..."
|
new_status = f"Downloading {len(running_tasks)} engines..."
|
||||||
self.progress_label.setText(new_status)
|
self.progress_label.setText(new_status)
|
||||||
|
|
||||||
def launch_button_click(self):
|
def launch_button_click(self):
|
||||||
|
|||||||
+72
-17
@@ -1,9 +1,10 @@
|
|||||||
''' app/ui/main_window.py '''
|
''' app/ui/main_window.py '''
|
||||||
|
import ast
|
||||||
import datetime
|
import datetime
|
||||||
import io
|
import io
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import subprocess
|
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
@@ -16,20 +17,22 @@ from PyQt6.QtWidgets import QMainWindow, QWidget, QHBoxLayout, QListWidget, QTab
|
|||||||
QTableWidgetItem, QLabel, QVBoxLayout, QHeaderView, QMessageBox, QGroupBox, QPushButton, QListWidgetItem, \
|
QTableWidgetItem, QLabel, QVBoxLayout, QHeaderView, QMessageBox, QGroupBox, QPushButton, QListWidgetItem, \
|
||||||
QFileDialog
|
QFileDialog
|
||||||
|
|
||||||
|
from src.api.api_server import API_VERSION
|
||||||
from src.render_queue import RenderQueue
|
from src.render_queue import RenderQueue
|
||||||
from src.utilities.misc_helper import get_time_elapsed, resources_dir, is_localhost
|
from src.utilities.misc_helper import get_time_elapsed, resources_dir, is_localhost
|
||||||
from src.utilities.status_utils import RenderStatus
|
from src.utilities.status_utils import RenderStatus
|
||||||
from src.utilities.zeroconf_server import ZeroconfServer
|
from src.utilities.zeroconf_server import ZeroconfServer
|
||||||
from src.ui.add_job import NewRenderJobForm
|
from src.ui.add_job_window import NewRenderJobForm
|
||||||
from src.ui.console import ConsoleWindow
|
from src.ui.console_window import ConsoleWindow
|
||||||
from src.ui.engine_browser import EngineBrowserWindow
|
from src.ui.engine_browser import EngineBrowserWindow
|
||||||
from src.ui.log_viewer import LogViewer
|
from src.ui.log_window import LogViewer
|
||||||
from src.ui.widgets.menubar import MenuBar
|
from src.ui.widgets.menubar import MenuBar
|
||||||
from src.ui.widgets.proportional_image_label import ProportionalImageLabel
|
from src.ui.widgets.proportional_image_label import ProportionalImageLabel
|
||||||
from src.ui.widgets.statusbar import StatusBar
|
from src.ui.widgets.statusbar import StatusBar
|
||||||
from src.ui.widgets.toolbar import ToolBar
|
from src.ui.widgets.toolbar import ToolBar
|
||||||
from src.api.serverproxy_manager import ServerProxyManager
|
from src.api.serverproxy_manager import ServerProxyManager
|
||||||
from src.utilities.misc_helper import launch_url
|
from src.utilities.misc_helper import launch_url, iso_datestring_to_formatted_datestring
|
||||||
|
from src.version import APP_NAME
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
@@ -53,6 +56,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.server_info_ram = None
|
self.server_info_ram = None
|
||||||
self.server_info_cpu = None
|
self.server_info_cpu = None
|
||||||
self.server_info_os = None
|
self.server_info_os = None
|
||||||
|
self.server_info_gpu = None
|
||||||
self.server_info_hostname = None
|
self.server_info_hostname = None
|
||||||
self.engine_browser_window = None
|
self.engine_browser_window = None
|
||||||
self.server_info_group = None
|
self.server_info_group = None
|
||||||
@@ -63,7 +67,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.buffer_handler = None
|
self.buffer_handler = None
|
||||||
|
|
||||||
# Window-Settings
|
# Window-Settings
|
||||||
self.setWindowTitle("Zordon")
|
self.setWindowTitle(APP_NAME)
|
||||||
self.setGeometry(100, 100, 900, 800)
|
self.setGeometry(100, 100, 900, 800)
|
||||||
central_widget = QWidget(self)
|
central_widget = QWidget(self)
|
||||||
self.setCentralWidget(central_widget)
|
self.setCentralWidget(central_widget)
|
||||||
@@ -87,12 +91,13 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
self.setup_ui(main_layout)
|
self.setup_ui(main_layout)
|
||||||
|
|
||||||
self.create_toolbars()
|
|
||||||
|
|
||||||
# Add Widgets to Window
|
# Add Widgets to Window
|
||||||
|
# self.custom_menu_bar =
|
||||||
self.setMenuBar(MenuBar(self))
|
self.setMenuBar(MenuBar(self))
|
||||||
self.setStatusBar(StatusBar(self))
|
self.setStatusBar(StatusBar(self))
|
||||||
|
|
||||||
|
self.create_toolbars()
|
||||||
|
|
||||||
# start background update
|
# start background update
|
||||||
self.bg_update_thread = QThread()
|
self.bg_update_thread = QThread()
|
||||||
self.bg_update_thread.run = self.__background_update
|
self.bg_update_thread.run = self.__background_update
|
||||||
@@ -121,6 +126,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.server_info_os = QLabel()
|
self.server_info_os = QLabel()
|
||||||
self.server_info_cpu = QLabel()
|
self.server_info_cpu = QLabel()
|
||||||
self.server_info_ram = QLabel()
|
self.server_info_ram = QLabel()
|
||||||
|
self.server_info_gpu = QLabel()
|
||||||
server_info_engines_button = QPushButton("Render Engines")
|
server_info_engines_button = QPushButton("Render Engines")
|
||||||
server_info_engines_button.clicked.connect(self.engine_browser)
|
server_info_engines_button.clicked.connect(self.engine_browser)
|
||||||
server_info_layout = QVBoxLayout()
|
server_info_layout = QVBoxLayout()
|
||||||
@@ -128,6 +134,7 @@ class MainWindow(QMainWindow):
|
|||||||
server_info_layout.addWidget(self.server_info_os)
|
server_info_layout.addWidget(self.server_info_os)
|
||||||
server_info_layout.addWidget(self.server_info_cpu)
|
server_info_layout.addWidget(self.server_info_cpu)
|
||||||
server_info_layout.addWidget(self.server_info_ram)
|
server_info_layout.addWidget(self.server_info_ram)
|
||||||
|
server_info_layout.addWidget(self.server_info_gpu)
|
||||||
server_info_layout.addWidget(server_info_engines_button)
|
server_info_layout.addWidget(server_info_engines_button)
|
||||||
server_info_group.setLayout(server_info_layout)
|
server_info_group.setLayout(server_info_layout)
|
||||||
|
|
||||||
@@ -237,15 +244,42 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def update_server_info_display(self, hostname):
|
def update_server_info_display(self, hostname):
|
||||||
"""Updates the server information section of the UI."""
|
"""Updates the server information section of the UI."""
|
||||||
self.server_info_hostname.setText(hostname or "unknown")
|
self.server_info_hostname.setText(f"Name: {hostname}")
|
||||||
server_info = ZeroconfServer.get_hostname_properties(hostname)
|
server_info = ZeroconfServer.get_hostname_properties(hostname)
|
||||||
|
|
||||||
# Use the get method with defaults to avoid KeyError
|
# Use the get method with defaults to avoid KeyError
|
||||||
os_info = f"OS: {server_info.get('system_os', 'Unknown')} {server_info.get('system_os_version', '')}"
|
os_info = f"OS: {server_info.get('system_os', 'Unknown')} {server_info.get('system_os_version', '')}"
|
||||||
cpu_info = f"CPU: {server_info.get('system_cpu', 'Unknown')} - {server_info.get('system_cpu_cores', 'Unknown')} cores"
|
cleaned_cpu_name = server_info.get('system_cpu_brand', 'Unknown').replace(' CPU','').replace('(TM)','').replace('(R)', '')
|
||||||
|
cpu_info = f"CPU: {cleaned_cpu_name} ({server_info.get('system_cpu_cores', 'Unknown')} cores)"
|
||||||
|
memory_info = f"RAM: {server_info.get('system_memory', 'Unknown')} GB"
|
||||||
|
|
||||||
|
# Get and format GPU info
|
||||||
|
try:
|
||||||
|
gpu_list = ast.literal_eval(server_info.get('gpu_info', []))
|
||||||
|
|
||||||
|
# Format all GPUs
|
||||||
|
gpu_info_parts = []
|
||||||
|
for gpu in gpu_list:
|
||||||
|
gpu_name = gpu.get('name', 'Unknown').replace('(TM)','').replace('(R)', '')
|
||||||
|
gpu_memory = gpu.get('memory', 'Unknown')
|
||||||
|
|
||||||
|
# Add " GB" suffix if memory is a number
|
||||||
|
if isinstance(gpu_memory, (int, float)) or (isinstance(gpu_memory, str) and gpu_memory.isdigit()):
|
||||||
|
gpu_memory_str = f"{gpu_memory} GB"
|
||||||
|
else:
|
||||||
|
gpu_memory_str = str(gpu_memory)
|
||||||
|
|
||||||
|
gpu_info_parts.append(f"{gpu_name} ({gpu_memory_str})")
|
||||||
|
|
||||||
|
gpu_info = f"GPU: {', '.join(gpu_info_parts)}" if gpu_info_parts else "GPU: Unknown"
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error parsing GPU info: {e}")
|
||||||
|
gpu_info = "GPU: Unknown"
|
||||||
|
|
||||||
self.server_info_os.setText(os_info.strip())
|
self.server_info_os.setText(os_info.strip())
|
||||||
self.server_info_cpu.setText(cpu_info)
|
self.server_info_cpu.setText(cpu_info)
|
||||||
|
self.server_info_ram.setText(memory_info)
|
||||||
|
self.server_info_gpu.setText(gpu_info)
|
||||||
|
|
||||||
def fetch_jobs(self, clear_table=False):
|
def fetch_jobs(self, clear_table=False):
|
||||||
|
|
||||||
@@ -256,7 +290,7 @@ class MainWindow(QMainWindow):
|
|||||||
self.job_list_view.clear()
|
self.job_list_view.clear()
|
||||||
self.refresh_job_headers()
|
self.refresh_job_headers()
|
||||||
|
|
||||||
job_fetch = self.current_server_proxy.get_all_jobs(ignore_token=clear_table)
|
job_fetch = self.current_server_proxy.get_all_jobs(ignore_token=False)
|
||||||
if job_fetch:
|
if job_fetch:
|
||||||
num_jobs = len(job_fetch)
|
num_jobs = len(job_fetch)
|
||||||
self.job_list_view.setRowCount(num_jobs)
|
self.job_list_view.setRowCount(num_jobs)
|
||||||
@@ -273,13 +307,14 @@ class MainWindow(QMainWindow):
|
|||||||
get_time_elapsed(start_time, end_time)
|
get_time_elapsed(start_time, end_time)
|
||||||
|
|
||||||
name = job.get('name') or os.path.basename(job.get('input_path', ''))
|
name = job.get('name') or os.path.basename(job.get('input_path', ''))
|
||||||
renderer = f"{job.get('renderer', '')}-{job.get('renderer_version')}"
|
engine_name = f"{job.get('renderer', '')}-{job.get('renderer_version')}"
|
||||||
priority = str(job.get('priority', ''))
|
priority = str(job.get('priority', ''))
|
||||||
total_frames = str(job.get('total_frames', ''))
|
total_frames = str(job.get('total_frames', ''))
|
||||||
|
date_created_string = iso_datestring_to_formatted_datestring(job['date_created'])
|
||||||
|
|
||||||
items = [QTableWidgetItem(job['id']), QTableWidgetItem(name), QTableWidgetItem(renderer),
|
items = [QTableWidgetItem(job['id']), QTableWidgetItem(name), QTableWidgetItem(engine_name),
|
||||||
QTableWidgetItem(priority), QTableWidgetItem(display_status), QTableWidgetItem(time_elapsed),
|
QTableWidgetItem(priority), QTableWidgetItem(display_status), QTableWidgetItem(time_elapsed),
|
||||||
QTableWidgetItem(total_frames), QTableWidgetItem(job['date_created'])]
|
QTableWidgetItem(total_frames), QTableWidgetItem(date_created_string)]
|
||||||
|
|
||||||
for col, item in enumerate(items):
|
for col, item in enumerate(items):
|
||||||
self.job_list_view.setItem(row, col, item)
|
self.job_list_view.setItem(row, col, item)
|
||||||
@@ -361,7 +396,7 @@ class MainWindow(QMainWindow):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
def refresh_job_headers(self):
|
def refresh_job_headers(self):
|
||||||
self.job_list_view.setHorizontalHeaderLabels(["ID", "Name", "Renderer", "Priority", "Status",
|
self.job_list_view.setHorizontalHeaderLabels(["ID", "Name", "Engine", "Priority", "Status",
|
||||||
"Time Elapsed", "Frames", "Date Created"])
|
"Time Elapsed", "Frames", "Date Created"])
|
||||||
self.job_list_view.setColumnHidden(0, True)
|
self.job_list_view.setColumnHidden(0, True)
|
||||||
|
|
||||||
@@ -410,6 +445,8 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
def update_servers(self):
|
def update_servers(self):
|
||||||
found_servers = list(set(ZeroconfServer.found_hostnames() + self.added_hostnames))
|
found_servers = list(set(ZeroconfServer.found_hostnames() + self.added_hostnames))
|
||||||
|
found_servers = [x for x in found_servers if ZeroconfServer.get_hostname_properties(x)['api_version'] == API_VERSION]
|
||||||
|
|
||||||
# Always make sure local hostname is first
|
# Always make sure local hostname is first
|
||||||
if found_servers and not is_localhost(found_servers[0]):
|
if found_servers and not is_localhost(found_servers[0]):
|
||||||
for hostname in found_servers:
|
for hostname in found_servers:
|
||||||
@@ -468,9 +505,9 @@ class MainWindow(QMainWindow):
|
|||||||
|
|
||||||
# Top Toolbar Buttons
|
# Top Toolbar Buttons
|
||||||
self.topbar.add_button(
|
self.topbar.add_button(
|
||||||
"Console", f"{resources_directory}/Console.png", self.open_console_window)
|
"Settings", f"{resources_directory}/Gear.png", self.menuBar().show_settings)
|
||||||
self.topbar.add_button(
|
self.topbar.add_button(
|
||||||
"Engines", f"{resources_directory}/SoftwareInstaller.png", self.engine_browser)
|
"Console", f"{resources_directory}/Console.png", self.open_console_window)
|
||||||
self.topbar.add_separator()
|
self.topbar.add_separator()
|
||||||
self.topbar.add_button(
|
self.topbar.add_button(
|
||||||
"Stop Job", f"{resources_directory}/StopSign.png", self.stop_job)
|
"Stop Job", f"{resources_directory}/StopSign.png", self.stop_job)
|
||||||
@@ -591,3 +628,21 @@ class MainWindow(QMainWindow):
|
|||||||
if file_name:
|
if file_name:
|
||||||
self.new_job_window = NewRenderJobForm(file_name)
|
self.new_job_window = NewRenderJobForm(file_name)
|
||||||
self.new_job_window.show()
|
self.new_job_window.show()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# lazy load GUI frameworks
|
||||||
|
from PyQt6.QtWidgets import QApplication
|
||||||
|
|
||||||
|
# load application
|
||||||
|
# QtCore.QCoreApplication.setAttribute(QtCore.Qt.ApplicationAttribute.AA_MacDontSwapCtrlAndMeta)
|
||||||
|
app: QApplication = QApplication(sys.argv)
|
||||||
|
|
||||||
|
# configure main main_window
|
||||||
|
main_window = MainWindow()
|
||||||
|
# main_window.buffer_handler = buffer_handler
|
||||||
|
app.setActiveWindow(main_window)
|
||||||
|
|
||||||
|
main_window.show()
|
||||||
|
|
||||||
|
sys.exit(app.exec())
|
||||||
|
|||||||
@@ -0,0 +1,554 @@
|
|||||||
|
import os
|
||||||
|
import socket
|
||||||
|
from datetime import datetime
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import humanize
|
||||||
|
from PyQt6 import QtCore
|
||||||
|
from PyQt6.QtCore import Qt, QSettings, pyqtSignal as Signal, QThread, pyqtSignal, QTimer
|
||||||
|
from PyQt6.QtGui import QIcon
|
||||||
|
from PyQt6.QtWidgets import QApplication, QMainWindow, QListWidget, QListWidgetItem, QStackedWidget, QVBoxLayout, \
|
||||||
|
QWidget, QLabel, QCheckBox, QLineEdit, \
|
||||||
|
QPushButton, QHBoxLayout, QGroupBox, QTableWidget, QAbstractItemView, QTableWidgetItem, QHeaderView, \
|
||||||
|
QMessageBox, QProgressBar
|
||||||
|
|
||||||
|
from src.api.server_proxy import RenderServerProxy
|
||||||
|
from src.engines.engine_manager import EngineManager
|
||||||
|
from src.utilities.config import Config
|
||||||
|
from src.utilities.misc_helper import launch_url, system_safe_path
|
||||||
|
from src.version import APP_AUTHOR, APP_NAME
|
||||||
|
|
||||||
|
settings = QSettings(APP_AUTHOR, APP_NAME)
|
||||||
|
|
||||||
|
class GetEngineInfoWorker(QThread):
|
||||||
|
"""
|
||||||
|
The GetEngineInfoWorker class fetches engine information from a server in a background thread.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
done: A signal emitted when the engine information is retrieved.
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
run(self): Fetches engine information from the server.
|
||||||
|
"""
|
||||||
|
done = pyqtSignal(object) # emits the result when finished
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.parent = parent
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
data = RenderServerProxy(socket.gethostname()).get_engine_info()
|
||||||
|
self.done.emit(data)
|
||||||
|
|
||||||
|
class SettingsWindow(QMainWindow):
|
||||||
|
"""
|
||||||
|
The SettingsWindow class provides a user interface for managing engine settings.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.engine_download_progress_bar = None
|
||||||
|
self.engines_last_update_label = None
|
||||||
|
self.check_for_engine_updates_checkbox = None
|
||||||
|
self.delete_engine_button = None
|
||||||
|
self.launch_engine_button = None
|
||||||
|
self.show_password_button = None
|
||||||
|
self.network_password_line = None
|
||||||
|
self.enable_network_password_checkbox = None
|
||||||
|
self.check_for_new_engines_button = None
|
||||||
|
|
||||||
|
if not EngineManager.engines_path: # fix issue where sometimes path was not set
|
||||||
|
EngineManager.engines_path = system_safe_path(
|
||||||
|
os.path.join(os.path.join(os.path.expanduser(Config.upload_folder),
|
||||||
|
'engines')))
|
||||||
|
|
||||||
|
self.installed_engines_table = None
|
||||||
|
|
||||||
|
self.setWindowTitle("Settings")
|
||||||
|
|
||||||
|
# Create the main layout
|
||||||
|
main_layout = QVBoxLayout()
|
||||||
|
|
||||||
|
# Create the sidebar (QListWidget) for navigation
|
||||||
|
self.sidebar = QListWidget()
|
||||||
|
self.sidebar.setFixedWidth(150)
|
||||||
|
|
||||||
|
# Set the icon size
|
||||||
|
self.sidebar.setIconSize(QtCore.QSize(32, 32)) # Increase the icon size to 32x32 pixels
|
||||||
|
|
||||||
|
# Adjust the font size for the sidebar items
|
||||||
|
font = self.sidebar.font()
|
||||||
|
font.setPointSize(12) # Increase the font size
|
||||||
|
self.sidebar.setFont(font)
|
||||||
|
|
||||||
|
# Add items with icons to the sidebar
|
||||||
|
resources_dir = os.path.join(Path(__file__).resolve().parent.parent.parent, 'resources')
|
||||||
|
self.add_sidebar_item("General", os.path.join(resources_dir, "Gear.png"))
|
||||||
|
self.add_sidebar_item("Server", os.path.join(resources_dir, "Server.png"))
|
||||||
|
self.add_sidebar_item("Engines", os.path.join(resources_dir, "Blender.png"))
|
||||||
|
self.sidebar.setCurrentRow(0)
|
||||||
|
|
||||||
|
# Create the stacked widget to hold different settings pages
|
||||||
|
self.stacked_widget = QStackedWidget()
|
||||||
|
|
||||||
|
# Create pages for each section
|
||||||
|
general_page = self.create_general_page()
|
||||||
|
network_page = self.create_network_page()
|
||||||
|
engines_page = self.create_engines_page()
|
||||||
|
|
||||||
|
# Add pages to the stacked widget
|
||||||
|
self.stacked_widget.addWidget(general_page)
|
||||||
|
self.stacked_widget.addWidget(network_page)
|
||||||
|
self.stacked_widget.addWidget(engines_page)
|
||||||
|
|
||||||
|
# Connect the sidebar to the stacked widget
|
||||||
|
self.sidebar.currentRowChanged.connect(self.stacked_widget.setCurrentIndex)
|
||||||
|
|
||||||
|
# Create a horizontal layout to hold the sidebar and stacked widget
|
||||||
|
content_layout = QHBoxLayout()
|
||||||
|
content_layout.addWidget(self.sidebar)
|
||||||
|
content_layout.addWidget(self.stacked_widget)
|
||||||
|
|
||||||
|
# Add the content layout to the main layout
|
||||||
|
main_layout.addLayout(content_layout)
|
||||||
|
|
||||||
|
# Add the "OK" button at the bottom
|
||||||
|
ok_button = QPushButton("OK")
|
||||||
|
ok_button.clicked.connect(self.close)
|
||||||
|
ok_button.setFixedWidth(80)
|
||||||
|
ok_button.setDefault(True)
|
||||||
|
main_layout.addWidget(ok_button, alignment=Qt.AlignmentFlag.AlignRight)
|
||||||
|
|
||||||
|
# Create a central widget and set the layout
|
||||||
|
central_widget = QWidget()
|
||||||
|
central_widget.setLayout(main_layout)
|
||||||
|
self.setCentralWidget(central_widget)
|
||||||
|
|
||||||
|
self.setMinimumSize(700, 400)
|
||||||
|
|
||||||
|
# timers for background download UI updates
|
||||||
|
self.timer = QTimer(self)
|
||||||
|
self.timer.timeout.connect(self.update_engine_download_status)
|
||||||
|
|
||||||
|
def add_sidebar_item(self, name, icon_path):
|
||||||
|
"""Add an item with an icon to the sidebar."""
|
||||||
|
item = QListWidgetItem(QIcon(icon_path), name)
|
||||||
|
self.sidebar.addItem(item)
|
||||||
|
|
||||||
|
def create_general_page(self):
|
||||||
|
"""Create the General settings page."""
|
||||||
|
page = QWidget()
|
||||||
|
layout = QVBoxLayout()
|
||||||
|
|
||||||
|
# Startup Settings Group
|
||||||
|
startup_group = QGroupBox("Startup Settings")
|
||||||
|
startup_layout = QVBoxLayout()
|
||||||
|
# startup_layout.addWidget(QCheckBox("Start application on system startup"))
|
||||||
|
check_for_updates_checkbox = QCheckBox("Check for updates automatically")
|
||||||
|
check_for_updates_checkbox.setChecked(settings.value("auto_check_for_updates", True, type=bool))
|
||||||
|
check_for_updates_checkbox.stateChanged.connect(lambda state: settings.setValue("auto_check_for_updates", bool(state)))
|
||||||
|
startup_layout.addWidget(check_for_updates_checkbox)
|
||||||
|
startup_group.setLayout(startup_layout)
|
||||||
|
|
||||||
|
# Local Files Group
|
||||||
|
data_path = Path(Config.upload_folder).expanduser()
|
||||||
|
path_size = sum(f.stat().st_size for f in Path(data_path).rglob('*') if f.is_file())
|
||||||
|
database_group = QGroupBox("Local Files")
|
||||||
|
database_layout = QVBoxLayout()
|
||||||
|
database_layout.addWidget(QLabel(f"Local Directory: {data_path}"))
|
||||||
|
database_layout.addWidget(QLabel(f"Size: {humanize.naturalsize(path_size, binary=True)}"))
|
||||||
|
open_database_path_button = QPushButton("Open Directory")
|
||||||
|
open_database_path_button.clicked.connect(lambda: launch_url(data_path))
|
||||||
|
open_database_path_button.setFixedWidth(200)
|
||||||
|
database_layout.addWidget(open_database_path_button)
|
||||||
|
database_group.setLayout(database_layout)
|
||||||
|
|
||||||
|
|
||||||
|
# Render Settings Group
|
||||||
|
render_settings_group = QGroupBox("Render Engine Settings")
|
||||||
|
render_settings_layout = QVBoxLayout()
|
||||||
|
render_settings_layout.addWidget(QLabel("Restrict to render nodes with same:"))
|
||||||
|
require_same_engine_checkbox = QCheckBox("Renderer Version")
|
||||||
|
require_same_engine_checkbox.setChecked(settings.value("render_require_same_engine_version", False, type=bool))
|
||||||
|
require_same_engine_checkbox.stateChanged.connect(lambda state: settings.setValue("render_require_same_engine_version", bool(state)))
|
||||||
|
render_settings_layout.addWidget(require_same_engine_checkbox)
|
||||||
|
require_same_cpu_checkbox = QCheckBox("CPU Architecture")
|
||||||
|
require_same_cpu_checkbox.setChecked(settings.value("render_require_same_cpu_type", False, type=bool))
|
||||||
|
require_same_cpu_checkbox.stateChanged.connect(lambda state: settings.setValue("render_require_same_cpu_type", bool(state)))
|
||||||
|
render_settings_layout.addWidget(require_same_cpu_checkbox)
|
||||||
|
require_same_os_checkbox = QCheckBox("Operating System")
|
||||||
|
require_same_os_checkbox.setChecked(settings.value("render_require_same_os", False, type=bool))
|
||||||
|
require_same_os_checkbox.stateChanged.connect(lambda state: settings.setValue("render_require_same_os", bool(state)))
|
||||||
|
render_settings_layout.addWidget(require_same_os_checkbox)
|
||||||
|
render_settings_group.setLayout(render_settings_layout)
|
||||||
|
|
||||||
|
layout.addWidget(startup_group)
|
||||||
|
layout.addWidget(database_group)
|
||||||
|
layout.addWidget(render_settings_group)
|
||||||
|
|
||||||
|
layout.addStretch() # Add a stretch to push content to the top
|
||||||
|
page.setLayout(layout)
|
||||||
|
return page
|
||||||
|
|
||||||
|
def create_network_page(self):
|
||||||
|
"""Create the Network settings page."""
|
||||||
|
page = QWidget()
|
||||||
|
layout = QVBoxLayout()
|
||||||
|
|
||||||
|
# Sharing Settings Group
|
||||||
|
sharing_group = QGroupBox("Sharing Settings")
|
||||||
|
sharing_layout = QVBoxLayout()
|
||||||
|
|
||||||
|
enable_sharing_checkbox = QCheckBox("Enable other computers on the network to render to this machine")
|
||||||
|
enable_sharing_checkbox.setChecked(settings.value("enable_network_sharing", False, type=bool))
|
||||||
|
enable_sharing_checkbox.stateChanged.connect(self.toggle_render_sharing)
|
||||||
|
sharing_layout.addWidget(enable_sharing_checkbox)
|
||||||
|
|
||||||
|
password_enabled = (settings.value("enable_network_sharing", False, type=bool) and
|
||||||
|
settings.value("enable_network_password", False, type=bool))
|
||||||
|
|
||||||
|
password_layout = QHBoxLayout()
|
||||||
|
password_layout.setContentsMargins(0, 0, 0, 0)
|
||||||
|
self.enable_network_password_checkbox = QCheckBox("Enable network password:")
|
||||||
|
self.enable_network_password_checkbox.setChecked(settings.value("enable_network_password", False, type=bool))
|
||||||
|
self.enable_network_password_checkbox.stateChanged.connect(self.enable_network_password_changed)
|
||||||
|
self.enable_network_password_checkbox.setEnabled(settings.value("enable_network_sharing", False, type=bool))
|
||||||
|
sharing_layout.addWidget(self.enable_network_password_checkbox)
|
||||||
|
self.network_password_line = QLineEdit()
|
||||||
|
self.network_password_line.setPlaceholderText("Enter a password")
|
||||||
|
self.network_password_line.setEchoMode(QLineEdit.EchoMode.Password)
|
||||||
|
self.network_password_line.setEnabled(password_enabled)
|
||||||
|
password_layout.addWidget(self.network_password_line)
|
||||||
|
self.show_password_button = QPushButton("Show")
|
||||||
|
self.show_password_button.setEnabled(password_enabled)
|
||||||
|
self.show_password_button.clicked.connect(self.show_password_button_pressed)
|
||||||
|
password_layout.addWidget(self.show_password_button)
|
||||||
|
sharing_layout.addLayout(password_layout)
|
||||||
|
|
||||||
|
sharing_group.setLayout(sharing_layout)
|
||||||
|
|
||||||
|
layout.addWidget(sharing_group)
|
||||||
|
|
||||||
|
layout.addStretch() # Add a stretch to push content to the top
|
||||||
|
page.setLayout(layout)
|
||||||
|
return page
|
||||||
|
|
||||||
|
def toggle_render_sharing(self, enable_sharing):
|
||||||
|
settings.setValue("enable_network_sharing", enable_sharing)
|
||||||
|
self.enable_network_password_checkbox.setEnabled(enable_sharing)
|
||||||
|
enable_password = enable_sharing and settings.value("enable_network_password", False, type=bool)
|
||||||
|
self.network_password_line.setEnabled(enable_password)
|
||||||
|
self.show_password_button.setEnabled(enable_password)
|
||||||
|
|
||||||
|
def enable_network_password_changed(self, new_value):
|
||||||
|
settings.setValue("enable_network_password", new_value)
|
||||||
|
self.network_password_line.setEnabled(new_value)
|
||||||
|
self.show_password_button.setEnabled(new_value)
|
||||||
|
|
||||||
|
def show_password_button_pressed(self):
|
||||||
|
# toggle showing / hiding the password
|
||||||
|
show_pass = self.show_password_button.text() == "Show"
|
||||||
|
self.show_password_button.setText("Hide" if show_pass else "Show")
|
||||||
|
self.network_password_line.setEchoMode(QLineEdit.EchoMode.Normal if show_pass else QLineEdit.EchoMode.Password)
|
||||||
|
|
||||||
|
def create_engines_page(self):
|
||||||
|
"""Create the Engines settings page."""
|
||||||
|
page = QWidget()
|
||||||
|
layout = QVBoxLayout()
|
||||||
|
|
||||||
|
# Installed Engines Group
|
||||||
|
installed_group = QGroupBox("Installed Engines")
|
||||||
|
installed_layout = QVBoxLayout()
|
||||||
|
|
||||||
|
# Setup table
|
||||||
|
self.installed_engines_table = EngineTableWidget()
|
||||||
|
self.installed_engines_table.row_selected.connect(self.engine_table_selected)
|
||||||
|
installed_layout.addWidget(self.installed_engines_table)
|
||||||
|
|
||||||
|
# Ignore system installs
|
||||||
|
engine_ignore_system_installs_checkbox = QCheckBox("Ignore system installs")
|
||||||
|
engine_ignore_system_installs_checkbox.setChecked(settings.value("engines_ignore_system_installs", False, type=bool))
|
||||||
|
engine_ignore_system_installs_checkbox.stateChanged.connect(self.change_ignore_system_installs)
|
||||||
|
installed_layout.addWidget(engine_ignore_system_installs_checkbox)
|
||||||
|
|
||||||
|
# Engine Launch / Delete buttons
|
||||||
|
installed_buttons_layout = QHBoxLayout()
|
||||||
|
self.launch_engine_button = QPushButton("Launch")
|
||||||
|
self.launch_engine_button.setEnabled(False)
|
||||||
|
self.launch_engine_button.clicked.connect(self.launch_selected_engine)
|
||||||
|
self.delete_engine_button = QPushButton("Delete")
|
||||||
|
self.delete_engine_button.setEnabled(False)
|
||||||
|
self.delete_engine_button.clicked.connect(self.delete_selected_engine)
|
||||||
|
|
||||||
|
installed_buttons_layout.addWidget(self.launch_engine_button)
|
||||||
|
installed_buttons_layout.addWidget(self.delete_engine_button)
|
||||||
|
installed_layout.addLayout(installed_buttons_layout)
|
||||||
|
installed_group.setLayout(installed_layout)
|
||||||
|
|
||||||
|
# Engine Updates Group
|
||||||
|
engine_updates_group = QGroupBox("Auto-Install")
|
||||||
|
engine_updates_layout = QVBoxLayout()
|
||||||
|
|
||||||
|
engine_download_layout = QHBoxLayout()
|
||||||
|
engine_download_layout.addWidget(QLabel("Enable Downloads for:"))
|
||||||
|
|
||||||
|
at_least_one_downloadable = False
|
||||||
|
for engine in EngineManager.downloadable_engines():
|
||||||
|
engine_download_check = QCheckBox(engine.name())
|
||||||
|
is_checked = settings.value(f"engine_download-{engine.name()}", False, type=bool)
|
||||||
|
at_least_one_downloadable |= is_checked
|
||||||
|
engine_download_check.setChecked(is_checked)
|
||||||
|
# Capture the checkbox correctly using a default argument in lambda
|
||||||
|
engine_download_check.clicked.connect(
|
||||||
|
lambda state, checkbox=engine_download_check: self.engine_download_settings_changed(state, checkbox.text())
|
||||||
|
)
|
||||||
|
engine_download_layout.addWidget(engine_download_check)
|
||||||
|
|
||||||
|
engine_updates_layout.addLayout(engine_download_layout)
|
||||||
|
|
||||||
|
self.check_for_engine_updates_checkbox = QCheckBox("Check for new versions on launch")
|
||||||
|
self.check_for_engine_updates_checkbox.setChecked(settings.value('check_for_engine_updates_on_launch', True, type=bool))
|
||||||
|
self.check_for_engine_updates_checkbox.setEnabled(at_least_one_downloadable)
|
||||||
|
self.check_for_engine_updates_checkbox.stateChanged.connect(
|
||||||
|
lambda state: settings.setValue("check_for_engine_updates_on_launch", bool(state)))
|
||||||
|
engine_updates_layout.addWidget(self.check_for_engine_updates_checkbox)
|
||||||
|
self.engines_last_update_label = QLabel()
|
||||||
|
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.engine_download_progress_bar = QProgressBar()
|
||||||
|
engine_updates_layout.addWidget(self.engine_download_progress_bar)
|
||||||
|
self.engine_download_progress_bar.setHidden(True)
|
||||||
|
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)
|
||||||
|
engine_updates_group.setLayout(engine_updates_layout)
|
||||||
|
|
||||||
|
layout.addWidget(installed_group)
|
||||||
|
layout.addWidget(engine_updates_group)
|
||||||
|
|
||||||
|
layout.addStretch() # Add a stretch to push content to the top
|
||||||
|
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_engines_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)
|
||||||
|
if not last_checked_str:
|
||||||
|
time_string = "Never"
|
||||||
|
else:
|
||||||
|
last_checked_dt = datetime.fromisoformat(last_checked_str)
|
||||||
|
now = datetime.now()
|
||||||
|
time_string = humanize.naturaltime(now - last_checked_dt)
|
||||||
|
self.engines_last_update_label.setText(f"Last Updated: {time_string}")
|
||||||
|
|
||||||
|
def engine_download_settings_changed(self, state, engine_name):
|
||||||
|
settings.setValue(f"engine_download-{engine_name}", state)
|
||||||
|
|
||||||
|
at_least_one_downloadable = False
|
||||||
|
for engine in EngineManager.downloadable_engines():
|
||||||
|
at_least_one_downloadable |= settings.value(f"engine_download-{engine.name()}", False, type=bool)
|
||||||
|
self.check_for_new_engines_button.setEnabled(at_least_one_downloadable)
|
||||||
|
self.check_for_engine_updates_checkbox.setEnabled(at_least_one_downloadable)
|
||||||
|
self.engines_last_update_label.setEnabled(at_least_one_downloadable)
|
||||||
|
|
||||||
|
def delete_selected_engine(self):
|
||||||
|
engine_info = self.installed_engines_table.selected_engine_data()
|
||||||
|
reply = QMessageBox.question(self, f"Delete {engine_info['engine']} {engine_info['version']}?",
|
||||||
|
f"Do you want to delete {engine_info['engine']} {engine_info['version']}?",
|
||||||
|
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
|
||||||
|
|
||||||
|
if reply is not QMessageBox.StandardButton.Yes:
|
||||||
|
return
|
||||||
|
|
||||||
|
delete_result = EngineManager.delete_engine_download(engine_info.get('engine'),
|
||||||
|
engine_info.get('version'),
|
||||||
|
engine_info.get('system_os'),
|
||||||
|
engine_info.get('cpu'))
|
||||||
|
self.installed_engines_table.update_engines_table(use_cached=False)
|
||||||
|
if delete_result:
|
||||||
|
QMessageBox.information(self, f"{engine_info['engine']} {engine_info['version']} Deleted",
|
||||||
|
f"{engine_info['engine']} {engine_info['version']} deleted successfully",
|
||||||
|
QMessageBox.StandardButton.Ok)
|
||||||
|
else:
|
||||||
|
QMessageBox.warning(self, f"Unknown Error",
|
||||||
|
f"Unknown error while deleting {engine_info['engine']} {engine_info['version']}.",
|
||||||
|
QMessageBox.StandardButton.Ok)
|
||||||
|
|
||||||
|
def launch_selected_engine(self):
|
||||||
|
engine_info = self.installed_engines_table.selected_engine_data()
|
||||||
|
if engine_info:
|
||||||
|
launch_url(engine_info['path'])
|
||||||
|
|
||||||
|
def engine_table_selected(self):
|
||||||
|
engine_data = self.installed_engines_table.selected_engine_data()
|
||||||
|
if engine_data:
|
||||||
|
self.launch_engine_button.setEnabled(bool(engine_data.get('path') or True))
|
||||||
|
self.delete_engine_button.setEnabled(engine_data.get('type') == 'managed')
|
||||||
|
else:
|
||||||
|
self.launch_engine_button.setEnabled(False)
|
||||||
|
self.delete_engine_button.setEnabled(False)
|
||||||
|
|
||||||
|
def check_for_new_engines(self):
|
||||||
|
|
||||||
|
ignore_system = settings.value("engines_ignore_system_installs", False, type=bool)
|
||||||
|
messagebox_shown = False
|
||||||
|
for engine in EngineManager.downloadable_engines():
|
||||||
|
if settings.value(f'engine_download-{engine.name()}', False, type=bool):
|
||||||
|
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.Question)
|
||||||
|
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.engine_download_progress_bar.setHidden(False)
|
||||||
|
self.engine_download_progress_bar.setValue(0)
|
||||||
|
self.engine_download_progress_bar.setMaximum(100)
|
||||||
|
self.check_for_new_engines_button.setEnabled(False)
|
||||||
|
self.timer.start(1000)
|
||||||
|
|
||||||
|
if not messagebox_shown:
|
||||||
|
msg_box = QMessageBox()
|
||||||
|
msg_box.setWindowTitle("No Updates Available")
|
||||||
|
msg_box.setText("No Updates Available.")
|
||||||
|
msg_box.setIcon(QMessageBox.Icon.Information)
|
||||||
|
msg_box.setStandardButtons(QMessageBox.StandardButton.Ok)
|
||||||
|
msg_box.exec()
|
||||||
|
|
||||||
|
settings.setValue("engines_last_update_time", datetime.now().isoformat())
|
||||||
|
self.update_engine_download_status()
|
||||||
|
|
||||||
|
def update_engine_download_status(self):
|
||||||
|
|
||||||
|
running_tasks = EngineManager.active_downloads()
|
||||||
|
if not running_tasks:
|
||||||
|
self.timer.stop()
|
||||||
|
self.engine_download_progress_bar.setHidden(True)
|
||||||
|
self.installed_engines_table.update_engines_table(use_cached=False)
|
||||||
|
self.update_last_checked_label()
|
||||||
|
self.check_for_new_engines_button.setEnabled(True)
|
||||||
|
return
|
||||||
|
|
||||||
|
percent_complete = int(running_tasks[0].percent_complete * 100)
|
||||||
|
self.engine_download_progress_bar.setValue(percent_complete)
|
||||||
|
if percent_complete == 100:
|
||||||
|
status_update = f"Installing {running_tasks[0].engine.capitalize()} {running_tasks[0].version}..."
|
||||||
|
else:
|
||||||
|
status_update = f"Downloading {running_tasks[0].engine.capitalize()} {running_tasks[0].version}..."
|
||||||
|
self.engines_last_update_label.setText(status_update)
|
||||||
|
|
||||||
|
|
||||||
|
class EngineTableWidget(QWidget):
|
||||||
|
"""
|
||||||
|
The EngineTableWidget class displays a table of installed engines.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
table: A table widget displaying engine information.
|
||||||
|
|
||||||
|
Methods:
|
||||||
|
on_selection_changed(self): Emits a signal when the user selects a different row in the table.
|
||||||
|
"""
|
||||||
|
|
||||||
|
row_selected = Signal()
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
|
||||||
|
self.__get_engine_info_worker = None
|
||||||
|
self.table = QTableWidget(0, 4)
|
||||||
|
self.table.setHorizontalHeaderLabels(["Engine", "Version", "Type", "Path"])
|
||||||
|
self.table.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
|
||||||
|
self.table.verticalHeader().setVisible(False)
|
||||||
|
# self.table_widget.itemSelectionChanged.connect(self.engine_picked)
|
||||||
|
self.table.setEditTriggers(QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||||
|
self.table.selectionModel().selectionChanged.connect(self.on_selection_changed)
|
||||||
|
|
||||||
|
layout = QVBoxLayout(self)
|
||||||
|
layout.setContentsMargins(0, 0, 0, 0)
|
||||||
|
layout.setSpacing(0)
|
||||||
|
layout.addWidget(self.table)
|
||||||
|
|
||||||
|
self.raw_server_data = None
|
||||||
|
|
||||||
|
def showEvent(self, event):
|
||||||
|
"""Runs when the widget is about to be shown."""
|
||||||
|
self.update_engines_table()
|
||||||
|
super().showEvent(event) # Ensure normal event processing
|
||||||
|
|
||||||
|
def engine_data_ready(self, raw_server_data):
|
||||||
|
self.raw_server_data = raw_server_data
|
||||||
|
self.update_engines_table()
|
||||||
|
|
||||||
|
def update_engines_table(self, use_cached=True):
|
||||||
|
if not self.raw_server_data or not use_cached:
|
||||||
|
self.__get_engine_info_worker = GetEngineInfoWorker(self)
|
||||||
|
self.__get_engine_info_worker.done.connect(self.engine_data_ready)
|
||||||
|
self.__get_engine_info_worker.start()
|
||||||
|
if not self.raw_server_data:
|
||||||
|
return
|
||||||
|
|
||||||
|
table_data = [] # convert the data into a flat list
|
||||||
|
for _, engine_data in self.raw_server_data.items():
|
||||||
|
table_data.extend(engine_data['versions'])
|
||||||
|
|
||||||
|
if settings.value("engines_ignore_system_installs", False, type=bool):
|
||||||
|
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)
|
||||||
|
|
||||||
|
self.table.setHorizontalHeaderLabels(['Engine', 'Version', 'Type', 'Path'])
|
||||||
|
self.table.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeMode.Fixed)
|
||||||
|
self.table.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeMode.Fixed)
|
||||||
|
self.table.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeMode.Fixed)
|
||||||
|
self.table.horizontalHeader().setSectionResizeMode(3, QHeaderView.ResizeMode.Stretch)
|
||||||
|
|
||||||
|
for row, engine in enumerate(table_data):
|
||||||
|
self.table.setItem(row, 0, QTableWidgetItem(engine['engine']))
|
||||||
|
self.table.setItem(row, 1, QTableWidgetItem(engine['version']))
|
||||||
|
self.table.setItem(row, 2, QTableWidgetItem(engine['type']))
|
||||||
|
self.table.setItem(row, 3, QTableWidgetItem(engine['path']))
|
||||||
|
|
||||||
|
self.table.selectRow(0)
|
||||||
|
|
||||||
|
def selected_engine_data(self):
|
||||||
|
"""Returns the data from the selected row as a dictionary."""
|
||||||
|
row = self.table.currentRow() # Get the selected row index
|
||||||
|
|
||||||
|
if row < 0 or not len(self.table.selectedItems()): # No row selected
|
||||||
|
return None
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"engine": self.table.item(row, 0).text(),
|
||||||
|
"version": self.table.item(row, 1).text(),
|
||||||
|
"type": self.table.item(row, 2).text(),
|
||||||
|
"path": self.table.item(row, 3).text(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
|
def on_selection_changed(self):
|
||||||
|
self.row_selected.emit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = QApplication([])
|
||||||
|
window = SettingsWindow()
|
||||||
|
window.show()
|
||||||
|
app.exec()
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
''' app/ui/widgets/menubar.py '''
|
''' app/ui/widgets/menubar.py '''
|
||||||
import sys
|
|
||||||
|
|
||||||
from PyQt6.QtGui import QAction
|
from PyQt6.QtGui import QAction
|
||||||
from PyQt6.QtWidgets import QMenuBar, QApplication
|
from PyQt6.QtWidgets import QMenuBar, QApplication, QMessageBox, QDialog, QVBoxLayout, QLabel, QPushButton
|
||||||
|
|
||||||
|
|
||||||
class MenuBar(QMenuBar):
|
class MenuBar(QMenuBar):
|
||||||
@@ -16,6 +14,8 @@ class MenuBar(QMenuBar):
|
|||||||
def __init__(self, parent=None) -> None:
|
def __init__(self, parent=None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
|
self.settings_window = None
|
||||||
|
|
||||||
# setup menus
|
# setup menus
|
||||||
file_menu = self.addMenu("File")
|
file_menu = self.addMenu("File")
|
||||||
# edit_menu = self.addMenu("Edit")
|
# edit_menu = self.addMenu("Edit")
|
||||||
@@ -32,7 +32,7 @@ class MenuBar(QMenuBar):
|
|||||||
settings_action = QAction("Settings...", self)
|
settings_action = QAction("Settings...", self)
|
||||||
settings_action.triggered.connect(self.show_settings)
|
settings_action.triggered.connect(self.show_settings)
|
||||||
settings_action.setShortcut(f'Ctrl+,')
|
settings_action.setShortcut(f'Ctrl+,')
|
||||||
# file_menu.addAction(settings_action) # todo: enable once we have a setting screen
|
file_menu.addAction(settings_action)
|
||||||
# exit
|
# exit
|
||||||
exit_action = QAction('&Exit', self)
|
exit_action = QAction('&Exit', self)
|
||||||
exit_action.setShortcut('Ctrl+Q')
|
exit_action.setShortcut('Ctrl+Q')
|
||||||
@@ -43,15 +43,63 @@ class MenuBar(QMenuBar):
|
|||||||
about_action = QAction("About", self)
|
about_action = QAction("About", self)
|
||||||
about_action.triggered.connect(self.show_about)
|
about_action.triggered.connect(self.show_about)
|
||||||
help_menu.addAction(about_action)
|
help_menu.addAction(about_action)
|
||||||
|
update_action = QAction("Check for Updates...", self)
|
||||||
|
update_action.triggered.connect(self.check_for_updates)
|
||||||
|
help_menu.addAction(update_action)
|
||||||
|
|
||||||
def new_job(self):
|
def new_job(self):
|
||||||
self.parent().new_job()
|
self.parent().new_job()
|
||||||
|
|
||||||
def show_settings(self):
|
def show_settings(self):
|
||||||
pass
|
from src.ui.settings_window import SettingsWindow
|
||||||
|
self.settings_window = SettingsWindow()
|
||||||
|
self.settings_window.show()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def show_about():
|
def show_about():
|
||||||
from src.ui.about_window import AboutDialog
|
from src.ui.about_window import AboutDialog
|
||||||
dialog = AboutDialog()
|
dialog = AboutDialog()
|
||||||
dialog.exec()
|
dialog.exec()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def check_for_updates():
|
||||||
|
from src.utilities.misc_helper import check_for_updates
|
||||||
|
from src.version import APP_NAME, APP_VERSION, APP_REPO_NAME, APP_REPO_OWNER
|
||||||
|
found_update = check_for_updates(APP_REPO_NAME, APP_REPO_OWNER, APP_NAME, APP_VERSION)
|
||||||
|
if found_update:
|
||||||
|
dialog = UpdateDialog(found_update, APP_VERSION)
|
||||||
|
dialog.exec()
|
||||||
|
else:
|
||||||
|
QMessageBox.information(None, "No Update", "No updates available.")
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateDialog(QDialog):
|
||||||
|
def __init__(self, release_info, current_version, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.setWindowTitle(f"Update Available ({current_version} -> {release_info['tag_name']})")
|
||||||
|
|
||||||
|
layout = QVBoxLayout()
|
||||||
|
label = QLabel(f"A new version ({release_info['tag_name']}) is available! Current version: {current_version}")
|
||||||
|
layout.addWidget(label)
|
||||||
|
|
||||||
|
# Label to show the release notes
|
||||||
|
description = QLabel(release_info["body"])
|
||||||
|
layout.addWidget(description)
|
||||||
|
|
||||||
|
# Button to download the latest version
|
||||||
|
download_button = QPushButton(f"Download Latest Version ({release_info['tag_name']})")
|
||||||
|
download_button.clicked.connect(lambda: self.open_url(release_info["html_url"]))
|
||||||
|
layout.addWidget(download_button)
|
||||||
|
|
||||||
|
# OK button to dismiss the dialog
|
||||||
|
ok_button = QPushButton("Dismiss")
|
||||||
|
ok_button.clicked.connect(self.accept) # Close the dialog when clicked
|
||||||
|
layout.addWidget(ok_button)
|
||||||
|
|
||||||
|
self.setLayout(layout)
|
||||||
|
|
||||||
|
def open_url(self, url):
|
||||||
|
from PyQt6.QtCore import QUrl
|
||||||
|
from PyQt6.QtGui import QDesktopServices
|
||||||
|
QDesktopServices.openUrl(QUrl(url))
|
||||||
|
self.accept()
|
||||||
|
|||||||
@@ -35,12 +35,13 @@ class StatusBar(QStatusBar):
|
|||||||
try:
|
try:
|
||||||
# update status label - get download status
|
# update status label - get download status
|
||||||
new_status = proxy.status()
|
new_status = proxy.status()
|
||||||
if EngineManager.download_tasks:
|
active_downloads = EngineManager.active_downloads()
|
||||||
if len(EngineManager.download_tasks) == 1:
|
if active_downloads:
|
||||||
task = EngineManager.download_tasks[0]
|
if len(active_downloads) == 1:
|
||||||
|
task = active_downloads[0]
|
||||||
new_status = f"{new_status} | Downloading {task.engine.capitalize()} {task.version}..."
|
new_status = f"{new_status} | Downloading {task.engine.capitalize()} {task.version}..."
|
||||||
else:
|
else:
|
||||||
new_status = f"{new_status} | Downloading {len(EngineManager.download_tasks)} engines"
|
new_status = f"{new_status} | Downloading {len(active_downloads)} engines"
|
||||||
self.messageLabel.setText(new_status)
|
self.messageLabel.setText(new_status)
|
||||||
|
|
||||||
# update status image
|
# update status image
|
||||||
|
|||||||
@@ -4,18 +4,18 @@ from src.engines.ffmpeg.ffmpeg_engine import FFMPEG
|
|||||||
|
|
||||||
def image_sequence_to_video(source_glob_pattern, output_path, framerate=24, encoder="prores_ks", profile=4,
|
def image_sequence_to_video(source_glob_pattern, output_path, framerate=24, encoder="prores_ks", profile=4,
|
||||||
start_frame=1):
|
start_frame=1):
|
||||||
subprocess.run([FFMPEG.default_renderer_path(), "-framerate", str(framerate), "-start_number",
|
subprocess.run([FFMPEG.default_engine_path(), "-framerate", str(framerate), "-start_number",
|
||||||
str(start_frame), "-i", f"{source_glob_pattern}", "-c:v", encoder, "-profile:v", str(profile),
|
str(start_frame), "-i", f"{source_glob_pattern}", "-c:v", encoder, "-profile:v", str(profile),
|
||||||
'-pix_fmt', 'yuva444p10le', output_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
'-pix_fmt', 'yuva444p10le', output_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||||
check=True)
|
check=True)
|
||||||
|
|
||||||
|
|
||||||
def save_first_frame(source_path, dest_path, max_width=1280):
|
def save_first_frame(source_path, dest_path, max_width=1280):
|
||||||
subprocess.run([FFMPEG.default_renderer_path(), '-i', source_path, '-vf', f'scale={max_width}:-1',
|
subprocess.run([FFMPEG.default_engine_path(), '-i', source_path, '-vf', f'scale={max_width}:-1',
|
||||||
'-vframes', '1', dest_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
|
'-vframes', '1', dest_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
|
||||||
|
|
||||||
|
|
||||||
def generate_thumbnail(source_path, dest_path, max_width=240, fps=12):
|
def generate_thumbnail(source_path, dest_path, max_width=240, fps=12):
|
||||||
subprocess.run([FFMPEG.default_renderer_path(), '-i', source_path, '-vf',
|
subprocess.run([FFMPEG.default_engine_path(), '-i', source_path, '-vf',
|
||||||
f"scale={max_width}:trunc(ow/a/2)*2,format=yuv420p", '-r', str(fps), '-c:v', 'libx264', '-preset',
|
f"scale={max_width}:trunc(ow/a/2)*2,format=yuv420p", '-r', str(fps), '-c:v', 'libx264', '-preset',
|
||||||
'ultrafast', '-an', dest_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
|
'ultrafast', '-an', dest_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import socket
|
import socket
|
||||||
import string
|
import string
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
@@ -137,6 +140,40 @@ def current_system_cpu():
|
|||||||
# convert all x86 64 to "x64"
|
# convert all x86 64 to "x64"
|
||||||
return platform.machine().lower().replace('amd64', 'x64').replace('x86_64', 'x64')
|
return platform.machine().lower().replace('amd64', 'x64').replace('x86_64', 'x64')
|
||||||
|
|
||||||
|
def current_system_cpu_brand():
|
||||||
|
"""Fast cross-platform CPU brand string"""
|
||||||
|
if sys.platform.startswith('darwin'): # macOS
|
||||||
|
try:
|
||||||
|
return subprocess.check_output(['sysctl', '-n', 'machdep.cpu.brand_string']).decode().strip()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
elif sys.platform.startswith('win'): # Windows
|
||||||
|
from winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx
|
||||||
|
try:
|
||||||
|
# Open the registry key where Windows stores the CPU name
|
||||||
|
key = OpenKey(HKEY_LOCAL_MACHINE, r"HARDWARE\DESCRIPTION\System\CentralProcessor\0")
|
||||||
|
# The value name is "ProcessorNameString"
|
||||||
|
value, _ = QueryValueEx(key, "ProcessorNameString")
|
||||||
|
return value.strip() # Usually perfect, with full marketing name
|
||||||
|
except Exception:
|
||||||
|
# Fallback: sometimes the key is under a different index, try 1
|
||||||
|
try:
|
||||||
|
key = OpenKey(HKEY_LOCAL_MACHINE, r"HARDWARE\DESCRIPTION\System\CentralProcessor\1")
|
||||||
|
value, _ = QueryValueEx(key, "ProcessorNameString")
|
||||||
|
return value.strip()
|
||||||
|
except Exception:
|
||||||
|
return "Unknown CPU"
|
||||||
|
elif sys.platform.startswith('linux'):
|
||||||
|
try:
|
||||||
|
with open('/proc/cpuinfo') as f:
|
||||||
|
for line in f:
|
||||||
|
if line.startswith('model name'):
|
||||||
|
return line.split(':', 1)[1].strip()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Ultimate fallback
|
||||||
|
return platform.processor() or 'Unknown CPU'
|
||||||
|
|
||||||
def resources_dir():
|
def resources_dir():
|
||||||
resource_environment_path = os.environ.get('RESOURCEPATH', None)
|
resource_environment_path = os.environ.get('RESOURCEPATH', None)
|
||||||
@@ -159,6 +196,33 @@ def copy_directory_contents(src_dir, dst_dir):
|
|||||||
shutil.copy2(src_path, dst_path)
|
shutil.copy2(src_path, dst_path)
|
||||||
|
|
||||||
|
|
||||||
|
def check_for_updates(repo_name, repo_owner, app_name, current_version):
|
||||||
|
def get_github_releases(owner, repo):
|
||||||
|
import requests
|
||||||
|
url = f"https://api.github.com/repos/{owner}/{repo}/releases"
|
||||||
|
try:
|
||||||
|
response = requests.get(url, timeout=3)
|
||||||
|
response.raise_for_status()
|
||||||
|
releases = response.json()
|
||||||
|
return releases
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error checking for updates: {e}")
|
||||||
|
return []
|
||||||
|
|
||||||
|
releases = get_github_releases(repo_owner, repo_name)
|
||||||
|
if not releases:
|
||||||
|
return
|
||||||
|
|
||||||
|
latest_version = releases[0]
|
||||||
|
latest_version_tag = latest_version['tag_name']
|
||||||
|
|
||||||
|
from packaging import version
|
||||||
|
if version.parse(latest_version_tag) > version.parse(current_version):
|
||||||
|
logger.info(f"Newer version of {app_name} available. "
|
||||||
|
f"Latest: {latest_version_tag}, Current: {current_version}")
|
||||||
|
return latest_version
|
||||||
|
|
||||||
|
|
||||||
def is_localhost(comparison_hostname):
|
def is_localhost(comparison_hostname):
|
||||||
# this is necessary because socket.gethostname() does not always include '.local' - This is a sanitized comparison
|
# this is necessary because socket.gethostname() does not always include '.local' - This is a sanitized comparison
|
||||||
try:
|
try:
|
||||||
@@ -183,3 +247,140 @@ def num_to_alphanumeric(num):
|
|||||||
result += characters[remainder]
|
result += characters[remainder]
|
||||||
|
|
||||||
return result[::-1] # Reverse the result to get the correct alphanumeric string
|
return result[::-1] # Reverse the result to get the correct alphanumeric string
|
||||||
|
|
||||||
|
|
||||||
|
def iso_datestring_to_formatted_datestring(iso_date_string):
|
||||||
|
from dateutil import parser
|
||||||
|
import pytz
|
||||||
|
|
||||||
|
# Parse the ISO date string into a datetime object and convert timezones
|
||||||
|
date = parser.isoparse(iso_date_string).astimezone(pytz.UTC)
|
||||||
|
local_timezone = datetime.now().astimezone().tzinfo
|
||||||
|
date_local = date.astimezone(local_timezone)
|
||||||
|
|
||||||
|
# Format the date to the desired readable yet sortable format with 12-hour time
|
||||||
|
formatted_date = date_local.strftime('%Y-%m-%d %I:%M %p')
|
||||||
|
|
||||||
|
return formatted_date
|
||||||
|
|
||||||
|
def get_gpu_info():
|
||||||
|
"""Cross-platform GPU information retrieval"""
|
||||||
|
|
||||||
|
def get_windows_gpu_info():
|
||||||
|
"""Get GPU info on Windows"""
|
||||||
|
try:
|
||||||
|
result = subprocess.run(
|
||||||
|
['wmic', 'path', 'win32_videocontroller', 'get', 'name,AdapterRAM', '/format:list'],
|
||||||
|
capture_output=True, text=True, timeout=5
|
||||||
|
)
|
||||||
|
|
||||||
|
# Virtual adapters to exclude
|
||||||
|
virtual_adapters = [
|
||||||
|
'virtual', 'rdp', 'hyper-v', 'microsoft basic', 'basic display',
|
||||||
|
'vga compatible', 'dummy', 'nvfbc', 'nvencode'
|
||||||
|
]
|
||||||
|
|
||||||
|
gpus = []
|
||||||
|
current_gpu = None
|
||||||
|
|
||||||
|
for line in result.stdout.strip().split('\n'):
|
||||||
|
line = line.strip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if line.startswith('Name='):
|
||||||
|
if current_gpu and current_gpu.get('name'):
|
||||||
|
gpus.append(current_gpu)
|
||||||
|
gpu_name = line.replace('Name=', '').strip()
|
||||||
|
|
||||||
|
# Skip virtual adapters
|
||||||
|
if any(virtual in gpu_name.lower() for virtual in virtual_adapters):
|
||||||
|
current_gpu = None
|
||||||
|
else:
|
||||||
|
current_gpu = {'name': gpu_name, 'memory': 'Integrated'}
|
||||||
|
|
||||||
|
elif line.startswith('AdapterRAM=') and current_gpu:
|
||||||
|
vram_bytes_str = line.replace('AdapterRAM=', '').strip()
|
||||||
|
if vram_bytes_str and vram_bytes_str != '0':
|
||||||
|
try:
|
||||||
|
vram_gb = int(vram_bytes_str) / (1024**3)
|
||||||
|
current_gpu['memory'] = round(vram_gb, 2)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if current_gpu and current_gpu.get('name'):
|
||||||
|
gpus.append(current_gpu)
|
||||||
|
|
||||||
|
return gpus if gpus else [{'name': 'Unknown GPU', 'memory': 'Unknown'}]
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to get Windows GPU info: {e}")
|
||||||
|
return [{'name': 'Unknown GPU', 'memory': 'Unknown'}]
|
||||||
|
|
||||||
|
def get_macos_gpu_info():
|
||||||
|
"""Get GPU info on macOS (works with Apple Silicon)"""
|
||||||
|
try:
|
||||||
|
if current_system_cpu() == "arm64":
|
||||||
|
# don't bother with system_profiler with Apple ARM - we know its integrated
|
||||||
|
return [{'name': current_system_cpu_brand(), 'memory': 'Integrated'}]
|
||||||
|
|
||||||
|
result = subprocess.run(['system_profiler', 'SPDisplaysDataType', '-detailLevel', 'mini', '-json'],
|
||||||
|
capture_output=True, text=True, timeout=5)
|
||||||
|
data = json.loads(result.stdout)
|
||||||
|
|
||||||
|
gpus = []
|
||||||
|
displays = data.get('SPDisplaysDataType', [])
|
||||||
|
for display in displays:
|
||||||
|
if 'sppci_model' in display:
|
||||||
|
gpus.append({
|
||||||
|
'name': display.get('sppci_model', 'Unknown GPU'),
|
||||||
|
'memory': display.get('sppci_vram', 'Integrated'),
|
||||||
|
})
|
||||||
|
return gpus if gpus else [{'name': 'Apple GPU', 'memory': 'Integrated'}]
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Failed to get macOS GPU info: {e}")
|
||||||
|
return [{'name': 'Unknown GPU', 'memory': 'Unknown'}]
|
||||||
|
|
||||||
|
def get_linux_gpu_info():
|
||||||
|
gpus = []
|
||||||
|
try:
|
||||||
|
# Run plain lspci and filter for GPU-related lines
|
||||||
|
output = subprocess.check_output(
|
||||||
|
["lspci"], universal_newlines=True, stderr=subprocess.DEVNULL
|
||||||
|
)
|
||||||
|
for line in output.splitlines():
|
||||||
|
if any(keyword in line.lower() for keyword in ["vga", "3d", "display"]):
|
||||||
|
# Extract the part after the colon (vendor + model)
|
||||||
|
if ":" in line:
|
||||||
|
name_part = line.split(":", 1)[1].strip()
|
||||||
|
# Clean up common extras like (rev xx) or (prog-if ...)
|
||||||
|
name = name_part.split("(")[0].split("controller:")[-1].strip()
|
||||||
|
vendor = "Unknown"
|
||||||
|
if "nvidia" in name.lower():
|
||||||
|
vendor = "NVIDIA"
|
||||||
|
elif "amd" in name.lower() or "ati" in name.lower():
|
||||||
|
vendor = "AMD"
|
||||||
|
elif "intel" in name.lower():
|
||||||
|
vendor = "Intel"
|
||||||
|
|
||||||
|
gpus.append({
|
||||||
|
"name": name,
|
||||||
|
"vendor": vendor,
|
||||||
|
"memory": "Unknown"
|
||||||
|
})
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("lspci not found. Install pciutils: sudo apt install pciutils")
|
||||||
|
return []
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error running lspci: {e}")
|
||||||
|
return []
|
||||||
|
|
||||||
|
return gpus
|
||||||
|
|
||||||
|
system = platform.system()
|
||||||
|
|
||||||
|
if system == 'Darwin': # macOS
|
||||||
|
return get_macos_gpu_info()
|
||||||
|
elif system == 'Windows':
|
||||||
|
return get_windows_gpu_info()
|
||||||
|
else: # Assume Linux or other
|
||||||
|
return get_linux_gpu_info()
|
||||||
|
|||||||
@@ -32,9 +32,11 @@ class ZeroconfServer:
|
|||||||
def start(cls, listen_only=False):
|
def start(cls, listen_only=False):
|
||||||
if not cls.service_type:
|
if not cls.service_type:
|
||||||
raise RuntimeError("The 'configure' method must be run before starting the zeroconf server")
|
raise RuntimeError("The 'configure' method must be run before starting the zeroconf server")
|
||||||
logger.debug("Starting zeroconf service")
|
elif not listen_only:
|
||||||
if not listen_only:
|
logger.debug(f"Starting zeroconf service")
|
||||||
cls._register_service()
|
cls._register_service()
|
||||||
|
else:
|
||||||
|
logger.debug(f"Starting zeroconf service - Listen only mode")
|
||||||
cls._browse_services()
|
cls._browse_services()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -4,3 +4,5 @@ APP_AUTHOR = "Brett Williams"
|
|||||||
APP_DESCRIPTION = "Distributed Render Farm Tools"
|
APP_DESCRIPTION = "Distributed Render Farm Tools"
|
||||||
APP_COPYRIGHT_YEAR = "2024"
|
APP_COPYRIGHT_YEAR = "2024"
|
||||||
APP_LICENSE = "MIT License"
|
APP_LICENSE = "MIT License"
|
||||||
|
APP_REPO_NAME = APP_NAME
|
||||||
|
APP_REPO_OWNER = "blw1138"
|
||||||
Reference in New Issue
Block a user