From cb4de8f3dd845c2ecf765c5c0e3f0f3ca71494a1 Mon Sep 17 00:00:00 2001 From: zengweifeng Date: Tue, 8 Sep 2020 09:43:38 +0800 Subject: [PATCH] fix the error of function check_metacpan which can only get the latest version --- advisors/check_upstream.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/advisors/check_upstream.py b/advisors/check_upstream.py index a1bf6973..cece3fc9 100755 --- a/advisors/check_upstream.py +++ b/advisors/check_upstream.py @@ -156,22 +156,25 @@ def check_metacpan(info): headers = { 'User-Agent' : 'Mozilla/5.0 (X11; Linux x86_64)' } - url = urljoin("https://fastapi.metacpan.org/release/", info["src_repo"]) + url = urljoin("https://metacpan.org/release/", info["src_repo"]) resp = requests.get(url, headers=headers) resp = resp.text tags = [] - result_json = json.loads(resp) - if result_json != {}: - if "version" not in result_json.keys(): - eprint("{repo} > ERROR FOUND".format(repo=info["src_repo"])) - sys.exit(1) - else: - tags.append(result_json["version"]) - else: + tag_list = resp.splitlines() + condition = "value=\"/release" + for index in range(len(tag_list)): + if condition in tag_list[index]: + tag = tag_list[index + 1] + index = index + 1 + if 'DEV' in tag: + continue + tag = tag.lstrip() + tag = tag.rstrip() + tags.append(tag) + if not len(tags): eprint("{repo} found unsorted on cpan.metacpan.org".format(repo=info["src_repo"])) sys.exit(1) - last_query = {} last_query["time_stamp"] = datetime.now() last_query["raw_data"] = resp -- Gitee