Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump cryptography from 41.0.7 to 42.0.4 in /backend in the pip group across 1 directory #6

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.3.0
colorama==0.4.6; sys_platform == "win32" or platform_system == "Windows"
cryptography==41.0.7
cryptography==42.0.4
distlib==0.3.8
dnspython==2.6.1
ecdsa==0.18.0
Expand Down
27 changes: 22 additions & 5 deletions backend/utils/server_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,28 @@ def get_cpu_info() -> dict:
"""获取 CPU 信息"""
cpu_info = {'usage': round(psutil.cpu_percent(interval=1, percpu=False), 2)} # %

# CPU 频率信息,最大、最小和当前频率
cpu_freq = psutil.cpu_freq()
cpu_info['max_freq'] = round(cpu_freq.max, 2) # MHz
cpu_info['min_freq'] = round(cpu_freq.min, 2) # MHz
cpu_info['current_freq'] = round(cpu_freq.current, 2) # MHz
# 检查是否是 Apple M系列芯片
if platform.system() == "Darwin" and "arm" in platform.machine().lower():
cpu_info['max_freq'] = 0
cpu_info['min_freq'] = 0
cpu_info['current_freq'] = 0
else:
try:
# CPU 频率信息,最大、最小和当前频率
cpu_freq = psutil.cpu_freq()
cpu_info['max_freq'] = round(cpu_freq.max, 2) # MHz
cpu_info['min_freq'] = round(cpu_freq.min, 2) # MHz
cpu_info['current_freq'] = round(cpu_freq.current, 2) # MHz
except FileNotFoundError:
# 处理无法获取频率的情况
cpu_info['max_freq'] = 0
cpu_info['min_freq'] = 0
cpu_info['current_freq'] = 0
except AttributeError:
# 处理属性不存在的情况(更安全的做法)
cpu_info['max_freq'] = 0
cpu_info['min_freq'] = 0
cpu_info['current_freq'] = 0

# CPU 逻辑核心数,物理核心数
cpu_info['logical_num'] = psutil.cpu_count(logical=True)
Expand Down
Loading