aboutsummaryrefslogtreecommitdiff
path: root/backend/parser
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-09-23 17:42:20 +0300
committerGitHub <noreply@github.com>2023-09-23 17:42:20 +0300
commitbf0af624d07669a09d935d9da44bb2d56da65371 (patch)
treee1ba7a966375a2f311e9a16fe0f9f5c5493f0135 /backend/parser
parentfeat: discussions (#59) (diff)
downloadlphub-bf0af624d07669a09d935d9da44bb2d56da65371.tar.gz
lphub-bf0af624d07669a09d935d9da44bb2d56da65371.tar.bz2
lphub-bf0af624d07669a09d935d9da44bb2d56da65371.zip
feat: much better parser (#83)
Former-commit-id: dd944d2f42612cc3d724458f7e958e2c4dd93084
Diffstat (limited to 'backend/parser')
-rw-r--r--backend/parser/parser-arm64.REMOVED.git-id1
-rw-r--r--backend/parser/parser.REMOVED.git-id1
-rw-r--r--backend/parser/parser.go13
3 files changed, 8 insertions, 7 deletions
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 @@
172bd63d0667a78d35f643f1f8fcf71d9269d2719 \ 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 (
10) 10)
11 11
12func ProcessDemo(demoPath string) (int, int, error) { 12func ProcessDemo(demoPath string) (int, int, error) {
13 cmd := exec.Command("bash", "-c", fmt.Sprintf(`echo "FEXBash" && ./backend/parser/parser %s`, demoPath)) 13 cmd := exec.Command("bash", "-c", fmt.Sprintf(`./parser-arm64 %s`, demoPath))
14 stdout, err := cmd.StdoutPipe() 14 stdout, err := cmd.StdoutPipe()
15 if err != nil { 15 if err != nil {
16 log.Println(err) 16 log.Println(err)
@@ -21,14 +21,14 @@ func ProcessDemo(demoPath string) (int, int, error) {
21 var cmTicks, portalCount int 21 var cmTicks, portalCount int
22 for scanner.Scan() { 22 for scanner.Scan() {
23 line := scanner.Text() 23 line := scanner.Text()
24 if strings.Contains(line, "CM ticks") { 24 if strings.Contains(line, "CM Ticks") {
25 cmTicksStr := strings.TrimSpace(strings.Split(line, ":")[1]) 25 cmTicksStr := strings.TrimSpace(strings.Split(line, ":")[1])
26 cmTicks, err = strconv.Atoi(cmTicksStr) 26 cmTicks, err = strconv.Atoi(cmTicksStr)
27 if err != nil { 27 if err != nil {
28 return 0, 0, err 28 return 0, 0, err
29 } 29 }
30 } 30 }
31 if strings.Contains(line, "Portal count") { 31 if strings.Contains(line, "Portal Count") {
32 portalCountStr := strings.TrimSpace(strings.Split(line, ":")[1]) 32 portalCountStr := strings.TrimSpace(strings.Split(line, ":")[1])
33 portalCount, err = strconv.Atoi(portalCountStr) 33 portalCount, err = strconv.Atoi(portalCountStr)
34 if err != nil { 34 if err != nil {
@@ -36,8 +36,9 @@ func ProcessDemo(demoPath string) (int, int, error) {
36 } 36 }
37 } 37 }
38 } 38 }
39 cmd.Wait() 39 err = cmd.Wait()
40 // We don't check for error in wait, since FEXBash always gives segmentation fault 40 if err != nil {
41 // Wanted output is retrieved, so it's okay (i think) 41 return 0, 0, err
42 }
42 return portalCount, cmTicks, nil 43 return portalCount, cmTicks, nil
43} 44}