From 28d1682a54e9a08aa5a17bb7ee2bde40a712e152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 24 Aug 2018 18:49:11 +0200 Subject: [PATCH] Donate CPU: Some fixes in donate-cpu.py --- tools/donate-cpu.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py index 498949bbe..ee3f50f62 100644 --- a/tools/donate-cpu.py +++ b/tools/donate-cpu.py @@ -29,26 +29,31 @@ def checkRequirements(): result = False return result -def getCppcheck(workPath): +def getCppcheck(cppcheckPath): print('Get Cppcheck..') - cppcheckPath = workPath + '/cppcheck' if os.path.exists(cppcheckPath): os.chdir(cppcheckPath) subprocess.call(['git', 'checkout', '-f']) subprocess.call(['git', 'pull']) else: subprocess.call(['git', 'clone', 'http://github.com/danmar/cppcheck.git', cppcheckPath]) + if not os.path.exists(cppcheckPath): + return False time.sleep(2) + return True + def compile(cppcheckPath): print('Compiling Cppcheck..') try: + os.chdir(cppcheckPath) subprocess.call(['make', 'SRCDIR=build', 'CXXFLAGS=-O2']) - subprocess.call(['./cppcheck', '--version']) + subprocess.call([cppcheckPath + '/cppcheck', '--version']) except OSError: return False return True + def getPackage(): print('Connecting to server to get assigned work..') package = None @@ -62,6 +67,7 @@ def getPackage(): sock.close() return package + def wget(url, destfile): subprocess.call( ['wget', '--tries=10', '--timeout=300', '-O', destfile, url]) @@ -120,7 +126,11 @@ if not os.path.exists(workpath): os.mkdir(workpath) cppcheckPath = workpath + '/cppcheck' while True: - getCppcheck(workpath) + if not getCppcheck(cppcheckPath): + time.sleep(5) + if not getCppcheck(cppcheckPath): + print('Failed to clone Cppcheck, retry later') + sys.exit(1) if compile(cppcheckPath) == False: print('Failed to compile Cppcheck, retry later') sys.exit(1)