From dfaba302907183685171a61d965ebda6b0a6f9d8 Mon Sep 17 00:00:00 2001 From: versat Date: Sat, 19 Jan 2019 12:45:08 +0100 Subject: [PATCH] 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. --- tools/donate-cpu.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py index 34d22c3ce..1a3ea7835 100644 --- a/tools/donate-cpu.py +++ b/tools/donate-cpu.py @@ -374,11 +374,12 @@ for arg in sys.argv[1:]: print('Thank you!') if not checkRequirements(): sys.exit(1) -if subprocess.call(['wget', '--limit-rate=' + bandwidth_limit, '-q', '--spider', 'cppcheck.osuosl.org']) is 2: - print('Error: Bandwidth limit value "' + bandwidth_limit + '" is invalid.') - sys.exit(1) -else: - print('Bandwidth-limit: ' + bandwidth_limit) +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.') + sys.exit(1) + else: + print('Bandwidth-limit: ' + bandwidth_limit) if not os.path.exists(workpath): os.mkdir(workpath) cppcheckPath = workpath + '/cppcheck'