grim/hgkeeper

add a switch to disable the cache with it forced off right now as apparently nothing ever expires right now
package hg
import (
"fmt"
"os/exec"
"path/filepath"
"strings"
log "github.com/sirupsen/logrus"
)
func TemplatesDir() (string, error) {
templatesDir, err := Config("web.templates").Exec()
if err != nil || templatesDir == "" {
if err != nil {
log.Warnf("failed to get web.templates config setting: %v", err)
}
args := []string{
"/usr/bin/env",
"python3",
"-c",
"import mercurial;print(mercurial.__path__[0])",
}
cmd := exec.Command(args[0], args[1:]...)
raw, err := cmd.CombinedOutput()
if err != nil {
return "", err
}
templatesDir = strings.TrimSpace(string(raw))
if templatesDir == "" {
return "", fmt.Errorf("failed to find the templates directory")
}
templatesDir = filepath.Join(templatesDir, "templates")
}
return templatesDir, nil
}