From fb5501028de04464521f3a6251c33ef23b09a9c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 28 Jul 2022 17:49:01 +0200 Subject: [PATCH] Add-on: use `bat.bpathlib.make_absolute()` for making paths absolute This should resolve the issue where on Windows file paths to a network share would be converted to UNC notation (and thus loose their drive letter). --- addon/flamenco/job_submission.py | 8 ++++++++ addon/flamenco/operators.py | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/addon/flamenco/job_submission.py b/addon/flamenco/job_submission.py index fbd67348..43a53979 100644 --- a/addon/flamenco/job_submission.py +++ b/addon/flamenco/job_submission.py @@ -2,10 +2,12 @@ from pathlib import Path, PurePosixPath from typing import TYPE_CHECKING, Optional, Union import platform +import logging import bpy from .job_types_propgroup import JobTypePropertyGroup +from .bat.submodules import bpathlib from . import preferences if TYPE_CHECKING: @@ -26,6 +28,7 @@ else: # it'll be set to the path of the BAT-packed blend file. BLENDFILE_SETTING_KEY = "blendfile" +log = logging.getLogger(__name__) def job_for_scene(scene: bpy.types.Scene) -> Optional[_SubmittedJob]: from flamenco.manager.models import SubmittedJob, JobMetadata @@ -101,6 +104,11 @@ def is_file_inside_job_storage(context: bpy.types.Context, blendfile: Path) -> b prefs = preferences.get(context) job_storage = Path(prefs.job_storage).absolute().resolve() + + log.info("Checking whether the file is already inside the job storage") + log.info(" file : %s", blendfile) + log.info(" storage: %s", job_storage) + try: blendfile.relative_to(job_storage) except ValueError: diff --git a/addon/flamenco/operators.py b/addon/flamenco/operators.py index d3c85bd8..d9aa3d1d 100644 --- a/addon/flamenco/operators.py +++ b/addon/flamenco/operators.py @@ -11,6 +11,7 @@ import bpy from . import job_types, job_submission, preferences from .job_types_propgroup import JobTypePropertyGroup +from .bat.submodules import bpathlib if TYPE_CHECKING: from .bat.interface import ( @@ -242,8 +243,10 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): self.blendfile_on_farm = None self._bat_pack_shaman(context, blendfile) elif job_submission.is_file_inside_job_storage(context, blendfile): + self.log.info("File is already in job storage location, submitting it as-is") self._use_blendfile_directly(context, blendfile) else: + self.log.info("File is not already in job storage location, copying it there") self.blendfile_on_farm = self._bat_pack_filesystem(context, blendfile) context.window_manager.modal_handler_add(self) @@ -363,7 +366,7 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): # The blend file is contained in the job storage path, no need to # copy anything. - self.blendfile_on_farm = PurePosixPath(blendfile.absolute().resolve().as_posix()) + self.blendfile_on_farm = bpathlib.make_absolute(blendfile) self._submit_job(context) def _submit_job(self, context: bpy.types.Context) -> None: