From f8edb7b6e61f3829a652f10671f3a5e8aa3d0337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Sat, 6 Mar 2021 12:34:12 +0100 Subject: [PATCH] various daca@home client cleanups (#3161) --- tools/donate-cpu.py | 3 ++- tools/donate_cpu_lib.py | 30 +++++++++++++----------------- tools/test-my-pr.py | 2 +- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py index 9b7066084..03d6eb724 100755 --- a/tools/donate-cpu.py +++ b/tools/donate-cpu.py @@ -203,6 +203,7 @@ while True: output += 'platform: ' + platform.platform() + '\n' output += 'python: ' + platform.python_version() + '\n' output += 'client-version: ' + CLIENT_VERSION + '\n' + output += 'compiler: ' + get_compiler_version() + '\n' output += 'cppcheck: ' + ' '.join(cppcheck_versions) + '\n' output += 'head-info: ' + cppcheck_head_info + '\n' output += 'count:' + count + '\n' @@ -214,7 +215,7 @@ while True: if 'head' in cppcheck_versions: output += 'head results:\n' + results_to_diff[cppcheck_versions.index('head')] if not crash and not timeout: - output += 'diff:\n' + diff_results(work_path, cppcheck_versions[0], results_to_diff[0], cppcheck_versions[1], results_to_diff[1]) + '\n' + output += 'diff:\n' + diff_results(cppcheck_versions[0], results_to_diff[0], cppcheck_versions[1], results_to_diff[1]) + '\n' if package_url: print('=========================================================') print(output) diff --git a/tools/donate_cpu_lib.py b/tools/donate_cpu_lib.py index 50f97c1e2..ed8e9582b 100644 --- a/tools/donate_cpu_lib.py +++ b/tools/donate_cpu_lib.py @@ -16,7 +16,7 @@ import psutil # 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.3.11" +CLIENT_VERSION = "1.3.12" # Timeout for analysis with Cppcheck in seconds CPPCHECK_TIMEOUT = 30 * 60 @@ -31,7 +31,7 @@ def check_requirements(): try: subprocess.call([app, '--version']) except OSError: - print(app + ' is required') + print("Error: '{}' is required".format(app)) result = False return result @@ -224,8 +224,7 @@ def unpack_package(work_path, tgz): # Skip dangerous file names continue elif member.name.lower().endswith(('.c', '.cpp', '.cxx', '.cc', '.c++', '.h', '.hpp', - '.h++', '.hxx', '.hh', '.tpp', '.txx', '.qml', - '.sln', '.vcproj', '.vcxproj')): + '.h++', '.hxx', '.hh', '.tpp', '.txx', '.qml')): try: tf.extract(member.name) found = True @@ -296,13 +295,7 @@ def scan_package(work_path, cppcheck_path, jobs, libraries): # Reference for GNU C: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html options = libs + jobs + ' --showtime=top5 --check-library --inconclusive --enable=style,information --template=daca2 -rp=temp' - if os.path.isfile('temp/tortoisesvn/TortoiseSVN.sln'): - options = options.replace('--library=posix ', '') - options = options.replace('--library=gnu ', '') - options = '--library=windows ' + options - options += ' --platform=win64 --project=temp/tortoisesvn/TortoiseSVN.sln' - else: - options += ' -D__GNUC__ --platform=unix64 temp' + options += ' -D__GNUC__ --platform=unix64 temp' cppcheck_cmd = cppcheck_path + '/cppcheck' + ' ' + options cmd = 'nice ' + cppcheck_cmd returncode, stdout, stderr, elapsed_time = run_command(cmd) @@ -358,7 +351,7 @@ def scan_package(work_path, cppcheck_path, jobs, libraries): if cppcheck_path == 'cppcheck': # re-run within gdb to get a stacktrace cmd = 'gdb --batch --eval-command=run --eval-command="bt 50" --return-child-result --args ' + cppcheck_cmd + " -j1" - dummy, st_stdout, dummy, dummy = run_command(cmd) + _, st_stdout, _, _ = run_command(cmd) gdb_pos = st_stdout.find(" received signal") if not gdb_pos == -1: last_check_pos = st_stdout.rfind('Checking ', 0, gdb_pos) @@ -377,11 +370,9 @@ def scan_package(work_path, cppcheck_path, jobs, libraries): returncode = -100-returncode return returncode, stdout, '', returncode, options, '' - if sig_pos != -1: + if sig_num != -1: print('Error!') - pos2 = stderr.find(' [cppcheckError]', sig_pos) - signr = int(stderr[sig_pos+len(sig_msg):pos2]) - return -signr, '', '', -signr, options, '' + return -sig_num, ''.join(internal_error_messages_list), '', -sig_num, options, '' thr_pos = stderr.find('#### ThreadExecutor') if thr_pos != -1: @@ -406,7 +397,7 @@ def split_results(results): return ret -def diff_results(work_path, ver1, results1, ver2, results2): +def diff_results(ver1, results1, ver2, results2): print('Diff results..') ret = '' r1 = sorted(split_results(results1)) @@ -524,6 +515,11 @@ def get_libraries(): return libraries +def get_compiler_version(): + _, stdout, _, _ = run_command('g++ --version') + return stdout.split('\n')[0] + + my_script_name = os.path.splitext(os.path.basename(sys.argv[0]))[0] jobs = '-j1' stop_time = None diff --git a/tools/test-my-pr.py b/tools/test-my-pr.py index 0df6598bd..33924c482 100755 --- a/tools/test-my-pr.py +++ b/tools/test-my-pr.py @@ -155,7 +155,7 @@ if __name__ == "__main__": with open(result_file, 'a') as myfile: myfile.write(package + '\n') - diff = lib.diff_results(work_path, 'main', results_to_diff[0], 'your', results_to_diff[1]) + diff = lib.diff_results('main', results_to_diff[0], 'your', results_to_diff[1]) if diff != '': myfile.write('diff:\n' + diff + '\n')