@@ -326,6 +326,48 @@ def detect_total_memory_bytes():
326326 return None
327327
328328
329+ def detect_cpu_name():
330+ """Return a human-readable CPU name if available."""
331+ try:
332+ if sys.platform.startswith("linux"):
333+ with open("/proc/cpuinfo", "r", encoding="utf-8") as f:
334+ for line in f:
335+ if line.lower().startswith("model name"):
336+ _, value = line.split(":", 1)
337+ return value.strip()
338+ elif sys.platform == "darwin":
339+ try:
340+ out = subprocess.check_output(
341+ ["sysctl", "-n", "machdep.cpu.brand_string"],
342+ text=True,
343+ stderr=subprocess.DEVNULL
344+ ).strip()
345+ if out:
346+ return out
347+ except Exception:
348+ pass
349+ out = subprocess.check_output(
350+ ["sysctl", "-n", "hw.model"],
351+ text=True,
352+ stderr=subprocess.DEVNULL
353+ ).strip()
354+ if out:
355+ return out
356+ elif sys.platform.startswith("win"):
357+ out = subprocess.check_output(
358+ ["wmic", "cpu", "get", "Name"],
359+ text=True,
360+ stderr=subprocess.DEVNULL
361+ )
362+ for line in out.splitlines():
363+ line = line.strip()
364+ if line and line.lower() != "name":
365+ return line
366+ except Exception:
367+ return None
368+ return platform.processor() or None
369+
370+
329371def gather_environment():
330372 uname = platform.uname()
331373 info = {
@@ -334,8 +376,11 @@ def gather_environment():
334376 "cpu_count": os.cpu_count(),
335377 }
336378 mem_bytes = detect_total_memory_bytes()
337- if mem_bytes:
379+ if mem_bytes is not None :
338380 info["memory_bytes"] = mem_bytes
381+ cpu_name = detect_cpu_name()
382+ if cpu_name:
383+ info["cpu"] = cpu_name
339384 return {k: v for k, v in info.items() if v is not None}
340385
341386
0 commit comments