winpulse 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
winpulse-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: winpulse
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Cross-platform light system metric telemetry engine
|
|
5
|
+
Author: Mayank170906
|
|
6
|
+
Author-email: Mayank170906 <mayankchoudharysept17@gmail.com>
|
|
7
|
+
Requires-Python: >=3.8
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
winpulse-0.1.0/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "winpulse"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Cross-platform light system metric telemetry engine"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Mayank170906", email = "mayankchoudharysept17@gmail.com" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.8"
|
|
10
|
+
dependencies = []
|
|
11
|
+
|
|
12
|
+
[build-system]
|
|
13
|
+
requires = ["uv_build>=0.8.14,<0.9.0"]
|
|
14
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
import platform
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
class WinPulse:
|
|
7
|
+
def __init__(self):
|
|
8
|
+
# 1. Immediate Static Meta Data (Instant execution via Python standard library)
|
|
9
|
+
self.os_name = platform.system() # Windows, Linux, Darwin
|
|
10
|
+
self.architecture = platform.machine() # AMD64, x86_64, arm64
|
|
11
|
+
self.logical_cores = os.cpu_count() or 1 # Always reports 12 on your Ryzen 5 5600H
|
|
12
|
+
|
|
13
|
+
def get_all_system_details(self):
|
|
14
|
+
"""
|
|
15
|
+
Fires exactly ONE fast native shell command per OS to fetch all remaining dynamic metrics
|
|
16
|
+
such as true physical cores, company name, CPU usage, and total/available RAM.
|
|
17
|
+
"""
|
|
18
|
+
try:
|
|
19
|
+
if self.os_name == "Windows":
|
|
20
|
+
# Single-line PowerShell pipeline outputting structured JSON
|
|
21
|
+
cmd = ("powershell -Command \""
|
|
22
|
+
"$cpu = Get-CimInstance Win32_Processor; "
|
|
23
|
+
"$osInfo = Get-CimInstance Win32_OperatingSystem; "
|
|
24
|
+
"$cpuUsage = (Get-CimInstance Win32_Processor | Measure-Object -Property LoadPercentage -Average).Average; "
|
|
25
|
+
"$totalRam = $osInfo.TotalVisibleMemorySize * 1024; "
|
|
26
|
+
"$freeRam = $osInfo.FreePhysicalMemory * 1024; "
|
|
27
|
+
"@{cpu_company_name=$cpu.Name.Trim(); "
|
|
28
|
+
"physical_cores=$cpu.NumberOfCores; "
|
|
29
|
+
"cpu_percentage_use=[math]::Round($cpuUsage, 1); "
|
|
30
|
+
"ram_total_gb=[math]::Round($totalRam / 1GB, 1); "
|
|
31
|
+
"ram_available_gb=[math]::Round($freeRam / 1GB, 1)} "
|
|
32
|
+
"| ConvertTo-Json\"")
|
|
33
|
+
|
|
34
|
+
# Execute and parse JSON directly inside the Windows block
|
|
35
|
+
raw_output = subprocess.check_output(cmd, shell=True).decode().strip()
|
|
36
|
+
dynamic_data = json.loads(raw_output)
|
|
37
|
+
|
|
38
|
+
elif self.os_name == "Linux":
|
|
39
|
+
# Safe Linux flat token execution separated by pipes
|
|
40
|
+
cmd = ("echo \"$(lscpu | grep 'Model name:' | cut -d: -f2 | xargs)|"
|
|
41
|
+
"$(lscpu | grep 'Core(s) per socket:' | awk '{print $4}')|"
|
|
42
|
+
"$(vmstat 1 2 | tail -1 | awk '{print 100 - $15}')|"
|
|
43
|
+
"$(free -m | awk '/^Mem:/ {print $2}')|"
|
|
44
|
+
"$(free -m | awk '/^Mem:/ {print $7}')\"")
|
|
45
|
+
|
|
46
|
+
raw_output = subprocess.check_output(cmd, shell=True).decode().strip()
|
|
47
|
+
parts = raw_output.split('|')
|
|
48
|
+
|
|
49
|
+
# Math translation converting MB allocations to clean float GB metrics
|
|
50
|
+
tot_gb = round(int(parts[3]) / 1024, 1) if parts[3].isdigit() else 0.0
|
|
51
|
+
avail_gb = round(int(parts[4]) / 1024, 1) if parts[4].isdigit() else 0.0
|
|
52
|
+
|
|
53
|
+
dynamic_data = {
|
|
54
|
+
"cpu_company_name": parts[0],
|
|
55
|
+
"physical_cores": int(parts[1]) if parts[1].isdigit() else self.logical_cores,
|
|
56
|
+
"cpu_percentage_use": parts[2],
|
|
57
|
+
"ram_total_gb": tot_gb,
|
|
58
|
+
"ram_available_gb": avail_gb
|
|
59
|
+
}
|
|
60
|
+
elif self.os_name == "Darwin": # macOS
|
|
61
|
+
# Safe Mac Zsh single line telemetry extraction separated by pipes
|
|
62
|
+
cmd = ("echo \"$(sysctl -n machdep.cpu.brand_string)|"
|
|
63
|
+
"$(sysctl -n hw.physicalcpu)|"
|
|
64
|
+
"$(ps -A -o %cpu | awk '{s+=$1} END {print s}')|"
|
|
65
|
+
"$(($(sysctl -n hw.memsize) / 1024 / 1024 / 1024))|"
|
|
66
|
+
"$(($(vm_stat | awk '/Pages free/ {print $3}' | tr -d '.') * 4096 / 1024 / 1024 / 1024))\"")
|
|
67
|
+
|
|
68
|
+
raw_output = subprocess.check_output(cmd, shell=True).decode().strip()
|
|
69
|
+
parts = raw_output.split('|')
|
|
70
|
+
|
|
71
|
+
mac_usage = round(float(parts[2]) / self.logical_cores, 1) if parts[2] else 0.0
|
|
72
|
+
|
|
73
|
+
dynamic_data = {
|
|
74
|
+
"cpu_company_name": parts[0],
|
|
75
|
+
"physical_cores": int(parts[1]) if parts[1].isdigit() else self.logical_cores,
|
|
76
|
+
"cpu_percentage_use": mac_usage,
|
|
77
|
+
"ram_total_gb": parts[3],
|
|
78
|
+
"ram_available_gb": parts[4]
|
|
79
|
+
}
|
|
80
|
+
else:
|
|
81
|
+
return {"error": "Unsupported Operating System"}
|
|
82
|
+
|
|
83
|
+
# Combine everything cleanly into your final flat output dictionary
|
|
84
|
+
return {
|
|
85
|
+
"os_name": self.os_name,
|
|
86
|
+
"architecture": self.architecture,
|
|
87
|
+
"cpu_company_name": dynamic_data.get("cpu_company_name"),
|
|
88
|
+
"physical_cores": dynamic_data.get("physical_cores"),
|
|
89
|
+
"logical_cores": self.logical_cores,
|
|
90
|
+
"cpu_percentage_use": f"{dynamic_data.get('cpu_percentage_use')}%",
|
|
91
|
+
"ram_total": f"{dynamic_data.get('ram_total_gb')} GB",
|
|
92
|
+
"ram_available": f"{dynamic_data.get('ram_available_gb')} GB"
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
except Exception as e:
|
|
96
|
+
return {"error": f"Failed to gather system telemetry: {str(e)}"}
|
|
File without changes
|