Windows File Path Fixes (#39)

* Added system_safe_path to convert paths to Windows

* Fix issue where engines would not be reported unless a system engine was installed

* Platform independent searching for binaries in engine directory

* Add missing package to requirements.txt

* Better error handling for ffmpeg.get_all_formats()

* Add system_safe_path to more locations in api_server.py

* Fix naming issue with Blender on macos

* Fix path lookups and add engine_path to workers

* Report installed renderers in status

* Remove files included by accident
This commit is contained in:
2023-10-21 20:12:09 -07:00
committed by GitHub
parent 0b6b971fbc
commit 7a52cce40a
16 changed files with 129 additions and 61 deletions

View File

@@ -4,6 +4,7 @@ import platform
import shutil
from .downloaders.blender_downloader import BlenderDownloader
from .downloaders.ffmpeg_downloader import FFMPEGDownloader
from ..utilities.misc_helper import system_safe_path
try:
from .blender_engine import Blender
@@ -37,14 +38,25 @@ class EngineManager:
# Split the input string by dashes to get segments
segments = directory.split('-')
# Define the keys for each word
keys = ["engine", "version", "system_os", "cpu"]
# Create a dictionary with named keys
executable_names = {'linux': 'blender', 'windows': 'blender.exe', 'macos': 'Blender.app'}
keys = ["engine", "version", "system_os", "cpu"]
result_dict = {keys[i]: segments[i] for i in range(min(len(keys), len(segments)))}
result_dict['path'] = os.path.join(cls.engines_path, directory, executable_names.get(result_dict['system_os'], 'unknown'))
result_dict['type'] = 'managed'
# Figure out the binary name for the path
binary_name = result_dict['engine'].lower()
for eng in cls.supported_engines():
if eng.name().lower() == result_dict['engine']:
binary_name = eng.binary_names.get(result_dict['system_os'], binary_name)
# Find path to binary
path = None
for root, _, files in os.walk(system_safe_path(os.path.join(cls.engines_path, directory))):
if binary_name in files:
path = os.path.join(root, binary_name)
break
result_dict['path'] = path
results.append(result_dict)
except FileNotFoundError:
logger.warning("Cannot find local engines download directory")
@@ -113,11 +125,15 @@ class EngineManager:
return
# Get the appropriate downloader class based on the engine type
downloader = downloader_classes[engine]
if downloader.download_engine(version, download_location=cls.engines_path, system_os=system_os, cpu=cpu):
return cls.has_engine_version(engine, version, system_os, cpu)
else:
downloader_classes[engine].download_engine(version, download_location=cls.engines_path,
system_os=system_os, cpu=cpu)
# Check that engine was properly downloaded
found_engine = cls.has_engine_version(engine, version, system_os, cpu)
if not found_engine:
logger.error(f"Error downloading {engine}")
return found_engine
@classmethod
def delete_engine_download(cls, engine, version, system_os=None, cpu=None):