donate-cpu.py: Fix possible usage of none type variable

"bandwidth_limit" is None by default and therefore can not be used for string
concatenation in this case.
This commit is contained in:
versat 2019-01-19 12:45:08 +01:00
parent e3db99a16e
commit dfaba30290
1 changed files with 6 additions and 5 deletions

View File

@ -374,11 +374,12 @@ for arg in sys.argv[1:]:
print('Thank you!') print('Thank you!')
if not checkRequirements(): if not checkRequirements():
sys.exit(1) sys.exit(1)
if subprocess.call(['wget', '--limit-rate=' + bandwidth_limit, '-q', '--spider', 'cppcheck.osuosl.org']) is 2: if bandwidth_limit and isinstance(bandwidth_limit, str):
print('Error: Bandwidth limit value "' + bandwidth_limit + '" is invalid.') if subprocess.call(['wget', '--limit-rate=' + bandwidth_limit, '-q', '--spider', 'cppcheck.osuosl.org']) is 2:
sys.exit(1) print('Error: Bandwidth limit value "' + bandwidth_limit + '" is invalid.')
else: sys.exit(1)
print('Bandwidth-limit: ' + bandwidth_limit) else:
print('Bandwidth-limit: ' + bandwidth_limit)
if not os.path.exists(workpath): if not os.path.exists(workpath):
os.mkdir(workpath) os.mkdir(workpath)
cppcheckPath = workpath + '/cppcheck' cppcheckPath = workpath + '/cppcheck'