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,10 +374,11 @@ 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):
if subprocess.call(['wget', '--limit-rate=' + bandwidth_limit, '-q', '--spider', 'cppcheck.osuosl.org']) is 2:
print('Error: Bandwidth limit value "' + bandwidth_limit + '" is invalid.') print('Error: Bandwidth limit value "' + bandwidth_limit + '" is invalid.')
sys.exit(1) sys.exit(1)
else: else:
print('Bandwidth-limit: ' + bandwidth_limit) print('Bandwidth-limit: ' + bandwidth_limit)
if not os.path.exists(workpath): if not os.path.exists(workpath):
os.mkdir(workpath) os.mkdir(workpath)