Get the FLAMENCO_OT_copy_files operator up to par with the rest

This commit is contained in:
Sybren A. Stüvel 2018-03-20 16:52:50 +01:00
parent 10c51b3af5
commit c0a8602e17
2 changed files with 30 additions and 14 deletions

View File

@ -397,21 +397,34 @@ class FLAMENCO_OT_copy_files(Operator,
stop_upon_exception = True stop_upon_exception = True
async def async_execute(self, context): async def async_execute(self, context) -> None:
from pathlib import Path from pathlib import Path
from ..blender import preferences from ..blender import preferences
context.window_manager.flamenco_status = 'PACKING'
prefs = preferences() prefs = preferences()
exclusion_filter = (prefs.flamenco_exclude_filter or '').strip() exclusion_filter = (prefs.flamenco_exclude_filter or '').strip()
storage_path = prefs.flamenco_job_file_path # type: str
try:
outpath, missing_sources = await bat_interface.copy( outpath, missing_sources = await bat_interface.copy(
context, context,
Path(context.blend_data.filepath), Path(context.blend_data.filepath),
Path(prefs.cloud_project_local_path), Path(prefs.cloud_project_local_path),
Path(prefs.flamenco_job_file_path), Path(storage_path),
exclusion_filter 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: if missing_sources:
names = (ms.name for ms in 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, layout.operator(FLAMENCO_OT_render.bl_idname,
text='Render on Flamenco', text='Render on Flamenco',
icon='RENDER_ANIMATION') icon='RENDER_ANIMATION')
if bpy.app.debug:
layout.operator(FLAMENCO_OT_copy_files.bl_idname)
elif flamenco_status == 'INVESTIGATING': elif flamenco_status == 'INVESTIGATING':
row = layout.row(align=True) row = layout.row(align=True)
row.label('Investigating your files') row.label('Investigating your files')

View File

@ -6,18 +6,19 @@ import threading
import typing import typing
import pathlib 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 import bpy
from blender_asset_tracer import pack
from blender_asset_tracer.pack import progress, transfer
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
_running_packer = None # type: pack.Packer _running_packer = None # type: pack.Packer
_packer_lock = threading.RLock() _packer_lock = threading.RLock()
# For using in other parts of the add-on, so only this file imports BAT.
Aborted = pack.Aborted Aborted = pack.Aborted
FileTransferError = transfer.FileTransferError
class BatProgress(progress.Callback): class BatProgress(progress.Callback):