Manager: allow setup to finish without Blender #104306

Manually merged
Sybren A. Stüvel merged 34 commits from abelli/flamenco:issue100195 into main 2024-09-09 11:22:42 +02:00
Showing only changes of commit 6d745ce0b4 - Show all commits

View File

@ -182,12 +182,11 @@ func (f *Flamenco) FindBlenderExePath(e echo.Context) error {
logger.Warn().AnErr("cause", err).Msg("there was an issue finding Blender")
return sendAPIError(e, http.StatusInternalServerError, "there was an issue finding Blender: %v", err)
default:
isUsable := true
response = append(response, api.BlenderPathCheckResult{
IsUsable: &isUsable,
Input: &result.Input,
Path: &result.FoundLocation,
Cause: &result.BlenderVersion,
IsUsable: true,
Input: result.Input,
Path: result.FoundLocation,
Cause: result.BlenderVersion,
Source: result.Source,
})
}
@ -201,12 +200,11 @@ func (f *Flamenco) FindBlenderExePath(e echo.Context) error {
case err != nil:
logger.Info().AnErr("cause", err).Msg("there was an issue finding Blender as 'blender' on $PATH")
default:
isUsable := true
response = append(response, api.BlenderPathCheckResult{
IsUsable: &isUsable,
Input: &result.Input,
Path: &result.FoundLocation,
Cause: &result.BlenderVersion,
IsUsable: true,
Input: result.Input,
Path: result.FoundLocation,
Cause: result.BlenderVersion,
Source: result.Source,
})
}
@ -225,39 +223,32 @@ func (f *Flamenco) CheckBlenderExePath(e echo.Context) error {
}
command := toCheck.Path
var cause string
var isUsable bool
var path string
logger = logger.With().Str("command", command).Logger()
logger.Info().Msg("checking whether this command leads to Blender")
ctx := e.Request().Context()
checkResult, err := find_blender.CheckBlender(ctx, command)
response := api.BlenderPathCheckResult{
Input: &command,
Source: checkResult.Source,
Path: &path,
IsUsable: &isUsable,
Cause: &cause,
Input: command,
Source: checkResult.Source,
}
switch {
case errors.Is(err, exec.ErrNotFound):
*response.Cause = "Blender could not be found"
response.Cause = "Blender could not be found"
case err != nil:
*response.Cause = fmt.Sprintf("There was an error running the command: %v", err)
response.Cause = fmt.Sprintf("There was an error running the command: %v", err)
default:
*response.IsUsable = true
*response.Path = checkResult.FoundLocation
*response.Cause = fmt.Sprintf("Found %v", checkResult.BlenderVersion)
response.IsUsable = true
response.Path = checkResult.FoundLocation
response.Cause = fmt.Sprintf("Found %v", checkResult.BlenderVersion)
}
logger.Info().
Str("input", *response.Input).
Str("foundLocation", *response.Path).
Str("result", *response.Cause).
Bool("isUsable", *response.IsUsable).
Str("input", response.Input).
Str("foundLocation", response.Path).
Str("result", response.Cause).
Bool("isUsable", response.IsUsable).
Msg("result of command check")
return e.JSON(http.StatusOK, response)
@ -274,15 +265,13 @@ func (f *Flamenco) SaveSetupAssistantConfig(e echo.Context) error {
logger = logger.With().Interface("config", setupAssistantCfg).Logger()
isConfigInvalid := setupAssistantCfg.StorageLocation == "" ||
setupAssistantCfg.BlenderExecutable.IsUsable == nil
isConfigIncomplete := setupAssistantCfg.StorageLocation == "" ||
!setupAssistantCfg.BlenderExecutable.IsUsable ||
setupAssistantCfg.BlenderExecutable.Path == ""
isConfigIncomplete := setupAssistantCfg.BlenderExecutable.Path == nil ||
setupAssistantCfg.BlenderExecutable.Input == nil
if isConfigInvalid || setupAssistantCfg.BlenderExecutable.Source != "default" && isConfigIncomplete {
logger.Warn().Msg("setup assistant: configuration is invalid or incomplete, unable to accept")
return sendAPIError(e, http.StatusBadRequest, "configuration is invalid or incomplete")
if isConfigIncomplete && setupAssistantCfg.BlenderExecutable.Source != "default" {
logger.Warn().Msg("setup assistant: configuration is incomplete, unable to accept")
return sendAPIError(e, http.StatusBadRequest, "configuration is incomplete")
}
conf := f.config.Get()
@ -297,10 +286,10 @@ func (f *Flamenco) SaveSetupAssistantConfig(e echo.Context) error {
case api.BlenderPathSourcePathEnvvar:
// The input command can be found on $PATH, and thus we don't need to save
// the absolute path to Blender here.
executable = *setupAssistantCfg.BlenderExecutable.Input
executable = setupAssistantCfg.BlenderExecutable.Input
case api.BlenderPathSourceInputPath:
// The path should be used as-is.
executable = *setupAssistantCfg.BlenderExecutable.Path
executable = setupAssistantCfg.BlenderExecutable.Path
}
if commandNeedsQuoting(executable) {
executable = strconv.Quote(executable)