Log more when resolving Python (#4185)

* Log more when resolving Python

Users often have problems configuring their Python installations

* Convert if-else ladder to switch statement
* Consolidate Python resolution

Adds additional logging to plugin tasks to
align with the logging that scrapers output.
This commit is contained in:
Maista
2023-11-22 00:04:15 +01:00
committed by GitHub
parent 987fa80786
commit 0dcd58763f
3 changed files with 37 additions and 25 deletions

View File

@@ -7,6 +7,7 @@ import (
"fmt"
"io"
"os/exec"
"strings"
"sync"
stashExec "github.com/stashapp/stash/pkg/exec"
@@ -45,21 +46,17 @@ func (t *rawPluginTask) Start() error {
var cmd *exec.Cmd
if python.IsPythonCommand(command[0]) {
pythonPath := t.serverConfig.GetPythonPath()
var p *python.Python
if pythonPath != "" {
p = python.New(pythonPath)
} else {
p, _ = python.Resolve()
}
p, err := python.Resolve(pythonPath)
if p != nil {
if err != nil {
logger.Warnf("%s", err)
} else {
cmd = p.Command(context.TODO(), command[1:])
}
// if could not find python, just use the command args as-is
}
if cmd == nil {
// if could not find python, just use the command args as-is
cmd = stashExec.Command(command[0], command[1:]...)
}
@@ -99,6 +96,8 @@ func (t *rawPluginTask) Start() error {
go t.handlePluginStderr(t.plugin.Name, stderr)
t.cmd = cmd
logger.Debugf("Plugin %s started: %s", t.plugin.Name, strings.Join(cmd.Args, " "))
// send the stdout to the plugin output
go func() {
defer t.waitGroup.Done()
@@ -113,6 +112,7 @@ func (t *rawPluginTask) Start() error {
errStr := err.Error()
output.Error = &errStr
}
logger.Debugf("Plugin %s finished", t.plugin.Name)
t.result = &output
}()