mirror of
https://github.com/blw1138/Zordon.git
synced 2026-02-05 13:46:10 +00:00
@@ -9,7 +9,7 @@ SUBPROCESS_TIMEOUT = 5
|
||||
|
||||
class BaseRenderEngine(object):
|
||||
"""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:
|
||||
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):
|
||||
self.custom_renderer_path = custom_path
|
||||
if not self.renderer_path() or not os.path.exists(self.renderer_path()):
|
||||
raise FileNotFoundError(f"Cannot find path to renderer for {self.name()} instance: {self.renderer_path()}")
|
||||
self.custom_engine_path = custom_path
|
||||
if not self.engine_path() or not os.path.exists(self.engine_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):
|
||||
logger.warning(f"Path is not executable. Setting permissions to 755 for {self.renderer_path()}")
|
||||
os.chmod(self.renderer_path(), 0o755)
|
||||
if not os.access(self.engine_path(), os.X_OK):
|
||||
logger.warning(f"Path is not executable. Setting permissions to 755 for {self.engine_path()}")
|
||||
os.chmod(self.engine_path(), 0o755)
|
||||
|
||||
def version(self):
|
||||
"""Return the version number as a string.
|
||||
@@ -60,7 +60,7 @@ class BaseRenderEngine(object):
|
||||
|
||||
@classmethod
|
||||
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:
|
||||
list[str]: A list of strings representing the available output formats.
|
||||
@@ -83,20 +83,20 @@ class BaseRenderEngine(object):
|
||||
return []
|
||||
|
||||
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.
|
||||
Override this method if the renderer uses a different help flag.
|
||||
This method runs the engine's help command (default: '-h') and captures the output.
|
||||
Override this method if the engine uses a different help flag.
|
||||
|
||||
Returns:
|
||||
str: The help documentation as a string.
|
||||
|
||||
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:
|
||||
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
|
||||
help_doc = subprocess.check_output([path, '-h'], stderr=subprocess.STDOUT,
|
||||
timeout=SUBPROCESS_TIMEOUT, creationflags=creationflags).decode('utf-8')
|
||||
@@ -141,15 +141,15 @@ class BaseRenderEngine(object):
|
||||
# Do Not Override These Methods:
|
||||
# --------------------------------------------
|
||||
|
||||
def renderer_path(self):
|
||||
return self.custom_renderer_path or self.default_renderer_path()
|
||||
def engine_path(self):
|
||||
return self.custom_engine_path or self.default_engine_path()
|
||||
|
||||
@classmethod
|
||||
def name(cls):
|
||||
return str(cls.__name__).lower()
|
||||
|
||||
@classmethod
|
||||
def default_renderer_path(cls):
|
||||
def default_engine_path(cls):
|
||||
path = None
|
||||
try: # Linux and macOS
|
||||
path = subprocess.check_output(['which', cls.name()], timeout=SUBPROCESS_TIMEOUT).decode('utf-8').strip()
|
||||
|
||||
Reference in New Issue
Block a user