mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Apply python path resolution to plugins (#1990)
* Symlink python3 to python * Apply path resolution to plugins
This commit is contained in:
committed by
GitHub
parent
a7ed0a7004
commit
2c7e0f0571
@@ -29,6 +29,19 @@ type rawPluginTask struct {
|
||||
done chan bool
|
||||
}
|
||||
|
||||
func FindPythonExecutable() (string, error) {
|
||||
_, err := exec.LookPath("python3")
|
||||
|
||||
if err != nil {
|
||||
_, err = exec.LookPath("python")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "python", nil
|
||||
}
|
||||
return "python3", nil
|
||||
}
|
||||
|
||||
func (t *rawPluginTask) Start() error {
|
||||
if t.started {
|
||||
return errors.New("task already started")
|
||||
@@ -39,6 +52,13 @@ func (t *rawPluginTask) Start() error {
|
||||
return fmt.Errorf("empty exec value in operation %s", t.operation.Name)
|
||||
}
|
||||
|
||||
if command[0] == "python" || command[0] == "python3" {
|
||||
executable, err := FindPythonExecutable()
|
||||
if err == nil {
|
||||
command[0] = executable
|
||||
}
|
||||
}
|
||||
|
||||
cmd := exec.Command(command[0], command[1:]...)
|
||||
|
||||
stdin, err := cmd.StdinPipe()
|
||||
|
||||
Reference in New Issue
Block a user