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