代码拉取完成,页面将自动刷新
同步操作将从 mdche/release__pkgs_compares 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import requests
import ssl
import warnings
import xml.etree.ElementTree as et
from lxml import etree
from urllib.request import urlopen
def resolve_xml(cvrf: str) -> list:
"""
resolve cvrf xml to get packages info.
Args:
cvrf(str): name of the cvrf
Returns:
xml_result(list): return the package list of the cvrf
"""
warnings.filterwarnings("ignore", category=DeprecationWarning)
xml_result = []
# tree = ET.parse("/Users/mingdaoche/Downloads/updateinfo_0412/0515/2203/cvrf-openEuler-SA-2022-1681.xml")
ssl._create_default_https_context = ssl._create_unverified_context
cvrf_url = "https://repo.openeuler.org/security/data/cvrf/2022/{}".format(cvrf)
raw_xml = urlopen(cvrf_url)
tree = et.parse(raw_xml)
root = tree.getroot()
# print('root_tag', root.tag)
for branch in root.getchildren()[6].getchildren():
if branch.attrib["Name"] == "openEuler":
continue
for product in branch.getchildren():
# print(product.text)
xml_result.append(product.text)
return xml_result
def resolve_html(version_date) -> list:
"""
resovle test repo's packates
Returns:
html_result(list): package of the test repo
"""
html_result = []
base_url = "http://121.36.84.172/repo.openeuler.org/{}/{}/{}/Packages/"
version_list = ["openEuler-22.03-LTS", "openEuler-20.03-LTS-SP1", "openEuler-20.03-LTS-SP3"]
arch_list = ["aarch64", "source", "x86_64", "noarch"]
for version in version_list:
for arch in arch_list:
response = requests.get(base_url.format(version,version_date, arch))
tree = etree.HTML(response.text)
rows = tree.xpath('//table[@id="list"]/tbody/tr')[1:]
for row in rows:
package_name = row.xpath('./td/a/text()')
# print(package_name)
html_result.append(package_name[0])
return html_result
def compare_packages(xml_result: list, html_result: list):
"""
Compare xml packages version with html packages
Args:
xml_result(list):
html_result(list):
Returns:
"""
return all([xml_pkg in html_result for xml_pkg in xml_result])
def traversal_check_updated_cvrf(version_date):
"""
check updated cvrfs' packages with the test repo
Returns:
bool: The result of the comparasion.
"""
html_result = resolve_html(version_date)
with open("updated_index.txt", 'r', encoding='utf-8') as file:
for line in file.readlines():
xml_name = line.replace("\n", "")
if compare_packages(resolve_xml(line), html_result):
print("cvrf {} packages comparision result is: Pass.".format(xml_name))
else:
print("cvrf {} packages comparision result is: Failed.".format(xml_name))
if __name__ == "__main__":
# print(resolve_html())
# print(resolve_xml("cvrf-openEuler-SA-2022-1683.xml"))
# print(compare_packages(resolve_xml("cvrf-openEuler-SA-2022-1683.xml"), resolve_html()))
traversal_check_updated_cvrf("update_20220529")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。