diff options
Diffstat (limited to 'sources/pyside6/tests/registry/scrape_testresults.py')
-rw-r--r-- | sources/pyside6/tests/registry/scrape_testresults.py | 61 |
1 files changed, 19 insertions, 42 deletions
diff --git a/sources/pyside6/tests/registry/scrape_testresults.py b/sources/pyside6/tests/registry/scrape_testresults.py index e0f451d10..b7b6b58aa 100644 --- a/sources/pyside6/tests/registry/scrape_testresults.py +++ b/sources/pyside6/tests/registry/scrape_testresults.py @@ -1,41 +1,5 @@ -############################################################################# -## -## Copyright (C) 2018 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of Qt for Python. -## -## $QT_BEGIN_LICENSE:LGPL$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## GNU Lesser General Public License Usage -## Alternatively, this file may be used under the terms of the GNU Lesser -## General Public License version 3 as published by the Free Software -## Foundation and appearing in the file LICENSE.LGPL3 included in the -## packaging of this file. Please review the following information to -## ensure the GNU Lesser General Public License version 3 requirements -## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 2.0 or (at your option) the GNU General -## Public license version 3 or any later version approved by the KDE Free -## Qt Foundation. The licenses are as published by the Free Software -## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -## included in the packaging of this file. Please review the following -## information to ensure the GNU General Public License requirements will -## be met: https://www.gnu.org/licenses/gpl-2.0.html and -## https://www.gnu.org/licenses/gpl-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only """ scrape_testresults.py @@ -85,6 +49,7 @@ cache_path = os.path.dirname(test_path) target_path = os.path.dirname(__file__) start_time = time.time() + def get_name(url): """ Return the last piece of an url, including trailing slash. @@ -96,14 +61,17 @@ def get_name(url): name += "/" return name + def rel_url(url): """ throw the top URL away """ return url[len(top_url):] + stop_all = False + def find_all_links(text, url, ignore=()): """ Find all links in a page. @@ -126,6 +94,7 @@ def find_all_links(text, url, ignore=()): urls = list(url + name for name in names) return urls + def read_url(url): # We intentionally let things fail, because we re-run things on failure. try: @@ -141,6 +110,7 @@ def read_url(url): else: return response + def get_timestamp(text): # agent:2018/06/29 15:02:15 global stop_all @@ -164,6 +134,7 @@ def get_timestamp(text): raise return ts + def write_data(name, text): try: ts = get_timestamp(text) @@ -195,6 +166,7 @@ def write_data(name, text): with open(fn, "w") as f: f.write(text) + def eval_data(force=False): """ Read all found files, sort them and keep the latest version. @@ -220,9 +192,10 @@ def eval_data(force=False): print("+++ generated:", name) return len(results) + def handle_suburl(idx, n, url, level): if level == 1: - print(os.getpid(), "Reading", idx+1, "of", n, rel_url(url)) + print(os.getpid(), "Reading", idx + 1, "of", n, rel_url(url)) response = read_url(url) urls = find_all_links(response.text, url) for sub_url in urls: @@ -239,7 +212,7 @@ def handle_suburl(idx, n, url, level): print(os.getpid(), test_name) response = read_url(sub_url) txt = response.text if response else '' - if "BEGIN_FILE" in txt and not "'BEGIN_FILE'" in txt: + if "BEGIN_FILE" in txt and "'BEGIN_FILE'" not in txt: # find the text, but not a traceback with that text print(os.getpid(), test_name, "FOUND!") write_data(test_name, response.text) @@ -249,7 +222,7 @@ def handle_suburl(idx, n, url, level): def handle_suburl_tup(idx_n_url_level): if stop_all: - return # bad solution, but it stops fast + return # bad solution, but it stops fast idx, n, url, level = idx_n_url_level try: ret = handle_suburl(idx, n, url, level) @@ -257,6 +230,7 @@ def handle_suburl_tup(idx_n_url_level): except requests.exceptions.RequestException as e: return url, e + def handle_batch(urls, level): n = len(urls) args = ((idx, n, url, level) for (idx, url) in enumerate(urls)) @@ -279,6 +253,7 @@ def handle_batch(urls, level): print("Runs:", ", ".join(map(str, runs))) return not urls + def handle_topurl(url): """ Find all links to directories. @@ -313,6 +288,7 @@ def handle_topurl(url): json.dump(urls, fp, sort_keys=True, indent=4) return success + def get_test_results(starturl): ok = handle_topurl(starturl) stop_time = time.time() @@ -320,7 +296,7 @@ def get_test_results(starturl): hours, remainder = divmod(runtime, 3600) minutes, seconds = divmod(remainder, 60) - runtime_formatted = '%d:%02d:%06.3f' % (hours, minutes, seconds) + runtime_formatted = f'{hours}:{minutes:%02d}:{seconds:%06.3f}' print(f"Run time: {runtime_formatted}s") if ok: found = eval_data() @@ -328,6 +304,7 @@ def get_test_results(starturl): if found: print("Please check if a git push is necessary.") + if __name__ == "__main__": parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, |