MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / _resolve_bind_address

Function _resolve_bind_address

webapp_modern.py:19730–19758  ·  view source on GitHub ↗

Resolve a network interface name (e.g. 'wlan0') to its IPv4 address. Returns '0.0.0.0' if the interface has no IP or doesn't exist.

(interface_name: str)

Source from the content-addressed store, hash-verified

19728
19729 # Process Information
19730 processes = []
19731 for proc in psutil.process_iter(['pid', 'name', 'cpu_percent', 'memory_percent']):
19732 try:
19733 pinfo = proc.info
19734 processes.append({
19735 'pid': pinfo['pid'],
19736 'name': pinfo['name'],
19737 'cpu_percent': pinfo['cpu_percent'],
19738 'memory_percent': pinfo['memory_percent']
19739 })
19740 except (psutil.NoSuchProcess, psutil.AccessDenied):
19741 pass
19742
19743 # Sort processes by CPU usage
19744 processes.sort(key=lambda x: x['cpu_percent'] or 0, reverse=True)
19745 processes = processes[:10] # Top 10 processes
19746
19747 # Temperature (if available)
19748 try:
19749 if hasattr(psutil, 'sensors_temperatures'):
19750 temps_func = getattr(psutil, 'sensors_temperatures')
19751 temps = temps_func()
19752 temperature_data = {}
19753 for name, entries in temps.items():
19754 for entry in entries:
19755 temperature_data[f"{name}_{entry.label}"] = entry.current
19756 else:
19757 temperature_data = {}
19758 except:
19759 temperature_data = {}
19760
19761 # Battery (PiSugar UPS - only if connected)

Callers 1

run_serverFunction · 0.85

Calls 3

warningMethod · 0.80
getMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected