diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py index 89aa45ff6..6e0cf68df 100755 --- a/tools/donate-cpu.py +++ b/tools/donate-cpu.py @@ -150,7 +150,7 @@ while True: sys.exit(1) for ver in cppcheck_versions: if ver == 'head': - if not compile(cppcheck_path, jobs): + if not compile_cppcheck(cppcheck_path, jobs): print('Failed to compile Cppcheck, retry later') sys.exit(1) elif not compile_version(work_path, jobs, ver): diff --git a/tools/donate_cpu_lib.py b/tools/donate_cpu_lib.py index ca81d4ada..a24f4073d 100644 --- a/tools/donate_cpu_lib.py +++ b/tools/donate_cpu_lib.py @@ -13,7 +13,7 @@ import tarfile # Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/ # Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic # changes) -CLIENT_VERSION = "1.1.41" +CLIENT_VERSION = "1.1.42" def check_requirements(): @@ -88,7 +88,7 @@ def compile_version(work_path, jobs, version): return True -def compile(cppcheck_path, jobs): +def compile_cppcheck(cppcheck_path, jobs): print('Compiling Cppcheck..') try: os.chdir(cppcheck_path) @@ -127,7 +127,7 @@ def get_packages_count(server_address): return packages -def get_package(server_address, package_index = None): +def get_package(server_address, package_index=None): print('Connecting to server to get assigned work..') package = b'' sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -237,12 +237,6 @@ def has_include(path, includes): else: f = open(filename, 'rt', errors='ignore') filedata = f.read() - try: - # Python2 needs to decode the data first - filedata = filedata.decode(encoding='utf-8', errors='ignore') - except AttributeError: - # Python3 directly reads the data into a string object that has no decode() - pass f.close() if re.search(re_expr, filedata, re.MULTILINE): return True @@ -291,7 +285,7 @@ def scan_package(work_path, cppcheck_path, jobs, libraries): sig_num = int(stderr[sig_start_pos:stderr.find(' ', sig_start_pos)]) print('cppcheck finished with ' + str(returncode) + ('' if sig_num == -1 else ' (signal ' + str(sig_num) + ')')) # generate stack trace for SIGSEGV, SIGABRT, SIGILL, SIGFPE, SIGBUS - if returncode in (-11,-6,-4,-8,-7) or sig_num in (11,6,4,8,7): + if returncode in (-11, -6, -4, -8, -7) or sig_num in (11, 6, 4, 8, 7): print('Crash!') stacktrace = '' if cppcheck_path == 'cppcheck': @@ -393,13 +387,13 @@ def diff_results(work_path, ver1, results1, ver2, results2): def send_all(connection, data): - bytes = data.encode('ascii', 'ignore') - while bytes: - num = connection.send(bytes) - if num < len(bytes): - bytes = bytes[num:] + bytes_ = data.encode('ascii', 'ignore') + while bytes_: + num = connection.send(bytes_) + if num < len(bytes_): + bytes_ = bytes_[num:] else: - bytes = None + bytes_ = None def upload_results(package, results, server_address): diff --git a/tools/test-my-pr.py b/tools/test-my-pr.py index 13834e4e6..3c762c315 100755 --- a/tools/test-my-pr.py +++ b/tools/test-my-pr.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Run this script from your branch with proposed Cppcheck patch to verify your # patch against current master. It will compare output of testing bunch of @@ -49,12 +50,12 @@ if __name__ == "__main__": print('Failed to switch to common ancestor of your branch and master') sys.exit(1) - if not lib.compile(master_dir, jobs): + if not lib.compile_cppcheck(master_dir, jobs): print('Failed to compile master of Cppcheck') sys.exit(1) print('Testing your PR from directory: ' + your_repo_dir) - if not lib.compile(your_repo_dir, jobs): + if not lib.compile_cppcheck(your_repo_dir, jobs): print('Failed to compile your version of Cppcheck') sys.exit(1) @@ -118,7 +119,7 @@ if __name__ == "__main__": who = 'Master' else: who = 'Your' - crashes.append(package + ' ' + who) + crashes.append(package + ' ' + who) with open(result_file, 'a') as myfile: myfile.write(package + '\n')