diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py index 95628e7a9..53ceb13f9 100755 --- a/tools/donate-cpu.py +++ b/tools/donate-cpu.py @@ -17,6 +17,7 @@ # --max-packages=N Process N packages and then exit. A value of 0 means infinitely. # --no-upload Do not upload anything. Defaults to False. # --packages Process a list of given packages. +# --version Returns the version (of the underlying donate_cpu_lib.py). # # What this script does: # 1. Check requirements @@ -30,6 +31,8 @@ # Quick start: just run this script without any arguments import platform + +from distutils.version import StrictVersion from donate_cpu_lib import * max_packages = None @@ -86,6 +89,9 @@ for arg in sys.argv[1:]: max_packages = None elif arg.startswith('--no-upload'): do_upload = False + elif arg == '--version': + print(get_client_version()) + sys.exit(0) elif arg == '--help': print('Donate CPU to Cppcheck project') print('') @@ -100,6 +106,8 @@ for arg in sys.argv[1:]: print(' --bandwidth-limit=2m => max. 2 megabytes per second') print(' --max-packages=N Process N packages and then exit. A value of 0 means infinitely.') print(' --no-upload Do not upload anything. Defaults to False.') + print(' --packages Process a list of given packages.') + print(' --version Returns the version (of the underlying donate_cpu_lib.py).') print('') print('Quick start: just run this script without any arguments') sys.exit(0) @@ -209,6 +217,7 @@ while True: head_timing_info = '' old_timing_info = '' cppcheck_head_info = '' + client_version_head = '' libraries = library_includes.get_libraries(source_path) for ver in cppcheck_versions: @@ -218,6 +227,17 @@ while True: tree_path = os.path.join(work_path, 'tree-main') cppcheck_head_info = get_cppcheck_info(tree_path) capture_callstack = True + + def get_client_version_head(): + cmd = os.path.join(tree_path, 'tools', 'donate-cpu.py') + ' ' + '--version' + p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + try: + comm = p.communicate() + return comm[1] + except: + return None + + client_version_head = get_client_version_head() c, errout, info, t, cppcheck_options, timing_info = scan_package(tree_path, source_path, jobs, libraries, capture_callstack) if c < 0: if c == -101 and 'error: could not find or open any of the paths given.' in errout: @@ -268,4 +288,6 @@ while True: upload_info(package, info_output, server_address) if not max_packages or packages_processed < max_packages: print('Sleep 5 seconds..') + if (client_version_head is not None) and (StrictVersion(client_version_head) >= StrictVersion(get_client_version())): + print("ATTENTION: A newer client version ({}) is available - please update!".format(client_version_head)) time.sleep(5) diff --git a/tools/donate_cpu_lib.py b/tools/donate_cpu_lib.py index fb2c19c86..0fe191fc2 100644 --- a/tools/donate_cpu_lib.py +++ b/tools/donate_cpu_lib.py @@ -15,7 +15,7 @@ import shlex # 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.27" +CLIENT_VERSION = "1.3.28" # Timeout for analysis with Cppcheck in seconds CPPCHECK_TIMEOUT = 30 * 60 @@ -627,6 +627,10 @@ def get_compiler_version(): return stdout.split('\n')[0] +def get_client_version(): + return CLIENT_VERSION + + my_script_name = os.path.splitext(os.path.basename(sys.argv[0]))[0] jobs = '-j1' stop_time = None