Add support for Shaman servers

See https://gitlab.com/blender-institute/shaman for more info
This commit is contained in:
Sybren A. Stüvel 2019-02-28 12:53:29 +01:00
parent cc97288018
commit f7396350db
2 changed files with 35 additions and 3 deletions

View File

@ -69,6 +69,8 @@ VIDEO_CONTAINER_TO_EXTENSION = {
'FLASH': '.flv',
}
SHAMAN_URL_SCHEMES = {'shaman://', 'shaman+http://', 'shaman+https://'}
def scene_sample_count(scene) -> int:
"""Determine nr of render samples for this scene."""
@ -548,6 +550,34 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin,
relative_only = prefs.flamenco_relative_only
self.log.debug('projdir: %s', projdir)
if any(prefs.flamenco_job_file_path.startswith(scheme) for scheme in SHAMAN_URL_SCHEMES):
endpoint, _ = bat_interface.parse_shaman_endpoint(prefs.flamenco_job_file_path)
self.log.info('Sending BAT pack to Shaman at %s', endpoint)
try:
outfile, missing_sources = await bat_interface.copy(
bpy.context, filepath, projdir, '/', exclusion_filter,
packer_class=bat_interface.ShamanPacker,
relative_only=relative_only,
endpoint=endpoint,
checkout_id=job_id,
)
except bat_interface.FileTransferError as ex:
self.log.error('Could not transfer %d files, starting with %s',
len(ex.files_remaining), ex.files_remaining[0])
self.report({'ERROR'}, 'Unable to transfer %d files' % len(ex.files_remaining))
self.quit()
return None, None, []
except bat_interface.Aborted:
self.log.warning('BAT Pack was aborted')
self.report({'WARNING'}, 'Aborted Flamenco file packing/transferring')
self.quit()
return None, None, []
bpy.context.window_manager.flamenco_status = 'DONE'
outfile = PurePath('{shaman}') / outfile
return None, outfile, missing_sources
# Create a unique directory that is still more or less identifyable.
# This should work better than a random ID.
unique_dir = '%s-%s-%s' % (datetime.now().isoformat('-').replace(':', ''),

View File

@ -9,7 +9,7 @@ import typing
import bpy
from blender_asset_tracer import pack
from blender_asset_tracer.pack import progress, transfer
from blender_asset_tracer.pack import progress, transfer, shaman
log = logging.getLogger(__name__)
@ -19,6 +19,8 @@ _packer_lock = threading.RLock()
# For using in other parts of the add-on, so only this file imports BAT.
Aborted = pack.Aborted
FileTransferError = transfer.FileTransferError
ShamanPacker = shaman.ShamanPacker
parse_shaman_endpoint = shaman.parse_endpoint
class BatProgress(progress.Callback):
@ -63,8 +65,8 @@ class BatProgress(progress.Callback):
else:
self._txt('Pack of %s done' % output_blendfile.name)
def pack_aborted(self):
self._txt('Aborted')
def pack_aborted(self, reason: str):
self._txt('Aborted: %s' % reason)
self._status('ABORTED')
def trace_blendfile(self, filename: pathlib.Path) -> None: