File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
+ "fmt"
4
5
"os"
5
6
6
7
log "github.com/sirupsen/logrus"
@@ -22,5 +23,10 @@ func main() {
22
23
python .CleanUpVirtualEnv ()
23
24
python .SetupVirtualEnv ()
24
25
25
- python .ExecutePython ("script.py" )
26
+ out , err := python .ExecutePython ("script.py" )
27
+
28
+ if err != nil {
29
+ log .Error (fmt .Sprintf ("Job resulted in error: %s" , err .Error ()))
30
+ }
31
+ log .Info (string (out ))
26
32
}
Original file line number Diff line number Diff line change 1
1
package python
2
2
3
3
import (
4
- "fmt"
5
4
"os/exec"
6
-
7
- log "github.com/sirupsen/logrus"
8
5
)
9
6
10
7
func getPythonCommand () string {
@@ -18,13 +15,9 @@ func getPythonCommand() string {
18
15
}
19
16
20
17
// ExecutePython Executes the provided "scriptName.py" using the python binary from virtual environment
21
- func ExecutePython (scriptName string ) {
18
+ func ExecutePython (scriptName string ) ([] byte , error ) {
22
19
// run python job
23
20
pythonPath := getPythonCommand ()
24
21
cmd := exec .Command (pythonPath , scriptName )
25
- out , err := cmd .CombinedOutput ()
26
- if err != nil {
27
- log .Error (fmt .Sprintf ("%s" , err .Error ()))
28
- }
29
- log .Info (string (out ))
22
+ return cmd .CombinedOutput ()
30
23
}
You can’t perform that action at this time.
0 commit comments