diff --git a/blender_cloud/flamenco/__init__.py b/blender_cloud/flamenco/__init__.py index 5c0bf3e..a555318 100644 --- a/blender_cloud/flamenco/__init__.py +++ b/blender_cloud/flamenco/__init__.py @@ -397,21 +397,34 @@ class FLAMENCO_OT_copy_files(Operator, stop_upon_exception = True - async def async_execute(self, context): + async def async_execute(self, context) -> None: from pathlib import Path from ..blender import preferences - context.window_manager.flamenco_status = 'PACKING' prefs = preferences() exclusion_filter = (prefs.flamenco_exclude_filter or '').strip() - outpath, missing_sources = await bat_interface.copy( - context, - Path(context.blend_data.filepath), - Path(prefs.cloud_project_local_path), - Path(prefs.flamenco_job_file_path), - exclusion_filter - ) + storage_path = prefs.flamenco_job_file_path # type: str + + try: + outpath, missing_sources = await bat_interface.copy( + context, + Path(context.blend_data.filepath), + Path(prefs.cloud_project_local_path), + Path(storage_path), + exclusion_filter + ) + 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 + except bat_interface.Aborted: + self.log.warning('BAT Pack was aborted') + self.report({'WARNING'}, 'Aborted Flamenco file packing/transferring') + self.quit() + return if missing_sources: names = (ms.name for ms in missing_sources) @@ -711,6 +724,8 @@ class FLAMENCO_PT_render(bpy.types.Panel, FlamencoPollMixin): layout.operator(FLAMENCO_OT_render.bl_idname, text='Render on Flamenco', icon='RENDER_ANIMATION') + if bpy.app.debug: + layout.operator(FLAMENCO_OT_copy_files.bl_idname) elif flamenco_status == 'INVESTIGATING': row = layout.row(align=True) row.label('Investigating your files') diff --git a/blender_cloud/flamenco/bat_interface.py b/blender_cloud/flamenco/bat_interface.py index 767ad46..e38d46f 100644 --- a/blender_cloud/flamenco/bat_interface.py +++ b/blender_cloud/flamenco/bat_interface.py @@ -6,18 +6,19 @@ import threading import typing import pathlib -from blender_asset_tracer import pack -from blender_asset_tracer.pack import progress - -from blender_asset_tracer.pack.transfer import FileTransferError - import bpy +from blender_asset_tracer import pack +from blender_asset_tracer.pack import progress, transfer + log = logging.getLogger(__name__) _running_packer = None # type: pack.Packer _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 class BatProgress(progress.Callback):