donate-cpu: add --package argument

This commit is contained in:
Daniel Marjamäki 2018-11-19 10:04:53 +01:00
parent 42e516582c
commit 4d8a85ec4d
1 changed files with 16 additions and 3 deletions

View File

@ -263,6 +263,7 @@ def uploadResults(package, results):
jobs = '-j1' jobs = '-j1'
stopTime = None stopTime = None
workpath = os.path.expanduser('~/cppcheck-donate-cpu-workfolder') workpath = os.path.expanduser('~/cppcheck-donate-cpu-workfolder')
packageUrl = None
for arg in sys.argv[1:]: for arg in sys.argv[1:]:
# --stop-time=12:00 => run until ~12:00 and then stop # --stop-time=12:00 => run until ~12:00 and then stop
if arg.startswith('--stop-time='): if arg.startswith('--stop-time='):
@ -271,6 +272,9 @@ for arg in sys.argv[1:]:
elif arg.startswith('-j'): elif arg.startswith('-j'):
jobs = arg jobs = arg
print('Jobs:' + jobs[2:]) print('Jobs:' + jobs[2:])
elif arg.startswith('--package='):
packageUrl = arg[arg.find('=')+1:]
print('Package:' + packageUrl)
elif arg.startswith('--work-path='): elif arg.startswith('--work-path='):
workpath = arg[arg.find('=')+1:] workpath = arg[arg.find('=')+1:]
print('workpath:' + workpath) print('workpath:' + workpath)
@ -312,9 +316,13 @@ while True:
if compile(cppcheckPath, jobs) == False: if compile(cppcheckPath, jobs) == False:
print('Failed to compile Cppcheck, retry later') print('Failed to compile Cppcheck, retry later')
sys.exit(1) sys.exit(1)
package = getPackage() if packageUrl:
if len(package) == 0: package = packageUrl
time.sleep(5) else:
package = getPackage()
while len(package) == 0:
print("network or server might be temporarily down.. will try again in 30 seconds..")
time.sleep(30)
package = getPackage() package = getPackage()
tgz = downloadPackage(workpath, package) tgz = downloadPackage(workpath, package)
unpackPackage(workpath, tgz) unpackPackage(workpath, tgz)
@ -339,6 +347,11 @@ while True:
output += 'elapsed-time:' + elapsedTime + '\n' output += 'elapsed-time:' + elapsedTime + '\n'
if not crash: if not crash:
output += 'diff:\n' + diffResults(workpath, 'head', resultsToDiff[0], '1.85', resultsToDiff[1]) + '\n' output += 'diff:\n' + diffResults(workpath, 'head', resultsToDiff[0], '1.85', resultsToDiff[1]) + '\n'
if packageUrl:
print('=========================================================')
print(output)
print('=========================================================')
break
uploadResults(package, output) uploadResults(package, output)
print('Results have been uploaded') print('Results have been uploaded')
print('Sleep 5 seconds..') print('Sleep 5 seconds..')