mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-12-15 00:26:23 +00:00
Update flask_server.py
This commit is contained in:
@@ -2619,28 +2619,29 @@ def identify_temperature_sensor(sensor_name, adapter):
|
|||||||
return sensor_name
|
return sensor_name
|
||||||
|
|
||||||
|
|
||||||
def identify_fan(sensor_name, adapter):
|
def identify_fan(sensor_name, adapter, chip_name=None):
|
||||||
"""Identify what a fan sensor corresponds to, using hardware_monitor for GPU detection"""
|
"""Identify what a fan sensor corresponds to, using hardware_monitor for GPU detection"""
|
||||||
sensor_lower = sensor_name.lower()
|
sensor_lower = sensor_name.lower()
|
||||||
adapter_lower = adapter.lower() if adapter else ""
|
adapter_lower = adapter.lower() if adapter else ""
|
||||||
|
chip_lower = chip_name.lower() if chip_name else "" # <CHANGE> Add chip name
|
||||||
# GPU fans - Detect by driver name in adapter
|
|
||||||
if "pci adapter" in adapter_lower or any(gpu_driver in adapter_lower for gpu_driver in ["nouveau", "amdgpu", "radeon", "i915"]):
|
# GPU fans - Check both adapter and chip name for GPU drivers
|
||||||
|
if "pci adapter" in adapter_lower or "pci adapter" in chip_lower or any(gpu_driver in adapter_lower + chip_lower for gpu_driver in ["nouveau", "amdgpu", "radeon", "i915"]):
|
||||||
gpu_vendor = None
|
gpu_vendor = None
|
||||||
|
|
||||||
# Determine GPU vendor from driver
|
# Determine GPU vendor from driver
|
||||||
if "nouveau" in adapter_lower:
|
if "nouveau" in adapter_lower or "nouveau" in chip_lower:
|
||||||
gpu_vendor = "NVIDIA"
|
gpu_vendor = "NVIDIA"
|
||||||
elif "amdgpu" in adapter_lower or "radeon" in adapter_lower:
|
elif "amdgpu" in adapter_lower or "amdgpu" in chip_lower or "radeon" in adapter_lower or "radeon" in chip_lower:
|
||||||
gpu_vendor = "AMD"
|
gpu_vendor = "AMD"
|
||||||
elif "i915" in adapter_lower:
|
elif "i915" in adapter_lower or "i915" in chip_lower:
|
||||||
gpu_vendor = "Intel"
|
gpu_vendor = "Intel"
|
||||||
|
|
||||||
# Try to get detailed GPU name from lspci if possible
|
# Try to get detailed GPU name from lspci if possible
|
||||||
if gpu_vendor:
|
if gpu_vendor:
|
||||||
# Extract PCI address from adapter string
|
# Extract PCI address from adapter string
|
||||||
# Example: "nouveau-pci-0200" -> "02:00.0"
|
# Example: "nouveau-pci-0200" -> "02:00.0"
|
||||||
pci_match = re.search(r'pci-([0-9a-f]{4})', adapter_lower)
|
pci_match = re.search(r'pci-([0-9a-f]{4})', adapter_lower + " " + chip_lower)
|
||||||
|
|
||||||
if pci_match:
|
if pci_match:
|
||||||
pci_code = pci_match.group(1)
|
pci_code = pci_match.group(1)
|
||||||
@@ -4543,6 +4544,7 @@ def get_hardware_info():
|
|||||||
result = subprocess.run(['sensors'], capture_output=True, text=True, timeout=5)
|
result = subprocess.run(['sensors'], capture_output=True, text=True, timeout=5)
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
current_adapter = None
|
current_adapter = None
|
||||||
|
current_chip = None # <CHANGE> Add chip name tracking
|
||||||
fans = []
|
fans = []
|
||||||
|
|
||||||
for line in result.stdout.split('\n'):
|
for line in result.stdout.split('\n'):
|
||||||
@@ -4550,6 +4552,12 @@ def get_hardware_info():
|
|||||||
if not line:
|
if not line:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# <CHANGE> Detect chip name (e.g., "nouveau-pci-0200")
|
||||||
|
# Chip names don't have ":" and are not indented
|
||||||
|
if not ':' in line and not line.startswith(' ') and not line.startswith('Adapter'):
|
||||||
|
current_chip = line
|
||||||
|
continue
|
||||||
|
|
||||||
# Detect adapter line
|
# Detect adapter line
|
||||||
if line.startswith('Adapter:'):
|
if line.startswith('Adapter:'):
|
||||||
current_adapter = line.replace('Adapter:', '').strip()
|
current_adapter = line.replace('Adapter:', '').strip()
|
||||||
@@ -4567,9 +4575,7 @@ def get_hardware_info():
|
|||||||
if rpm_match:
|
if rpm_match:
|
||||||
fan_speed = int(float(rpm_match.group(1)))
|
fan_speed = int(float(rpm_match.group(1)))
|
||||||
|
|
||||||
# Placeholder for identify_fan - needs implementation
|
identified_name = identify_fan(sensor_name, current_adapter, current_chip)
|
||||||
# identified_name = identify_fan(sensor_name, current_adapter)
|
|
||||||
identified_name = identify_fan(sensor_name, current_adapter)
|
|
||||||
|
|
||||||
fans.append({
|
fans.append({
|
||||||
'name': identified_name,
|
'name': identified_name,
|
||||||
|
|||||||
Reference in New Issue
Block a user