donate-cpu.py: added "--packages" parameter to specify a list of packages to process (#3742)

This commit is contained in:
Oliver Stöneberg 2022-02-14 12:59:38 +01:00 committed by GitHub
parent 88b3d4dd93
commit d3ba5a0829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 8 deletions

View File

@ -16,6 +16,7 @@
# --bandwidth-limit=2m => max. 2 megabytes per second # --bandwidth-limit=2m => max. 2 megabytes per second
# --max-packages=N Process N packages and then exit. A value of 0 means infinitely. # --max-packages=N Process N packages and then exit. A value of 0 means infinitely.
# --no-upload Do not upload anything. Defaults to False. # --no-upload Do not upload anything. Defaults to False.
# --packages Process a list of given packages.
# #
# What this script does: # What this script does:
# 1. Check requirements # 1. Check requirements
@ -31,6 +32,9 @@
import platform import platform
from donate_cpu_lib import * from donate_cpu_lib import *
max_packages = None
package_urls = []
for arg in sys.argv[1:]: for arg in sys.argv[1:]:
# --stop-time=12:00 => run until ~12:00 and then stop # --stop-time=12:00 => run until ~12:00 and then stop
if arg.startswith('--stop-time='): if arg.startswith('--stop-time='):
@ -44,8 +48,18 @@ for arg in sys.argv[1:]:
jobs = arg jobs = arg
print('Jobs:' + jobs[2:]) print('Jobs:' + jobs[2:])
elif arg.startswith('--package='): elif arg.startswith('--package='):
package_url = arg[arg.find('=')+1:] pkg = arg[arg.find('=')+1:]
print('Package:' + package_url) package_urls.append(pkg)
print('Added Package:' + pkg)
elif arg.startswith('--packages='):
pkg_cnt = len(package_urls)
with open(arg[arg.find('=')+1:], 'rt') as f:
for package_url in f:
package_url = package_url.strip()
if not package_url:
continue
package_urls.append(package_url)
print('Added Packages:' + str(len(package_urls) - pkg_cnt))
elif arg.startswith('--work-path='): elif arg.startswith('--work-path='):
work_path = os.path.abspath(arg[arg.find('=')+1:]) work_path = os.path.abspath(arg[arg.find('=')+1:])
print('work_path:' + work_path) print('work_path:' + work_path)
@ -110,8 +124,8 @@ if bandwidth_limit and isinstance(bandwidth_limit, str):
sys.exit(1) sys.exit(1)
else: else:
print('Bandwidth-limit: ' + bandwidth_limit) print('Bandwidth-limit: ' + bandwidth_limit)
if package_url: if package_urls:
max_packages = 1 max_packages = len(package_urls)
if max_packages: if max_packages:
print('Maximum number of packages to download and analyze: {}'.format(max_packages)) print('Maximum number of packages to download and analyze: {}'.format(max_packages))
if not os.path.exists(work_path): if not os.path.exists(work_path):
@ -169,8 +183,8 @@ while True:
if not compile_version(current_cppcheck_dir, jobs): if not compile_version(current_cppcheck_dir, jobs):
print('Failed to compile Cppcheck-{}, retry later'.format(ver)) print('Failed to compile Cppcheck-{}, retry later'.format(ver))
sys.exit(1) sys.exit(1)
if package_url: if package_urls:
package = package_url package = package_urls[packages_processed-1]
else: else:
package = get_package(server_address) package = get_package(server_address)
tgz = download_package(work_path, package, bandwidth_limit) tgz = download_package(work_path, package, bandwidth_limit)
@ -238,7 +252,7 @@ while True:
output += 'head results:\n' + results_to_diff[cppcheck_versions.index('head')] output += 'head results:\n' + results_to_diff[cppcheck_versions.index('head')]
if not crash and not timeout: if not crash and not timeout:
output += 'diff:\n' + diff_results(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: if package_urls:
print('=========================================================') print('=========================================================')
print(output) print(output)
print('=========================================================') print('=========================================================')

View File

@ -15,7 +15,7 @@ import shlex
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/ # 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 # Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
# changes) # changes)
CLIENT_VERSION = "1.3.19" CLIENT_VERSION = "1.3.20"
# Timeout for analysis with Cppcheck in seconds # Timeout for analysis with Cppcheck in seconds
CPPCHECK_TIMEOUT = 30 * 60 CPPCHECK_TIMEOUT = 30 * 60