diff --git a/tools/donate-cpu-server.py b/tools/donate-cpu-server.py index a4a139143..bec52bb7e 100644 --- a/tools/donate-cpu-server.py +++ b/tools/donate-cpu-server.py @@ -11,6 +11,8 @@ from threading import Thread import subprocess import sys +OLD_VERSION = '1.86' + def strDateTime(): d = datetime.date.strftime(datetime.datetime.now().date(), '%Y-%m-%d') t = datetime.time.strftime(datetime.datetime.now().time(), '%H:%M') @@ -51,7 +53,7 @@ def fmt(a,b,c,d,e): def latestReport(latestResults): html = 'Latest daca@home results\n' html += '

Latest daca@home results

' - html += '
\n' + fmt('Package','Date       Time ','1.85','Head','Diff') + '\n'
+    html += '
\n' + fmt('Package','Date       Time ',OLD_VERSION,'Head','Diff') + '\n'
 
     # Write report for latest results
     for filename in latestResults:
@@ -73,7 +75,7 @@ def latestReport(latestResults):
                 count = line.split(' ')[1:]
             elif line.startswith('head '):
                 added += 1
-            elif line.startswith('1.85 '):
+            elif line.startswith(OLD_VERSION + ' '):
                 lost += 1
         diff = ''
         if lost > 0:
@@ -90,7 +92,7 @@ def crashReport():
     html = 'Crash report\n'
     html += '

Crash report

\n' html += '
\n'
-    html += 'Package                                 1.85  Head\n'
+    html += 'Package                                 ' + OLD_VERSION + '  Head\n'
     for filename in sorted(glob.glob(os.path.expanduser('~/daca@home/donated-results/*'))):
         if not os.path.isfile(filename):
             continue
@@ -121,7 +123,7 @@ def crashReport():
 
 def diffReportFromDict(out, today):
     html = '
\n'
-    html += 'MessageID                           1.85    Head\n'
+    html += 'MessageID                           ' + OLD_VERSION + '    Head\n'
     sum0 = 0
     sum1 = 0
     for messageId in sorted(out.keys()):
@@ -177,7 +179,7 @@ def diffReport(resultsPath):
             if not line.endswith(']'):
                 continue
             index = None
-            if line.startswith('1.85 '):
+            if line.startswith(OLD_VERSION + ' '):
                 index = 0
             elif line.startswith('head '):
                 index = 1
@@ -253,7 +255,7 @@ def diffMessageIdTodayReport(resultPath, messageId):
 
 def timeReport(resultPath):
     text = 'Time report\n\n'
-    text += 'Package 1.85 Head\n'
+    text += 'Package ' + OLD_VERSION + ' Head\n'
 
     totalTime184 = 0.0
     totalTimeHead = 0.0
@@ -381,8 +383,9 @@ def server(server_address_port, packages, packageIndex, resultPath):
             newThread = HttpClientThread(connection, cmd, resultPath, latestResults)
             newThread.start()
         elif cmd=='GetCppcheckVersions\n':
-            print('[' + strDateTime() + '] GetCppcheckVersions: head 1.85')
-            connection.send('head 1.85')
+            reply = 'head ' + OLD_VERSION
+            print('[' + strDateTime() + '] GetCppcheckVersions: ' + reply)
+            connection.send(reply)
             connection.close()
         elif cmd=='get\n':
             pkg = packages[packageIndex].strip()
diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py
index 9cd96a222..41b72b75e 100644
--- a/tools/donate-cpu.py
+++ b/tools/donate-cpu.py
@@ -89,7 +89,6 @@ def compile(cppcheckPath, jobs):
 
 def getCppcheckVersions():
     print('Connecting to server to get Cppcheck versions..')
-    package = None
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     server_address = ('cppcheck.osuosl.org', 8000)
     try:
@@ -97,7 +96,7 @@ def getCppcheckVersions():
         sock.send(b'GetCppcheckVersions\n')
         versions = sock.recv(256)
     except socket.error:
-        return ['head', '1.85']
+        return None
     sock.close()
     return versions.decode('utf-8').split()
 
@@ -362,6 +361,9 @@ while True:
         print('Failed to clone Cppcheck, retry later')
         sys.exit(1)
     cppcheckVersions = getCppcheckVersions()
+    if cppcheckVersions is None:
+        print('Failed to communicate with server, retry later')
+        sys.exit(1)
     for ver in cppcheckVersions:
         if ver == 'head':
             if compile(cppcheckPath, jobs) == False: