Changes to engine file extensions structure

This commit is contained in:
Brett Williams
2024-08-03 20:21:26 -05:00
parent 7d633d97c2
commit d9201b5082
5 changed files with 23 additions and 17 deletions

View File

@@ -9,7 +9,7 @@ logger = logging.getLogger()
class AERender(BaseRenderEngine): class AERender(BaseRenderEngine):
supported_extensions = ['.aep'] file_extensions = ['aep']
def version(self): def version(self):
version = None version = None
@@ -36,3 +36,8 @@ class AERender(BaseRenderEngine):
def get_output_formats(cls): def get_output_formats(cls):
# todo: create implementation # todo: create implementation
return [] return []
if __name__ == "__main__":
x = AERender().supported_extensions()
print(x)

View File

@@ -22,7 +22,6 @@ def aerender_path():
class AERenderWorker(BaseRenderWorker): class AERenderWorker(BaseRenderWorker):
supported_extensions = ['.aep']
engine = AERender engine = AERender
def __init__(self, input_path, output_path, args=None, parent=None, name=None): def __init__(self, input_path, output_path, args=None, parent=None, name=None):

View File

@@ -11,6 +11,7 @@ class Blender(BaseRenderEngine):
install_paths = ['/Applications/Blender.app/Contents/MacOS/Blender'] install_paths = ['/Applications/Blender.app/Contents/MacOS/Blender']
binary_names = {'linux': 'blender', 'windows': 'blender.exe', 'macos': 'Blender'} binary_names = {'linux': 'blender', 'windows': 'blender.exe', 'macos': 'Blender'}
file_extensions = ['blend']
@staticmethod @staticmethod
def downloader(): def downloader():
@@ -26,10 +27,6 @@ class Blender(BaseRenderEngine):
from src.engines.blender.blender_ui import BlenderUI from src.engines.blender.blender_ui import BlenderUI
return BlenderUI.get_options(self) return BlenderUI.get_options(self)
@staticmethod
def supported_extensions():
return ['blend']
def version(self): def version(self):
version = None version = None
try: try:

View File

@@ -9,7 +9,7 @@ SUBPROCESS_TIMEOUT = 5
class BaseRenderEngine(object): class BaseRenderEngine(object):
install_paths = [] install_paths = []
supported_extensions = [] file_extensions = []
def __init__(self, custom_path=None): def __init__(self, custom_path=None):
self.custom_renderer_path = custom_path self.custom_renderer_path = custom_path
@@ -58,8 +58,7 @@ class BaseRenderEngine(object):
path = self.renderer_path() path = self.renderer_path()
if not path: if not path:
raise FileNotFoundError("renderer path not found") raise FileNotFoundError("renderer path not found")
help_doc = subprocess.check_output([path, '-h'], stderr=subprocess.STDOUT, help_doc = subprocess.run([path, '-h'], capture_output=True, text=True).stdout.strip()
timeout=SUBPROCESS_TIMEOUT).decode('utf-8')
return help_doc return help_doc
def get_project_info(self, project_path, timeout=10): def get_project_info(self, project_path, timeout=10):
@@ -69,6 +68,10 @@ class BaseRenderEngine(object):
def get_output_formats(cls): def get_output_formats(cls):
raise NotImplementedError(f"get_output_formats not implemented for {cls.__name__}") raise NotImplementedError(f"get_output_formats not implemented for {cls.__name__}")
@classmethod
def supported_extensions(cls):
return cls.file_extensions
def get_arguments(self): def get_arguments(self):
pass pass

View File

@@ -23,13 +23,15 @@ class FFMPEG(BaseRenderEngine):
@classmethod @classmethod
def supported_extensions(cls): def supported_extensions(cls):
help_text = (subprocess.check_output([cls().renderer_path(), '-h', 'full'], stderr=subprocess.STDOUT) if not cls.file_extensions:
.decode('utf-8')) help_text = (subprocess.check_output([cls().renderer_path(), '-h', 'full'], stderr=subprocess.STDOUT)
found = re.findall(r'extensions that .* is allowed to access \(default "(.*)"', help_text) .decode('utf-8'))
found_extensions = set() found = re.findall(r'extensions that .* is allowed to access \(default "(.*)"', help_text)
for match in found: found_extensions = set()
found_extensions.update(match.split(',')) for match in found:
return list(found_extensions) found_extensions.update(match.split(','))
cls.file_extensions = list(found_extensions)
return cls.file_extensions
def version(self): def version(self):
version = None version = None