From 7f268f2177d29894d1bc014828fc52de267250aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 4 Jan 2023 00:57:48 +0100 Subject: [PATCH] Add-on: abort submission when job preparation fails Job preparation (that is, constructing the data to be sent to the Flamenco API) shouldn't fail, but in case it does, it should stop the rest of the submission process. --- addon/flamenco/operators.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/addon/flamenco/operators.py b/addon/flamenco/operators.py index dae8f11a..4b6127bb 100644 --- a/addon/flamenco/operators.py +++ b/addon/flamenco/operators.py @@ -451,13 +451,13 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): self.blendfile_on_farm = bpathlib.make_absolute(blendfile) self._submit_job(context) - def _prepare_job_for_submission(self, context: bpy.types.Context) -> None: + def _prepare_job_for_submission(self, context: bpy.types.Context) -> bool: """Prepare self.job for sending to Flamenco.""" self.job = job_submission.job_for_scene(context.scene) if self.job is None: self.report({"ERROR"}, "Unable to create job") - return {"CANCELLED"} + return False propgroup = getattr(context.scene, "flamenco_job_settings", None) assert isinstance(propgroup, JobTypePropertyGroup), "did not expect %s" % ( @@ -469,6 +469,9 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): propgroup.job_type, self.job, self.blendfile_on_farm ) + + return True + def _submit_job(self, context: bpy.types.Context) -> None: """Use the Flamenco API to submit the new Job.""" assert self.job is not None @@ -476,7 +479,8 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): from flamenco.manager import ApiException - self._prepare_job_for_submission(context) + if not self._prepare_job_for_submission(context): + return api_client = self.get_api_client(context) try: @@ -510,7 +514,9 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): """ from flamenco.manager import ApiException - self._prepare_job_for_submission(context) + if not self._prepare_job_for_submission(context): + return False + assert self.job is not None api_client = self.get_api_client(context) try: