Prevent a potential crash of Blender. Calling
`context.window_manager.modal_handler_add(self)` from an operator that does
not actually run modally can cause problems. So now that's called only
when running modally.
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.
Refactor the job submission operator, to make it easier to allow executing
the operator (that is, running in the foreground, blocking execution until
submission is done).
No functional changes.
This gives job type authors more control over how settings 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).
Note that this isn't used in the web interface yet.
Remove some Python 3.10 features to make the add-on compatible with py39.
This is the Python version that's bundled with Blender 2.93 LTS, for which
I got a request to see if it could be supported.
The Blender version still isn't officially supported, but this should make
things at least not immediately fail.
Avoid these warnings on the console:
```
WARN (bpy.rna): source/blender/python/intern/bpy_rna.cc:1339
pyrna_enum_to_py: current value '0' matches no enum in 'Scene', 'Scene',
'flamenco_job_type'
```
The solution was two-fold:
- Use a non-empty string as the identifier for the 'Select a Job Type'
choice.
- Give the property a default value.
Instead of storing the cached manager info in the Blender preferences,
store the info in a JSON file. The file is located in the user prefs
folder (`~/.config/blender/{version}/config` on Linux).
This also reduces the number of 'refresh' operators to a single one, which
then fetches all necessary info from the Manager.
This fixes an issue (reported via chat) where worker tags were sometimes
not retained across file saves.
This can help to debug issues.
Note that these are logged at `INFO` level, and thus probably won't be
seen with Python's default logging configuration.
Replace calls to `Path.absolute()` and `Path.resolve()` with
`bpathlib.make_absolute(path)`.
The replaced functions can transform drive letters on Windows to UNC
notation. Either all of Flamenco + BAT should be using UNC notation, or
drive letters, but mixing those will cause errors.
Fix an issue where a submission error would keep the BAT status set to
`INVESTIGATING`, which hides the 'Submit to Flamenco' button. In case of
an error, it's now properly set to `ABORTED`, which does show that button.
When refreshing the list of available job types, Blender recreates the
job type property itself, clearing out any previously chosen value. The
add-on tries to restore that previously chosen value, and now also
gracefully handles the case where this job type is no longer available.