From ee104303b7967030c10429e5c0e9494bf4af71cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 6 Sep 2018 06:53:40 +0200 Subject: [PATCH] Donate CPU: create diff report for todays results --- tools/donate-cpu-server.py | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/tools/donate-cpu-server.py b/tools/donate-cpu-server.py index a0149d0a2..929b5c05a 100644 --- a/tools/donate-cpu-server.py +++ b/tools/donate-cpu-server.py @@ -21,6 +21,7 @@ def overviewReport(): html += '

daca@home

\n' html += 'Crash report
\n' html += 'Diff report
\n' + html += 'Diff report - today
\n' html += 'Latest results
\n' html += 'Time report
\n' html += '' @@ -182,6 +183,77 @@ def diffReport(): return html + +def diffReportToday(resultsPath): + html = 'Diff report - today\n' + html += '

Diff report - today

\n' + html += '
\n'
+
+    out = {}
+
+    today = strDateTime()[:10]
+
+    # grep '^1.84 .*\]$' donated-results/* | sed 's/.*\[\(.*\)\]/\1/' | sort | uniq -c
+    for filename in sorted(glob.glob(resultsPath + '/*')):
+        if not os.path.isfile(filename):
+            continue
+        firstLine = True
+        for line in filename:
+            if firstLine:
+                if not line.startswith(today):
+                    break
+                firstLine = False
+                continue
+            if not line.endswith(']\n'):
+                continue
+            index = None
+            if line.startswith('1.84 '):
+                index = 0
+            elif line.startswith('head '):
+                index = 1
+            else:
+                continue
+            messageId = line[line.rfind('[')+1:len(line)-2]
+
+            if not messageId in out:
+                out[messageId] = [0,0]
+            out[messageId][index] += 1
+
+    html += 'MessageID                           1.84    Head\n'
+    sum0 = 0
+    sum1 = 0
+    for messageId in sorted(out.keys()):
+        line = messageId + ' '
+        counts = out[messageId]
+        sum0 += int(counts[0])
+        sum1 += int(counts[1])
+        if counts[0] > 0:
+            c = counts[0]
+            while len(line) < 40 - len(c):
+                line += ' '
+            line += c + ' '
+        if counts[1] > 0:
+            c = counts[1]
+            while len(line) < 48 - len(c):
+                line += ' '
+            line += c
+        line = '' + messageId + '' + line[line.find(' '):]
+        html += line + '\n'
+
+    # Sum
+    html += '================================================\n'
+    line = ''
+    while len(line) < 40 - len(str(sum0)):
+        line += ' '
+    line += str(sum0) + ' '
+    while len(line) < 48 - len(str(sum1)):
+        line += ' '
+    line += str(sum1)
+    html += line + '\n'
+
+    return html
+
+
 def diffMessageIdReport(resultPath, messageId):
     text = messageId + '\n'
     e = '[' + messageId + ']\n'
@@ -273,6 +345,9 @@ class HttpClientThread(Thread):
             elif url == 'diff':
                 html = diffReport()
                 httpGetResponse(self.connection, html, 'text/html')
+            elif url == 'diff-today':
+                html = diffReportToday(self.resultPath)
+                httpGetResponse(self.connection, html, 'text/html')
             elif url.startswith('diff-'):
                 messageId = url[5:]
                 text = diffMessageIdReport(self.resultPath, messageId)