From bf0af624d07669a09d935d9da44bb2d56da65371 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Sat, 23 Sep 2023 17:42:20 +0300 Subject: feat: much better parser (#83) Former-commit-id: dd944d2f42612cc3d724458f7e958e2c4dd93084 --- backend/parser/parser-arm64.REMOVED.git-id | 1 + backend/parser/parser.REMOVED.git-id | 1 - backend/parser/parser.go | 13 +++++++------ 3 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 backend/parser/parser-arm64.REMOVED.git-id delete mode 100644 backend/parser/parser.REMOVED.git-id diff --git a/backend/parser/parser-arm64.REMOVED.git-id b/backend/parser/parser-arm64.REMOVED.git-id new file mode 100644 index 0000000..6015751 --- /dev/null +++ b/backend/parser/parser-arm64.REMOVED.git-id @@ -0,0 +1 @@ +661739cc69d50dc70005a1a294562470f8528559 \ No newline at end of file diff --git a/backend/parser/parser.REMOVED.git-id b/backend/parser/parser.REMOVED.git-id deleted file mode 100644 index b09611f..0000000 --- a/backend/parser/parser.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -72bd63d0667a78d35f643f1f8fcf71d9269d2719 \ No newline at end of file diff --git a/backend/parser/parser.go b/backend/parser/parser.go index 562b8c0..f00c192 100644 --- a/backend/parser/parser.go +++ b/backend/parser/parser.go @@ -10,7 +10,7 @@ import ( ) func ProcessDemo(demoPath string) (int, int, error) { - cmd := exec.Command("bash", "-c", fmt.Sprintf(`echo "FEXBash" && ./backend/parser/parser %s`, demoPath)) + cmd := exec.Command("bash", "-c", fmt.Sprintf(`./parser-arm64 %s`, demoPath)) stdout, err := cmd.StdoutPipe() if err != nil { log.Println(err) @@ -21,14 +21,14 @@ func ProcessDemo(demoPath string) (int, int, error) { var cmTicks, portalCount int for scanner.Scan() { line := scanner.Text() - if strings.Contains(line, "CM ticks") { + if strings.Contains(line, "CM Ticks") { cmTicksStr := strings.TrimSpace(strings.Split(line, ":")[1]) cmTicks, err = strconv.Atoi(cmTicksStr) if err != nil { return 0, 0, err } } - if strings.Contains(line, "Portal count") { + if strings.Contains(line, "Portal Count") { portalCountStr := strings.TrimSpace(strings.Split(line, ":")[1]) portalCount, err = strconv.Atoi(portalCountStr) if err != nil { @@ -36,8 +36,9 @@ func ProcessDemo(demoPath string) (int, int, error) { } } } - cmd.Wait() - // We don't check for error in wait, since FEXBash always gives segmentation fault - // Wanted output is retrieved, so it's okay (i think) + err = cmd.Wait() + if err != nil { + return 0, 0, err + } return portalCount, cmTicks, nil } -- cgit v1.2.3