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

@@ -38,21 +38,17 @@ func (s *scriptScraper) runScraperScript(ctx context.Context, inString string, o
var cmd *exec.Cmd
if python.IsPythonCommand(command[0]) {
pythonPath := s.globalConfig.GetPythonPath()
var p *python.Python
if pythonPath != "" {
p = python.New(pythonPath)
p, err := python.Resolve(pythonPath)
if err != nil {
logger.Warnf("%s", err)
} else {
p, _ = python.Resolve()
cmd = p.Command(context.TODO(), command[1:])
}
if p != nil {
cmd = p.Command(ctx, 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:]...)
}