Skip to content
Snippets Groups Projects
Commit 3200929b authored by Sybren A. Stüvel's avatar Sybren A. Stüvel
Browse files

Added support for passing Python scripts to Blender in task definitions.

parent 18dd9c70
No related branches found
No related tags found
No related merge requests found
...@@ -18,6 +18,7 @@ changed functionality, fixed bugs). ...@@ -18,6 +18,7 @@ changed functionality, fixed bugs).
- Added `--single` or `-1` CLI option to shut down the Worker after executing a single task. - Added `--single` or `-1` CLI option to shut down the Worker after executing a single task.
- Added `--test` or `-t` CLI option to start in testing mode. See Flamenco documentation - Added `--test` or `-t` CLI option to start in testing mode. See Flamenco documentation
for more details. Requires Flamenco Manager 2.1.0+. for more details. Requires Flamenco Manager 2.1.0+.
- Added support for passing Python scripts to Blender in task definitions.
## Version 2.0.8 (released 2017-09-07) ## Version 2.0.8 (released 2017-09-07)
......
...@@ -565,6 +565,8 @@ class BlenderRenderCommand(AbstractSubprocessCommand): ...@@ -565,6 +565,8 @@ class BlenderRenderCommand(AbstractSubprocessCommand):
'--background', '--background',
settings['filepath'], settings['filepath'],
] ]
if settings.get('python_expr'):
cmd.extend(['--python-expr', settings['python_expr']])
if settings.get('render_output'): if settings.get('render_output'):
cmd.extend(['--render-output', settings['render_output']]) cmd.extend(['--render-output', settings['render_output']])
if settings.get('format'): if settings.get('format'):
......
from pathlib import Path
import subprocess
from unittest.mock import patch, call from unittest.mock import patch, call
from test_runner import AbstractCommandTest from test_runner import AbstractCommandTest
...@@ -67,8 +70,6 @@ class BlenderRenderTest(AbstractCommandTest): ...@@ -67,8 +70,6 @@ class BlenderRenderTest(AbstractCommandTest):
def test_cli_args(self): def test_cli_args(self):
"""Test that CLI arguments in the blender_cmd setting are handled properly.""" """Test that CLI arguments in the blender_cmd setting are handled properly."""
from pathlib import Path
import subprocess
from mock_responses import CoroMock from mock_responses import CoroMock
filepath = str(Path(__file__).parent) filepath = str(Path(__file__).parent)
...@@ -100,3 +101,38 @@ class BlenderRenderTest(AbstractCommandTest): ...@@ -100,3 +101,38 @@ class BlenderRenderTest(AbstractCommandTest):
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
) )
def test_python_expr(self):
from mock_responses import CoroMock
filepath = str(Path(__file__).parent)
settings = {
# Point blender_cmd to this file so that we're sure it exists.
'blender_cmd': '%s --with --cli="args for CLI"' % __file__,
'python_expr': 'print("yay in \'quotes\'")',
'chunk_size': 100,
'frames': '1..2',
'format': 'JPEG',
'filepath': filepath,
}
cse = CoroMock(...)
cse.coro.return_value.wait = CoroMock(return_value=0)
with patch('asyncio.create_subprocess_exec', new=cse) as mock_cse:
self.loop.run_until_complete(self.cmd.run(settings))
mock_cse.assert_called_once_with(
__file__,
'--with',
'--cli=args for CLI',
'--enable-autoexec',
'-noaudio',
'--background',
filepath,
'--python-expr', 'print("yay in \'quotes\'")',
'--render-format', 'JPEG',
'--render-frame', '1..2',
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment