From b735585f9a1f7411be82f2e5581388d812de4c4e Mon Sep 17 00:00:00 2001 From: Toyosatomimi no Miko Date: Wed, 10 Apr 2024 23:14:50 -0700 Subject: [PATCH] Added linuxmint.go --- checkers/linuxmint.go | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 checkers/linuxmint.go diff --git a/checkers/linuxmint.go b/checkers/linuxmint.go new file mode 100644 index 0000000..02c97ce --- /dev/null +++ b/checkers/linuxmint.go @@ -0,0 +1,50 @@ +package checkers + +import { + "fmt" + "io/ioutil" + "net/http" + "regexp" + "strings" + "time" +} + +var LinuxMintProject Project = Project{ + Name: "linuxmint", + Properties: DefaultProjectProperties, + NumOfCheckers: 1, + Checkers: []*ProjectChecker { + GetDefaultChecker("linuxmint", true, func(*Project) (bool, error) { + data := EnabledProjects["linuxmint"].Properties + err := AssertStrings(data.Upstream, data.OOSInterval) + if err != nil { + return false, GetError(err, "Linux Mint", "config sanity check") + } + upstream_body, err := httpGET(data.Upstream) + if err != nil { + return false, GetError(err, "Linux Mint", "getting upstream file") + } + page := string(upstream_body) + indexOfFile := strings.Index(page, "mirror.csclub.uwaterloo.ca/linuxmint") + if indexOfFile == -1 { + return false, GetError(nil, "Linux Mint", "no index of file") + } + re := regexp.MustCompile(`(?P\d+):(?P\d+)`) + m := re.FindStringSubmatch(page[indexOfFile:]) + if len(m) == 0 || len(m[0]) == 0 { + return false, GetError(nil, "Linux Mint", "no matches for regex in file") + } + split := strings.Split(m[0], ":") + hours, err := strconv.Atoi(split[0]) + if err != nil { + return false, GetError(err, "Linux Mint", "parsing hours") + } + minutes, err := strconv.Atoi(split[1]) + if err != nil { + return false, GetError(err, "Linux Mint", "parsing minutes") + } + duration := time.Duration(hours) * time.Hour + time.Duration(minutes) * time.Minute + return (duration <= time.Duration(data.OOSInterval) * time.Second), nil + }), + }, +} \ No newline at end of file