Donate CPU: Updated client script. Try to catch compile errors better.
This commit is contained in:
parent
8c88f65fb2
commit
138e53aeb9
|
@ -17,10 +17,11 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
|
import re
|
||||||
|
|
||||||
def checkRequirements():
|
def checkRequirements():
|
||||||
result = True
|
result = True
|
||||||
for app in ['g++', 'git', 'make', 'wget', 'tar']:
|
for app in ['g++', 'git', 'make', 'wget', 'rm', 'tar']:
|
||||||
try:
|
try:
|
||||||
subprocess.call([app, '--version'])
|
subprocess.call([app, '--version'])
|
||||||
except OSError:
|
except OSError:
|
||||||
|
@ -40,7 +41,12 @@ def getCppcheck(workPath):
|
||||||
|
|
||||||
def compile(cppcheckPath):
|
def compile(cppcheckPath):
|
||||||
print('Compiling Cppcheck..')
|
print('Compiling Cppcheck..')
|
||||||
subprocess.call(['make', 'SRCDIR=build', 'CXXFLAGS=-O2'])
|
try:
|
||||||
|
subprocess.call(['make', 'SRCDIR=build', 'CXXFLAGS=-O2'])
|
||||||
|
subprocess.call(['./cppcheck', '--version'])
|
||||||
|
except OSError:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def getPackage():
|
def getPackage():
|
||||||
print('Connecting to server to get assigned work..')
|
print('Connecting to server to get assigned work..')
|
||||||
|
@ -82,7 +88,16 @@ def scanPackage(workPath, package):
|
||||||
print(cmd)
|
print(cmd)
|
||||||
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
comm = p.communicate()
|
comm = p.communicate()
|
||||||
return comm[1]
|
errout = comm[1]
|
||||||
|
count = 0
|
||||||
|
for line in errout.split('\n'):
|
||||||
|
if re.match(r'.*:[0-9]+:[0-9]+: [a-z]+: .*\]$', line):
|
||||||
|
count += 1
|
||||||
|
if count == 0:
|
||||||
|
errout = None
|
||||||
|
else:
|
||||||
|
print('Number of issues: ' + str(count))
|
||||||
|
return errout
|
||||||
|
|
||||||
def uploadResults(package, results):
|
def uploadResults(package, results):
|
||||||
print('Uploading results..')
|
print('Uploading results..')
|
||||||
|
@ -105,8 +120,12 @@ if not os.path.exists(workpath):
|
||||||
cppcheckPath = workpath + '/cppcheck'
|
cppcheckPath = workpath + '/cppcheck'
|
||||||
while True:
|
while True:
|
||||||
getCppcheck(workpath)
|
getCppcheck(workpath)
|
||||||
compile(cppcheckPath)
|
if compile(cppcheckPath) == False:
|
||||||
|
print('Failed to compile Cppcheck, retry later')
|
||||||
|
sys.exit(1)
|
||||||
package = getPackage()
|
package = getPackage()
|
||||||
results = scanPackage(workpath, package)
|
results = scanPackage(workpath, package)
|
||||||
if results:
|
if results is None:
|
||||||
|
print('No results to upload')
|
||||||
|
else:
|
||||||
uploadResults(package, results)
|
uploadResults(package, results)
|
||||||
|
|
Loading…
Reference in New Issue