donate-cpu.py: Verify argument for jobs (-jN) (#2386)

Yesterday, I observed that some client with a wrong jobs setting
(only "-j") requested one package after another and always uploaded
results where it only said that the argument "-j" is invalid for
Cppcheck.
This check should avoid such cases where results are overwritten with
useless data and the server is kept busy for nothing.
This commit is contained in:
Sebastian 2019-11-22 22:04:41 +01:00 committed by GitHub
parent 5a48ac0c6e
commit 1b28fb2d1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -45,6 +45,10 @@ for arg in sys.argv[1:]:
stop_time = arg[-5:]
print('Stop time:' + stop_time)
elif arg.startswith('-j'):
if not re.match(r'-j\d+', arg):
print('Argument "{}" is invalid.'.format(arg))
print('"-j" must be followed by a positive number.')
sys.exit(1)
jobs = arg
print('Jobs:' + jobs[2:])
elif arg.startswith('--package='):