From 25f533b80f61654bcfcd8c3d5e3e9128cbfa8c8d Mon Sep 17 00:00:00 2001 From: jar091 <milan.jaros@vsb.cz> Date: Mon, 3 Dec 2018 09:59:42 +0100 Subject: [PATCH] fix worker --- flamenco_worker/cli.py | 4 ++-- flamenco_worker/commands.py | 6 ++++-- flamenco_worker/runner.py | 41 +++++++++++++++++++++++-------------- flamenco_worker/runner.py~ | 35 +++++++++++++++---------------- flamenco_worker/worker.py | 4 ++-- 5 files changed, 51 insertions(+), 39 deletions(-) diff --git a/flamenco_worker/cli.py b/flamenco_worker/cli.py index 7f56453a..e89b9e35 100644 --- a/flamenco_worker/cli.py +++ b/flamenco_worker/cli.py @@ -115,8 +115,8 @@ def main(): push_log_max_interval=confparser.interval_secs('push_log_max_interval_seconds'), push_log_max_entries=confparser.value('push_log_max_entries', int), push_act_max_interval=confparser.interval_secs('push_act_max_interval_seconds'), - worker_storage_dir=confparser.value('worker_storage_dir'), - worker_output_dir=confparser.value('worker_output_dir'), + worker_dir=confparser.value('worker_dir'), + worker_blender_param=confparser.value('worker_blender_param'), worker_blender_cmd=confparser.value('worker_blender_cmd'), initial_state='testing' if args.test else 'awake', run_single_task=args.single, diff --git a/flamenco_worker/commands.py b/flamenco_worker/commands.py index d0506302..3f776eb3 100644 --- a/flamenco_worker/commands.py +++ b/flamenco_worker/commands.py @@ -609,13 +609,15 @@ class BlenderRenderCommand(AbstractSubprocessCommand): '-noaudio', '--background', settings['filepath'], + '--python', + settings['blender_param'] ] if settings.get('python_expr'): cmd.extend(['--python-expr', settings['python_expr']]) if settings.get('render_output'): cmd.extend(['--render-output', settings['render_output']]) - if settings.get('format'): - cmd.extend(['--render-format', settings['format']]) + #if settings.get('format'): + # cmd.extend(['--render-format', settings['format']]) if settings.get('frames'): cmd.extend(['--render-frame', settings['frames']]) return cmd diff --git a/flamenco_worker/runner.py b/flamenco_worker/runner.py index 926f6afa..69f140d2 100644 --- a/flamenco_worker/runner.py +++ b/flamenco_worker/runner.py @@ -51,54 +51,64 @@ class TaskRunner: settings['blender_cmd'] = fworker.worker_blender_cmd return + def check_blender_param(self, settings: dict, fworker: worker.FlamencoWorker): + if not fworker.worker_blender_param: + return + + settings['blender_param'] = fworker.worker_blender_param + return + def check_storage_dir(self, settings: dict, fworker: worker.FlamencoWorker): - if not fworker.worker_storage_dir: + if not fworker.worker_dir: return if not settings.get('filepath'): return - (head, tail) = os.path.split(os.path.normpath(settings['filepath'])) - (head, tail) = os.path.split(head) + #(head, tail) = os.path.split(os.path.normpath(settings['filepath'])) + #(head, tail) = os.path.split(head) - settings['filepath'] = os.path.normpath(settings['filepath']).replace(head, os.path.normpath(fworker.worker_storage_dir)) + #settings['filepath'] = os.path.normpath(settings['filepath']).replace(head, os.path.normpath(fworker.worker_storage_dir)) + settings['filepath'] = os.path.normpath(fworker.worker_dir + '/' + settings['filepath']) return def check_output_dir(self, settings: dict, fworker: worker.FlamencoWorker): - if not fworker.worker_output_dir: + if not fworker.worker_dir: return if not settings.get('render_output'): return - (head, tail) = os.path.split(os.path.normpath(settings['render_output'])) - (head, tail) = os.path.split(head) + #(head, tail) = os.path.split(os.path.normpath(settings['render_output'])) + #(head, tail) = os.path.split(head) + + #settings['render_output'] = os.path.normpath(settings['render_output']).replace(head, os.path.normpath(fworker.worker_output_dir)) + settings['render_output'] = os.path.normpath(fworker.worker_dir + '/' + settings['render_output']) - settings['render_output'] = os.path.normpath(settings['render_output']).replace(head, os.path.normpath(fworker.worker_output_dir)) return def check_src_dir(self, settings: dict, fworker: worker.FlamencoWorker): - if not fworker.worker_output_dir: + if not fworker.worker_dir: return if not settings.get('src'): return - (head, tail) = os.path.split(os.path.normpath(settings['src'])) + #(head, tail) = os.path.split(os.path.normpath(settings['src'])) - settings['src'] = os.path.normpath(settings['src']).replace(head, os.path.normpath(fworker.worker_output_dir)) + settings['src'] = os.path.normpath(fworker.worker_dir + '/' + settings['src']) #.replace(head, os.path.normpath(fworker.worker_output_dir)) return def check_dest_dir(self, settings: dict, fworker: worker.FlamencoWorker): - if not fworker.worker_output_dir: + if not fworker.worker_dir: return if not settings.get('dest'): return - (head, tail) = os.path.split(os.path.normpath(settings['dest'])) + #(head, tail) = os.path.split(os.path.normpath(settings['dest'])) - settings['dest'] = os.path.normpath(settings['dest']).replace(head, os.path.normpath(fworker.worker_output_dir)) + settings['dest'] = os.path.normpath(fworker.worker_dir + '/' + settings['dest']) #.replace(head, os.path.normpath(fworker.worker_output_dir)) return async def execute(self, task: dict, fworker: worker.FlamencoWorker) -> bool: @@ -118,7 +128,8 @@ class TaskRunner: cmd_settings = cmd_info.get('settings') print(cmd_settings) - self.check_blender_cmd(cmd_settings, fworker) + self.check_blender_cmd(cmd_settings, fworker) + self.check_blender_param(cmd_settings, fworker) self.check_storage_dir(cmd_settings, fworker) self.check_output_dir(cmd_settings, fworker) self.check_src_dir(cmd_settings, fworker) diff --git a/flamenco_worker/runner.py~ b/flamenco_worker/runner.py~ index 103d8fd4..10c45588 100644 --- a/flamenco_worker/runner.py~ +++ b/flamenco_worker/runner.py~ @@ -52,57 +52,56 @@ class TaskRunner: return def check_storage_dir(self, settings: dict, fworker: worker.FlamencoWorker): - if not fworker.worker_storage_dir: + if not fworker.worker_dir: return if not settings.get('filepath'): return - (head, tail) = os.path.split(os.path.normpath(settings['filepath'])) - (head, tail) = os.path.split(head) + #(head, tail) = os.path.split(os.path.normpath(settings['filepath'])) + #(head, tail) = os.path.split(head) - settings['filepath'] = os.path.normpath(settings['filepath']).replace(head, os.path.normpath(fworker.worker_storage_dir)) + #settings['filepath'] = os.path.normpath(settings['filepath']).replace(head, os.path.normpath(fworker.worker_storage_dir)) + settings['filepath'] = os.path.normpath(fworker.worker_dir + '/' + settings['filepath']) return def check_output_dir(self, settings: dict, fworker: worker.FlamencoWorker): - if not fworker.worker_output_dir: + if not fworker.worker_dir: return if not settings.get('render_output'): return - (head, tail) = os.path.split(os.path.normpath(settings['render_output'])) - (head, tail) = os.path.split(head) + #(head, tail) = os.path.split(os.path.normpath(settings['render_output'])) + #(head, tail) = os.path.split(head) + + #settings['render_output'] = os.path.normpath(settings['render_output']).replace(head, os.path.normpath(fworker.worker_output_dir)) + settings['render_output'] = os.path.normpath(fworker.worker_dir + '/' + settings['render_output']) - settings['render_output'] = os.path.normpath(settings['render_output']).replace(head, os.path.normpath(fworker.worker_output_dir)) return def check_src_dir(self, settings: dict, fworker: worker.FlamencoWorker): - if not fworker.worker_output_dir: + if not fworker.worker_dir: return if not settings.get('src'): return - (head, tail) = os.path.split(os.path.normpath(settings['src'])) - (head, tail) = os.path.split(head) - (head, tail) = os.path.split(head) + #(head, tail) = os.path.split(os.path.normpath(settings['src'])) - settings['src'] = os.path.normpath(settings['src']).replace(head, os.path.normpath(fworker.worker_output_dir)) + settings['src'] = os.path.normpath(fworker.worker_dir + '/' + settings['src']) #.replace(head, os.path.normpath(fworker.worker_output_dir)) return def check_dest_dir(self, settings: dict, fworker: worker.FlamencoWorker): - if not fworker.worker_output_dir: + if not fworker.worker_dir: return if not settings.get('dest'): return - (head, tail) = os.path.split(os.path.normpath(settings['dest'])) - (head, tail) = os.path.split(head) - (head, tail) = os.path.split(head) + #(head, tail) = os.path.split(os.path.normpath(settings['dest'])) - settings['dest'] = os.path.normpath(settings['dest']).replace(head, os.path.normpath(fworker.worker_output_dir)) + settings['dest'] = os.path.normpath(fworker.worker_dir + '/' + settings['dest']) #.replace(head, os.path.normpath(fworker.worker_output_dir)) return async def execute(self, task: dict, fworker: worker.FlamencoWorker) -> bool: diff --git a/flamenco_worker/worker.py b/flamenco_worker/worker.py index bc6e6d38..6df00177 100644 --- a/flamenco_worker/worker.py +++ b/flamenco_worker/worker.py @@ -53,8 +53,8 @@ class FlamencoWorker: worker_id = attr.ib(validator=attr.validators.instance_of(str)) worker_secret = attr.ib(validator=attr.validators.instance_of(str)) - worker_storage_dir = attr.ib(validator=attr.validators.instance_of(str)) - worker_output_dir = attr.ib(validator=attr.validators.instance_of(str)) + worker_dir = attr.ib(validator=attr.validators.instance_of(str)) + worker_blender_param = attr.ib(validator=attr.validators.instance_of(str)) worker_blender_cmd = attr.ib(validator=attr.validators.instance_of(str)) loop = attr.ib(validator=attr.validators.instance_of(asyncio.AbstractEventLoop)) -- GitLab