Flamenco exclusion filter requires BAM 1.1.7; this is now checked

A warning is shown in the GUI when a BAM version that's too old is used
(instead of simply crashing when an exclusion filter was specified).
This commit is contained in:
2017-05-02 18:48:54 +02:00
parent 01ae0f5f54
commit 543da5c8d8
2 changed files with 39 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
"""BAM packing interface for Flamenco."""
import functools
import logging
from pathlib import Path
import typing
@@ -14,6 +15,28 @@ class CommandExecutionError(Exception):
pass
if 'bam_supports_exclude_option' in locals():
locals()['bam_supports_exclude_option'].cache_clear()
@functools.lru_cache(maxsize=1)
def bam_supports_exclude_option() -> bool:
"""Returns True if the version of BAM bundled with Blender supports --exclude.
This feature was added to BAM 1.1.7, so we can do a simple version check.
"""
try:
import io_blend_utils
except ImportError:
# If this happens, BAM won't work at all. However, this function can be called from
# the GUI; by being a bit careful while importing, we avoid breaking Blender's GUI.
log.exception('Error importing io_blend_utils module.')
return False
return io_blend_utils.bl_info['version'] >= (1, 1, 7)
async def bam_copy(base_blendfile: Path, target_blendfile: Path,
exclusion_filter: str) -> typing.List[Path]:
"""Uses BAM to copy the given file and dependencies to the target blendfile.
@@ -43,7 +66,11 @@ async def bam_copy(base_blendfile: Path, target_blendfile: Path,
]
if exclusion_filter:
args.extend(['--exclude', exclusion_filter])
if bam_supports_exclude_option():
args.extend(['--exclude', exclusion_filter])
else:
log.warning('Your version of Blender does not support the exclusion filter, '
'copying all files.')
cmd_to_log = ' '.join(shlex.quote(s) for s in args)
log.info('Executing %s', cmd_to_log)