Start working on blender-render
command
The command doesn't actually execute anything yet.
This commit is contained in:
parent
f1ad0a66a8
commit
71edb139dd
@ -117,6 +117,7 @@ func TestSimpleBlenderRenderHappy(t *testing.T) {
|
||||
"exe": "{blender}",
|
||||
"blendfile": settings["filepath"].(string),
|
||||
"args": expectCliArgs,
|
||||
"argsBefore": make([]interface{}, 0),
|
||||
}, t0.Commands[0].Parameters)
|
||||
|
||||
tVideo := aj.Tasks[4] // This should be a video encoding task
|
||||
|
@ -93,6 +93,7 @@ function authorRenderTasks(settings, renderDir, renderOutput) {
|
||||
const task = author.Task(`render-${chunk}`, "blender");
|
||||
const command = author.Command("blender-render", {
|
||||
exe: settings.blender_cmd,
|
||||
argsBefore: [],
|
||||
blendfile: settings.filepath,
|
||||
args: [
|
||||
"--render-output", path.join(renderDir, path.basename(renderOutput)),
|
||||
|
72
internal/worker/command_blender.go
Normal file
72
internal/worker/command_blender.go
Normal file
@ -0,0 +1,72 @@
|
||||
package worker
|
||||
|
||||
/* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* Original Code Copyright (C) 2022 Blender Foundation.
|
||||
*
|
||||
* This file is part of Flamenco.
|
||||
*
|
||||
* Flamenco is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* Flamenco is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* Flamenco. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK ***** */
|
||||
|
||||
/* This file contains the commands in the "blender" type group. */
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"gitlab.com/blender/flamenco-ng-poc/pkg/api"
|
||||
)
|
||||
|
||||
type BlenderSettings struct {
|
||||
exe string // Expansion of `{blender}`: executable path + its CLI parameters defined by the Manager.
|
||||
argsBefore []string // Additional CLI arguments defined by the job compiler script, to go before the blend file name.
|
||||
blendfile string // Path of the file to open.
|
||||
args []string // Additional CLI arguments defined by the job compiler script, to go after the blend file name.
|
||||
}
|
||||
|
||||
// cmdBlender executes the "blender-render" command.
|
||||
func (ce *CommandExecutor) cmdBlenderRender(ctx context.Context, logger zerolog.Logger, taskID string, cmd api.Command) error {
|
||||
settings := BlenderSettings{
|
||||
exe: cmd.Settings["exe"].(string),
|
||||
argsBefore: cmd.Settings["argsBefore"].([]string),
|
||||
blendfile: cmd.Settings["blendfile"].(string),
|
||||
args: cmd.Settings["args"].([]string),
|
||||
}
|
||||
if settings.exe == "" {
|
||||
logger.Warn().Interface("command", cmd).Msg("missing 'exe' setting")
|
||||
return fmt.Errorf("missing 'exe' setting: %+v", cmd)
|
||||
}
|
||||
if settings.blendfile == "" {
|
||||
logger.Warn().Interface("command", cmd).Msg("missing 'blendfile' setting")
|
||||
return fmt.Errorf("missing 'blendfile' setting: %+v", cmd)
|
||||
}
|
||||
|
||||
cliArgs := make([]string, 0)
|
||||
cliArgs = append(cliArgs, settings.argsBefore...)
|
||||
cliArgs = append(cliArgs, settings.blendfile)
|
||||
cliArgs = append(cliArgs, settings.args...)
|
||||
execCmd := exec.CommandContext(ctx, settings.exe, cliArgs...)
|
||||
logger.Info().
|
||||
Str("cmdName", cmd.Name).
|
||||
Str("execCmd", execCmd.String()).
|
||||
Msg("going to execute Blender")
|
||||
|
||||
// if err := ce.listener.LogProduced(ctx, taskID, fmt.Sprintf("echo: %q", messageStr)); err != nil {
|
||||
// return err
|
||||
// }
|
||||
return nil
|
||||
}
|
@ -70,6 +70,7 @@ func NewCommandExecutor(listener CommandListener, timeService TimeService) *Comm
|
||||
ce.registry = map[string]commandCallable{
|
||||
"echo": ce.cmdEcho,
|
||||
"sleep": ce.cmdSleep,
|
||||
"blender-render": ce.cmdBlenderRender,
|
||||
}
|
||||
|
||||
return ce
|
||||
|
Loading…
x
Reference in New Issue
Block a user