Add-on: allow scripted job submissions from Blender
The `bpy.ops.flamenco.submit_job(job_name="jobname")` operator can now be executed from Python. In that case, it will block the main thread until the job submission is complete.
This commit is contained in:
parent
152adcb777
commit
963133bd59
@ -8,6 +8,7 @@ bugs in actually-released versions.
|
|||||||
|
|
||||||
- Add `label` to job settings, to have full control over how they are presented in Blender's job submission GUI. If a job setting does not define a label, its `key` is used to generate one (like Flamenco 3.5 and older).
|
- Add `label` to job settings, to have full control over how they are presented in Blender's job submission GUI. If a job setting does not define a label, its `key` is used to generate one (like Flamenco 3.5 and older).
|
||||||
- Add `shellSplit(someString)` function to the job compiler scripts. This splits a string into an array of strings using shell/CLI semantics.
|
- Add `shellSplit(someString)` function to the job compiler scripts. This splits a string into an array of strings using shell/CLI semantics.
|
||||||
|
- Make it possible to script job submissions in Blender, by executing the `bpy.ops.flamenco.submit_job(job_name="jobname")` operator.
|
||||||
|
|
||||||
## 3.5 - released 2024-04-16
|
## 3.5 - released 2024-04-16
|
||||||
|
|
||||||
|
@ -128,6 +128,32 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator):
|
|||||||
job_type = job_types.active_job_type(context.scene)
|
job_type = job_types.active_job_type(context.scene)
|
||||||
return job_type is not None
|
return job_type is not None
|
||||||
|
|
||||||
|
def execute(self, context: bpy.types.Context) -> set[str]:
|
||||||
|
filepath, ok = self._presubmit_check(context)
|
||||||
|
if not ok:
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
is_running = self._submit_files(context, filepath)
|
||||||
|
if not is_running:
|
||||||
|
return {"CANCELLED"}
|
||||||
|
|
||||||
|
if self.packthread is None:
|
||||||
|
# If there is no pack thread running, there isn't much we can do.
|
||||||
|
return self._quit(context)
|
||||||
|
|
||||||
|
# Keep handling messages from the background thread.
|
||||||
|
while True:
|
||||||
|
# Block for 5 seconds at a time. The exact duration doesn't matter,
|
||||||
|
# as this while-loop is blocking the main thread anyway.
|
||||||
|
msg = self.packthread.poll(timeout=5)
|
||||||
|
if not msg:
|
||||||
|
# No message received, is fine, just wait for another one.
|
||||||
|
continue
|
||||||
|
|
||||||
|
result = self._on_bat_pack_msg(context, msg)
|
||||||
|
if "RUNNING_MODAL" not in result:
|
||||||
|
return result
|
||||||
|
|
||||||
def invoke(self, context: bpy.types.Context, event: bpy.types.Event) -> set[str]:
|
def invoke(self, context: bpy.types.Context, event: bpy.types.Event) -> set[str]:
|
||||||
filepath, ok = self._presubmit_check(context)
|
filepath, ok = self._presubmit_check(context)
|
||||||
if not ok:
|
if not ok:
|
||||||
|
Loading…
Reference in New Issue
Block a user