mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-12-16 00:56:26 +00:00
Update flask_server.py
This commit is contained in:
@@ -1635,6 +1635,9 @@ def get_detailed_gpu_info(gpu):
|
||||
output_lines.append(line)
|
||||
output = ''.join(output_lines)
|
||||
|
||||
if len(output_lines) <= 5:
|
||||
print(f"[v0] Received line {len(output_lines)}: {line.strip()[:100]}")
|
||||
|
||||
# intel_gpu_top -J outputs: [\n{\n...\n},\n{\n...\n}\n]
|
||||
# We need to find the first complete object inside the array
|
||||
|
||||
@@ -1642,6 +1645,8 @@ def get_detailed_gpu_info(gpu):
|
||||
if '[' not in output:
|
||||
continue
|
||||
|
||||
print(f"[v0] Found array start bracket, total output length: {len(output)}")
|
||||
|
||||
# Find the start of the array
|
||||
array_start = output.index('[')
|
||||
after_array_start = output[array_start + 1:]
|
||||
@@ -1664,12 +1669,16 @@ def get_detailed_gpu_info(gpu):
|
||||
object_end = i + 1
|
||||
break
|
||||
|
||||
print(f"[v0] Object parsing: start={object_start}, end={object_end}, brace_count={brace_count}")
|
||||
|
||||
if object_start >= 0 and object_end > object_start:
|
||||
# Extract the first complete JSON object
|
||||
json_str = after_array_start[object_start:object_end]
|
||||
print(f"[v0] Extracted JSON string (first 200 chars): {json_str[:200]}")
|
||||
try:
|
||||
json_data = json.loads(json_str)
|
||||
print(f"[v0] Successfully parsed JSON object from intel_gpu_top array")
|
||||
print(f"[v0] JSON keys: {list(json_data.keys())}")
|
||||
|
||||
# Parse frequency data
|
||||
if 'frequency' in json_data:
|
||||
@@ -2730,7 +2739,8 @@ def api_info():
|
||||
|
||||
@app.route('/api/hardware', methods=['GET'])
|
||||
def api_hardware():
|
||||
"""Get comprehensive hardware information"""
|
||||
"""Get hardware information"""
|
||||
try:
|
||||
hardware_info = get_hardware_info()
|
||||
|
||||
all_fans = hardware_info.get('sensors', {}).get('fans', [])
|
||||
@@ -2741,7 +2751,8 @@ def api_hardware():
|
||||
formatted_data = {
|
||||
'cpu': hardware_info.get('cpu', {}),
|
||||
'motherboard': hardware_info.get('motherboard', {}),
|
||||
'memory_modules': hardware_data.get('memory_modules', []),
|
||||
'bios': hardware_info.get('bios', {}),
|
||||
'memory_modules': hardware_info.get('memory_modules', []),
|
||||
'storage_devices': hardware_info.get('storage_devices', []),
|
||||
'pci_devices': hardware_info.get('pci_devices', []),
|
||||
'temperatures': hardware_info.get('sensors', {}).get('temperatures', []),
|
||||
@@ -2762,6 +2773,11 @@ def api_hardware():
|
||||
print(f"[v0] - GPUs: {len(formatted_data['gpus'])} found")
|
||||
|
||||
return jsonify(formatted_data)
|
||||
except Exception as e:
|
||||
print(f"[v0] Error in api_hardware: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return jsonify({'error': str(e)}), 500
|
||||
|
||||
@app.route('/api/gpu/<slot>/realtime', methods=['GET'])
|
||||
def api_gpu_realtime(slot):
|
||||
|
||||
Reference in New Issue
Block a user