mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-11-18 03:26:17 +00:00
Update AppImage
This commit is contained in:
@@ -950,31 +950,37 @@ def get_pcie_link_speed(disk_name):
|
||||
import re
|
||||
match = re.match(r'(nvme\d+)n\d+', disk_name)
|
||||
if not match:
|
||||
print(f"[v0] Could not extract controller from {disk_name}")
|
||||
# print(f"[v0] Could not extract controller from {disk_name}")
|
||||
pass
|
||||
return pcie_info
|
||||
|
||||
controller = match.group(1) # nvme0n1 -> nvme0
|
||||
print(f"[v0] Getting PCIe info for {disk_name}, controller: {controller}")
|
||||
# print(f"[v0] Getting PCIe info for {disk_name}, controller: {controller}")
|
||||
pass
|
||||
|
||||
# Path to PCIe device in sysfs
|
||||
sys_path = f'/sys/class/nvme/{controller}/device'
|
||||
|
||||
print(f"[v0] Checking sys_path: {sys_path}, exists: {os.path.exists(sys_path)}")
|
||||
# print(f"[v0] Checking sys_path: {sys_path}, exists: {os.path.exists(sys_path)}")
|
||||
pass
|
||||
|
||||
if os.path.exists(sys_path):
|
||||
try:
|
||||
pci_address = os.path.basename(os.readlink(sys_path))
|
||||
print(f"[v0] PCI address for {disk_name}: {pci_address}")
|
||||
# print(f"[v0] PCI address for {disk_name}: {pci_address}")
|
||||
pass
|
||||
|
||||
# Use lspci to get detailed PCIe information
|
||||
result = subprocess.run(['lspci', '-vvv', '-s', pci_address],
|
||||
capture_output=True, text=True, timeout=5)
|
||||
if result.returncode == 0:
|
||||
print(f"[v0] lspci output for {pci_address}:")
|
||||
# print(f"[v0] lspci output for {pci_address}:")
|
||||
pass
|
||||
for line in result.stdout.split('\n'):
|
||||
# Look for "LnkSta:" line which shows current link status
|
||||
if 'LnkSta:' in line:
|
||||
print(f"[v0] Found LnkSta: {line}")
|
||||
# print(f"[v0] Found LnkSta: {line}")
|
||||
pass
|
||||
# Example: "LnkSta: Speed 8GT/s, Width x4"
|
||||
if 'Speed' in line:
|
||||
speed_match = re.search(r'Speed\s+([\d.]+)GT/s', line)
|
||||
@@ -990,17 +996,20 @@ def get_pcie_link_speed(disk_name):
|
||||
pcie_info['pcie_gen'] = '4.0'
|
||||
else:
|
||||
pcie_info['pcie_gen'] = '5.0'
|
||||
print(f"[v0] Current PCIe gen: {pcie_info['pcie_gen']}")
|
||||
# print(f"[v0] Current PCIe gen: {pcie_info['pcie_gen']}")
|
||||
pass
|
||||
|
||||
if 'Width' in line:
|
||||
width_match = re.search(r'Width\s+x(\d+)', line)
|
||||
if width_match:
|
||||
pcie_info['pcie_width'] = f'x{width_match.group(1)}'
|
||||
print(f"[v0] Current PCIe width: {pcie_info['pcie_width']}")
|
||||
# print(f"[v0] Current PCIe width: {pcie_info['pcie_width']}")
|
||||
pass
|
||||
|
||||
# Look for "LnkCap:" line which shows maximum capabilities
|
||||
elif 'LnkCap:' in line:
|
||||
print(f"[v0] Found LnkCap: {line}")
|
||||
# print(f"[v0] Found LnkCap: {line}")
|
||||
pass
|
||||
if 'Speed' in line:
|
||||
speed_match = re.search(r'Speed\s+([\d.]+)GT/s', line)
|
||||
if speed_match:
|
||||
@@ -1015,39 +1024,48 @@ def get_pcie_link_speed(disk_name):
|
||||
pcie_info['pcie_max_gen'] = '4.0'
|
||||
else:
|
||||
pcie_info['pcie_max_gen'] = '5.0'
|
||||
print(f"[v0] Max PCIe gen: {pcie_info['pcie_max_gen']}")
|
||||
# print(f"[v0] Max PCIe gen: {pcie_info['pcie_max_gen']}")
|
||||
pass
|
||||
|
||||
if 'Width' in line:
|
||||
width_match = re.search(r'Width\s+x(\d+)', line)
|
||||
if width_match:
|
||||
pcie_info['pcie_max_width'] = f'x{width_match.group(1)}'
|
||||
print(f"[v0] Max PCIe width: {pcie_info['pcie_max_width']}")
|
||||
# print(f"[v0] Max PCIe width: {pcie_info['pcie_max_width']}")
|
||||
pass
|
||||
else:
|
||||
print(f"[v0] lspci failed with return code: {result.returncode}")
|
||||
# print(f"[v0] lspci failed with return code: {result.returncode}")
|
||||
pass
|
||||
except Exception as e:
|
||||
print(f"[v0] Error getting PCIe info via lspci: {e}")
|
||||
# print(f"[v0] Error getting PCIe info via lspci: {e}")
|
||||
pass
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
else:
|
||||
print(f"[v0] sys_path does not exist: {sys_path}")
|
||||
# print(f"[v0] sys_path does not exist: {sys_path}")
|
||||
pass
|
||||
alt_sys_path = f'/sys/block/{disk_name}/device/device'
|
||||
print(f"[v0] Trying alternative path: {alt_sys_path}, exists: {os.path.exists(alt_sys_path)}")
|
||||
# print(f"[v0] Trying alternative path: {alt_sys_path}, exists: {os.path.exists(alt_sys_path)}")
|
||||
pass
|
||||
|
||||
if os.path.exists(alt_sys_path):
|
||||
try:
|
||||
# Get PCI address from the alternative path
|
||||
pci_address = os.path.basename(os.readlink(alt_sys_path))
|
||||
print(f"[v0] PCI address from alt path for {disk_name}: {pci_address}")
|
||||
# print(f"[v0] PCI address from alt path for {disk_name}: {pci_address}")
|
||||
pass
|
||||
|
||||
# Use lspci to get detailed PCIe information
|
||||
result = subprocess.run(['lspci', '-vvv', '-s', pci_address],
|
||||
capture_output=True, text=True, timeout=5)
|
||||
if result.returncode == 0:
|
||||
print(f"[v0] lspci output for {pci_address} (from alt path):")
|
||||
# print(f"[v0] lspci output for {pci_address} (from alt path):")
|
||||
pass
|
||||
for line in result.stdout.split('\n'):
|
||||
# Look for "LnkSta:" line which shows current link status
|
||||
if 'LnkSta:' in line:
|
||||
print(f"[v0] Found LnkSta: {line}")
|
||||
# print(f"[v0] Found LnkSta: {line}")
|
||||
pass
|
||||
if 'Speed' in line:
|
||||
speed_match = re.search(r'Speed\s+([\d.]+)GT/s', line)
|
||||
if speed_match:
|
||||
@@ -1062,17 +1080,20 @@ def get_pcie_link_speed(disk_name):
|
||||
pcie_info['pcie_gen'] = '4.0'
|
||||
else:
|
||||
pcie_info['pcie_gen'] = '5.0'
|
||||
print(f"[v0] Current PCIe gen: {pcie_info['pcie_gen']}")
|
||||
# print(f"[v0] Current PCIe gen: {pcie_info['pcie_gen']}")
|
||||
pass
|
||||
|
||||
if 'Width' in line:
|
||||
width_match = re.search(r'Width\s+x(\d+)', line)
|
||||
if width_match:
|
||||
pcie_info['pcie_width'] = f'x{width_match.group(1)}'
|
||||
print(f"[v0] Current PCIe width: {pcie_info['pcie_width']}")
|
||||
# print(f"[v0] Current PCIe width: {pcie_info['pcie_width']}")
|
||||
pass
|
||||
|
||||
# Look for "LnkCap:" line which shows maximum capabilities
|
||||
elif 'LnkCap:' in line:
|
||||
print(f"[v0] Found LnkCap: {line}")
|
||||
# print(f"[v0] Found LnkCap: {line}")
|
||||
pass
|
||||
if 'Speed' in line:
|
||||
speed_match = re.search(r'Speed\s+([\d.]+)GT/s', line)
|
||||
if speed_match:
|
||||
@@ -1087,26 +1108,32 @@ def get_pcie_link_speed(disk_name):
|
||||
pcie_info['pcie_max_gen'] = '4.0'
|
||||
else:
|
||||
pcie_info['pcie_max_gen'] = '5.0'
|
||||
print(f"[v0] Max PCIe gen: {pcie_info['pcie_max_gen']}")
|
||||
# print(f"[v0] Max PCIe gen: {pcie_info['pcie_max_gen']}")
|
||||
pass
|
||||
|
||||
if 'Width' in line:
|
||||
width_match = re.search(r'Width\s+x(\d+)', line)
|
||||
if width_match:
|
||||
pcie_info['pcie_max_width'] = f'x{width_match.group(1)}'
|
||||
print(f"[v0] Max PCIe width: {pcie_info['pcie_max_width']}")
|
||||
# print(f"[v0] Max PCIe width: {pcie_info['pcie_max_width']}")
|
||||
pass
|
||||
else:
|
||||
print(f"[v0] lspci failed with return code: {result.returncode}")
|
||||
# print(f"[v0] lspci failed with return code: {result.returncode}")
|
||||
pass
|
||||
except Exception as e:
|
||||
print(f"[v0] Error getting PCIe info from alt path: {e}")
|
||||
# print(f"[v0] Error getting PCIe info from alt path: {e}")
|
||||
pass
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
except Exception as e:
|
||||
print(f"[v0] Error in get_pcie_link_speed for {disk_name}: {e}")
|
||||
# print(f"[v0] Error in get_pcie_link_speed for {disk_name}: {e}")
|
||||
pass
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
print(f"[v0] Final PCIe info for {disk_name}: {pcie_info}")
|
||||
# print(f"[v0] Final PCIe info for {disk_name}: {pcie_info}")
|
||||
pass
|
||||
return pcie_info
|
||||
|
||||
# get_pcie_link_speed function definition ends here
|
||||
|
||||
Reference in New Issue
Block a user