python3-openEuler 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of python3-openEuler might be problematic. Click here for more details.

@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 redrose2100
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,31 @@
1
+ Metadata-Version: 2.1
2
+ Name: python3-openEuler
3
+ Version: 0.0.1
4
+ Summary: used to get and deal information about openEuler os
5
+ Home-page: https://gitee.com/devops_dev/openEuler
6
+ Author: redrose2100
7
+ Author-email: hitredrose@163.com
8
+ Maintainer: redrose2100
9
+ Maintainer-email: hitredrose@163.com
10
+ License: MIT
11
+ Project-URL: Documentation, https://gitee.com/devops_dev/openEuler/README.md
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: System :: Logging
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.3
18
+ Classifier: Programming Language :: Python :: 3.4
19
+ Classifier: Programming Language :: Python :: 3.5
20
+ Classifier: Programming Language :: Python :: 3.6
21
+ Classifier: Programming Language :: Python :: 3.7
22
+ Classifier: Programming Language :: Python :: 3.8
23
+ Classifier: Programming Language :: Python :: 3.9
24
+ Classifier: Programming Language :: Python :: 3.10
25
+ Classifier: Programming Language :: Python :: 3.11
26
+ Classifier: Programming Language :: Python :: 3.12
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: python3-log
30
+
31
+ # python3-openEuler
@@ -0,0 +1 @@
1
+ # python3-openEuler
@@ -0,0 +1 @@
1
+ from openEuler.openEuler import OpenEuler
@@ -0,0 +1,85 @@
1
+ import requests
2
+ from bs4 import BeautifulSoup
3
+ from log import log
4
+ from typing import Generator, Optional
5
+
6
+ class OpenEuler():
7
+ def __init__(self):
8
+ pass
9
+
10
+ def get_openEuler_everything_pkgs(
11
+ self, os_version: str, os_arch: str
12
+ ) -> Generator[str, None, None]:
13
+ """
14
+ 从 openEuler everything 源页面获取指定版本、架构的所有软件包列表,以迭代方式返回。
15
+
16
+ Args:
17
+ os_version: openEuler 版本号(如 "24.03-LTS-SP2")
18
+ os_arch: 系统架构(如 "x86_64", "aarch64")
19
+
20
+ Yields:
21
+ str: 软件包名称(如 "a2ps-4.14-36.oe2403.x86_64.rpm")
22
+
23
+ Raises:
24
+ requests.exceptions.RequestException: 网络请求失败(如超时、404、500 等)
25
+ ValueError: 页面解析失败(未找到任何 .rpm 包)
26
+ """
27
+ # 基础 URL 模板(openEuler everything 源固定路径)
28
+ base_url_template = "https://dl-cdn.openeuler.openatom.cn/openEuler-{os_version}/everything/{os_arch}/Packages/"
29
+ # 请求超时时间(避免长期阻塞)
30
+ timeout = 15
31
+ # 请求头(模拟浏览器,避免部分服务器拦截)
32
+ headers = {
33
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
34
+ }
35
+ # 1. 构造目标页面 URL
36
+ target_url = base_url_template.format(
37
+ os_version=os_version, os_arch=os_arch
38
+ )
39
+ try:
40
+ # 2. 发送 GET 请求获取页面内容(允许重定向,部分 CDN 可能跳转)
41
+ response = requests.get(
42
+ url=target_url,
43
+ headers=headers,
44
+ timeout=timeout,
45
+ allow_redirects=True
46
+ )
47
+ # 检查响应状态码(非 200 视为请求失败)
48
+ response.raise_for_status()
49
+ html_content = response.text
50
+
51
+ except requests.exceptions.RequestException as e:
52
+ raise RuntimeError(
53
+ f"获取页面失败!URL: {target_url}, 错误: {str(e)}"
54
+ ) from e
55
+
56
+ # 3. 解析 HTML 提取 .rpm 包链接
57
+ soup = BeautifulSoup(html_content, "html.parser") # 使用标准 HTML 解析器(无需额外依赖)
58
+ # 页面中软件包以 <a> 标签存在,href 属性为包名,且文本与 href 一致
59
+ pkg_links = soup.find_all("a", href=lambda href: href and href.endswith(".rpm"))
60
+
61
+ if not pkg_links:
62
+ raise ValueError(
63
+ f"页面解析失败!URL: {target_url}, 未找到任何 .rpm 格式的软件包"
64
+ )
65
+
66
+ # 4. 迭代返回软件包名称(通过 yield 实现生成器)
67
+ for link in pkg_links:
68
+ pkg_name = link.get("href") # 从 href 属性获取包名(避免文本空格问题)
69
+ if pkg_name: # 双重校验(防止空链接)
70
+ yield pkg_name
71
+
72
+ if __name__ == "__main__":
73
+ # 初始化获取器
74
+ oe = OpenEuler()
75
+ # 示例:获取 openEuler 24.03-LTS-SP2 x86_64 架构的所有包(迭代打印前 10 个)
76
+ pkg_generator = oe.get_openEuler_everything_pkgs(
77
+ os_version="24.03-LTS-SP2",
78
+ os_arch="x86_64"
79
+ )
80
+ count=0
81
+ for pkg in pkg_generator:
82
+ count+=1
83
+ print(pkg)
84
+ print("共获取到 %d 个软件包" % count)
85
+
@@ -0,0 +1,31 @@
1
+ Metadata-Version: 2.1
2
+ Name: python3-openEuler
3
+ Version: 0.0.1
4
+ Summary: used to get and deal information about openEuler os
5
+ Home-page: https://gitee.com/devops_dev/openEuler
6
+ Author: redrose2100
7
+ Author-email: hitredrose@163.com
8
+ Maintainer: redrose2100
9
+ Maintainer-email: hitredrose@163.com
10
+ License: MIT
11
+ Project-URL: Documentation, https://gitee.com/devops_dev/openEuler/README.md
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: System :: Logging
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.3
18
+ Classifier: Programming Language :: Python :: 3.4
19
+ Classifier: Programming Language :: Python :: 3.5
20
+ Classifier: Programming Language :: Python :: 3.6
21
+ Classifier: Programming Language :: Python :: 3.7
22
+ Classifier: Programming Language :: Python :: 3.8
23
+ Classifier: Programming Language :: Python :: 3.9
24
+ Classifier: Programming Language :: Python :: 3.10
25
+ Classifier: Programming Language :: Python :: 3.11
26
+ Classifier: Programming Language :: Python :: 3.12
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: python3-log
30
+
31
+ # python3-openEuler
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ openEuler/__init__.py
5
+ openEuler/openEuler.py
6
+ python3_openEuler.egg-info/PKG-INFO
7
+ python3_openEuler.egg-info/SOURCES.txt
8
+ python3_openEuler.egg-info/dependency_links.txt
9
+ python3_openEuler.egg-info/requires.txt
10
+ python3_openEuler.egg-info/top_level.txt
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,53 @@
1
+ import platform
2
+ from setuptools import setup, find_packages
3
+
4
+
5
+ try:
6
+ with open("README.md",encoding="utf-8",mode="r") as f:
7
+ long_desc=f.read()
8
+ except:
9
+ long_desc=""
10
+
11
+ setup(
12
+ name="python3-openEuler",
13
+ version="0.0.1",
14
+ description="used to get and deal information about openEuler os",
15
+ long_description=long_desc,
16
+ long_description_content_type="text/markdown",
17
+ author="redrose2100",
18
+ author_email="hitredrose@163.com",
19
+ maintainer="redrose2100",
20
+ maintainer_email="hitredrose@163.com",
21
+ url="https://gitee.com/devops_dev/openEuler",
22
+ project_urls={
23
+ "Documentation": "https://gitee.com/devops_dev/openEuler/README.md"
24
+ },
25
+ license="MIT",
26
+ install_requires =[
27
+ "python3-log"
28
+ ],
29
+ include_package_data=True,
30
+ packages=find_packages(),
31
+ entry_points={
32
+ 'console_scripts': [
33
+ ],
34
+ },
35
+ data_files=[],
36
+ classifiers=[
37
+ 'Development Status :: 4 - Beta',
38
+ 'Intended Audience :: Developers',
39
+ 'Topic :: System :: Logging',
40
+ 'License :: OSI Approved :: MIT License',
41
+ 'Programming Language :: Python :: 3',
42
+ 'Programming Language :: Python :: 3.3',
43
+ 'Programming Language :: Python :: 3.4',
44
+ 'Programming Language :: Python :: 3.5',
45
+ 'Programming Language :: Python :: 3.6',
46
+ 'Programming Language :: Python :: 3.7',
47
+ 'Programming Language :: Python :: 3.8',
48
+ 'Programming Language :: Python :: 3.9',
49
+ 'Programming Language :: Python :: 3.10',
50
+ 'Programming Language :: Python :: 3.11',
51
+ 'Programming Language :: Python :: 3.12'
52
+ ]
53
+ )