1 Star 0 Fork 14

baixu/wsl

forked from openEuler/wsl 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
get_sp_version.py 1.05 KB
一键复制 编辑 原始数据 按行查看 历史
Li Chaoran 提交于 2023-09-08 11:16 . support 23.09
#!/bin/env python3
# coding=utf-8
"""
This script convert version string from year.month into yearmonth.spversion(22.03sp1->2203.1)
from openeuler repo, Which is used as WSL app major version
"""
import re
import sys
import requests
from retry import retry_call
def get_sp_version(rel: str) -> str:
"""
Get the release version info from repo
And convert
"""
headers = {"Content-type": "application/json",
"User-Agent": "Python"}
resp = retry_call(requests.get, ["https://mirrors.tuna.tsinghua.edu.cn/openeuler/"], {"headers": headers, "timeout": 50})
if resp.status_code != 200:
sys.exit(1)
res = re.compile(f'openEuler-{rel}(-LTS)?(-SP([0-9]))?')
vers = re.findall(res, resp.text)
if len(vers) == 0:
return '0'
return vers[-1][2] if vers[-1][2] else '0'
if __name__ == '__main__':
if len(sys.argv) != 2:
print(f'{sys.argv[0]} <release>')
sys.exit(1)
RELEASE = sys.argv[1]
RELEASE = RELEASE.replace('.', '')
print(RELEASE + '.' + get_sp_version(sys.argv[1]))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/baixu_yewu/wsl.git
git@gitee.com:baixu_yewu/wsl.git
baixu_yewu
wsl
wsl
master

搜索帮助