p2: add a way to run visualise.py cmd
This commit is contained in:
parent
07b91ea5e4
commit
a46d1403c3
30
p2/run.go
30
p2/run.go
@ -3,11 +3,15 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
"os/exec"
|
||||
|
||||
"git.dotya.ml/wanderer/ak9im/p2/stats"
|
||||
)
|
||||
|
||||
var datafile = flag.String("datafile", "", "read data from this file")
|
||||
var (
|
||||
datafile = flag.String("datafile", "", "read data from this file")
|
||||
vis = flag.Bool("vis", false, "run 'python visualise.py' to produce visualisations")
|
||||
)
|
||||
|
||||
func run() error {
|
||||
flag.Parse()
|
||||
@ -76,5 +80,29 @@ func run() error {
|
||||
}
|
||||
}
|
||||
|
||||
if *vis {
|
||||
err := visualise()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func visualise() error {
|
||||
red := "\033[31m"
|
||||
cyan := "\033[36m"
|
||||
reset := "\033[0m"
|
||||
f := "visualise.py"
|
||||
|
||||
log.Printf("running %s`python %s`%s", cyan, f, reset)
|
||||
|
||||
out, err := exec.Command("python", f).CombinedOutput()
|
||||
if err != nil {
|
||||
log.Printf("visualise failed with:\n\n%s%s%s\n", red, out, reset)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user