4
4
import socket
5
5
6
6
# Function to get CPU information
7
+
8
+
7
9
def get_cpu_info ():
8
10
cpu_info = {}
9
11
cpu_info ['CPU' ] = platform .processor ()
@@ -13,16 +15,21 @@ def get_cpu_info():
13
15
return cpu_info
14
16
15
17
# Function to get GPU information (for any brand)
18
+
19
+
16
20
def get_gpu_info ():
17
21
gpu_info = {}
18
22
try :
19
23
gpus = psutil .virtual_memory ().available
20
24
if gpus :
21
- gpu_info ['GPU Name' ] = 'Integrated GPU' # If integrated graphics is available
25
+ # If integrated graphics is available
26
+ gpu_info ['GPU Name' ] = 'Integrated GPU'
22
27
gpu_info ['GPU Memory' ] = f"{ gpus / (1024 ** 3 ):.2f} GB"
23
- gpu_info ['Driver Version' ] = 'N/A' # For integrated GPUs, driver version may not be available
28
+ # For integrated GPUs, driver version may not be available
29
+ gpu_info ['Driver Version' ] = 'N/A'
24
30
else :
25
- result = subprocess .check_output (["nvidia-smi" , "--query-gpu=name,memory.total,driver_version" , "--format=csv,noheader" ], encoding = "utf-8" )
31
+ result = subprocess .check_output (
32
+ ["nvidia-smi" , "--query-gpu=name,memory.total,driver_version" , "--format=csv,noheader" ], encoding = "utf-8" )
26
33
gpu_name , memory , driver_version = result .strip ().split (',' )
27
34
gpu_info ['GPU Name' ] = gpu_name
28
35
gpu_info ['GPU Memory' ] = f"{ int (memory .strip ().split ()[0 ]) / 1024 :.2f} GB"
@@ -34,20 +41,25 @@ def get_gpu_info():
34
41
return gpu_info
35
42
36
43
# Function to get battery status (for laptops)
44
+
45
+
37
46
def get_battery_status ():
38
47
battery_status = {}
39
48
try :
40
49
battery = psutil .sensors_battery ()
41
50
battery_status ['Charge Percentage' ] = f"{ battery .percent } %"
42
51
battery_status ['Power Plugged' ] = "Yes" if battery .power_plugged else "No"
43
- battery_status ['Remaining Time' ] = "Unknown" if battery .power_plugged else str (battery .secsleft // 60 ) + " minutes"
52
+ battery_status ['Remaining Time' ] = "Unknown" if battery .power_plugged else str (
53
+ battery .secsleft // 60 ) + " minutes"
44
54
except AttributeError :
45
55
battery_status ['Charge Percentage' ] = 'N/A'
46
56
battery_status ['Power Plugged' ] = 'N/A'
47
57
battery_status ['Remaining Time' ] = 'N/A'
48
58
return battery_status
49
59
50
60
# Function to get network interface information
61
+
62
+
51
63
def get_network_info ():
52
64
network_info = {}
53
65
try :
@@ -63,25 +75,31 @@ def get_network_info():
63
75
return network_info
64
76
65
77
# Function to get system temperature (Linux and Windows only)
78
+
79
+
66
80
def get_system_temperature ():
67
81
temp_info = {}
68
82
try :
69
83
# sensors = psutil.sensors_temperatures()
70
84
temp_info = psutil .sensors_temperatures ()['coretemp' ][0 ].current
71
85
# for sensor, entries in sensors.items():
72
- # temp_info[sensor] = [f"{entry.current}°C" for entry in entries]
86
+ # temp_info[sensor] = [f"{entry.current}°C" for entry in entries]
73
87
except Exception as e :
74
88
print (f"Error fetching system temperature: { e } " )
75
89
temp_info = {'Temperature' : 'N/A' }
76
90
return temp_info
77
91
78
92
# Function to list installed software (Windows only)
93
+
94
+
79
95
def get_installed_software ():
80
96
software_list = {}
81
97
try :
82
- process = subprocess .Popen (["wmic" , "product" , "get" , "Name" ], stdout = subprocess .PIPE , stderr = subprocess .PIPE , universal_newlines = True )
98
+ process = subprocess .Popen (["wmic" , "product" , "get" , "Name" ],
99
+ stdout = subprocess .PIPE , stderr = subprocess .PIPE , universal_newlines = True )
83
100
stdout , stderr = process .communicate ()
84
- software_list ['Installed Software' ] = [line .strip () for line in stdout .split ('\n ' ) if line .strip ()]
101
+ software_list ['Installed Software' ] = [line .strip ()
102
+ for line in stdout .split ('\n ' ) if line .strip ()]
85
103
except FileNotFoundError :
86
104
software_list ['Installed Software' ] = 'N/A'
87
105
except Exception as e :
@@ -90,6 +108,8 @@ def get_installed_software():
90
108
return software_list
91
109
92
110
# Function to list connected USB devices
111
+
112
+
93
113
def get_usb_devices ():
94
114
usb_devices = []
95
115
try :
@@ -102,28 +122,31 @@ def get_usb_devices():
102
122
return usb_devices
103
123
104
124
# Function to get display information (Windows only)
125
+
126
+
105
127
def get_display_info ():
106
128
display_info = {}
107
129
try :
108
- process = subprocess .Popen (["wmic" , "desktopmonitor" , "get" , "ScreenHeight,ScreenWidth" , "/format:list" ], stdout = subprocess .PIPE , stderr = subprocess .PIPE , universal_newlines = True )
130
+ process = subprocess .Popen (["wmic" , "desktopmonitor" , "get" , "ScreenHeight,ScreenWidth" ,
131
+ "/format:list" ], stdout = subprocess .PIPE , stderr = subprocess .PIPE , universal_newlines = True )
109
132
stdout , stderr = process .communicate ()
110
133
lines = [line .strip () for line in stdout .split ('\n ' ) if line .strip ()]
111
-
134
+
112
135
if len (lines ) >= 2 :
113
136
display_info ['Screen Resolution' ] = f"{ lines [0 ].split ('=' )[1 ]} x{ lines [1 ].split ('=' )[1 ]} pixels"
114
137
else :
115
138
display_info ['Screen Resolution' ] = 'N/A'
116
-
139
+
117
140
if len (lines ) >= 3 :
118
141
display_info ['Color Depth' ] = f"{ lines [2 ].split ('=' )[1 ]} bits"
119
142
else :
120
143
display_info ['Color Depth' ] = 'N/A'
121
-
144
+
122
145
if len (lines ) >= 4 :
123
146
display_info ['Refresh Rate' ] = f"{ lines [3 ].split ('=' )[1 ]} Hz"
124
147
else :
125
148
display_info ['Refresh Rate' ] = 'N/A'
126
-
149
+
127
150
except FileNotFoundError :
128
151
display_info ['Screen Resolution' ] = 'N/A'
129
152
display_info ['Color Depth' ] = 'N/A'
@@ -133,12 +156,16 @@ def get_display_info():
133
156
return display_info
134
157
135
158
# Function to get audio devices information (Windows only)
159
+
160
+
136
161
def get_audio_devices_info ():
137
162
audio_devices_info = {}
138
163
try :
139
- process = subprocess .Popen (["powershell" , "(Get-WmiObject -Class Win32_SoundDevice).Name" ], stdout = subprocess .PIPE , stderr = subprocess .PIPE , universal_newlines = True )
164
+ process = subprocess .Popen (["powershell" , "(Get-WmiObject -Class Win32_SoundDevice).Name" ],
165
+ stdout = subprocess .PIPE , stderr = subprocess .PIPE , universal_newlines = True )
140
166
stdout , stderr = process .communicate ()
141
- audio_devices_info ['Audio Devices' ] = [line .strip () for line in stdout .split ('\n ' ) if line .strip ()]
167
+ audio_devices_info ['Audio Devices' ] = [line .strip ()
168
+ for line in stdout .split ('\n ' ) if line .strip ()]
142
169
except FileNotFoundError :
143
170
audio_devices_info ['Audio Devices' ] = 'N/A'
144
171
except Exception as e :
@@ -147,9 +174,12 @@ def get_audio_devices_info():
147
174
return audio_devices_info
148
175
149
176
# Function to check internet connectivity
177
+
178
+
150
179
def check_internet_connectivity ():
151
180
try :
152
- subprocess .check_call (["ping" , "-c" , "1" , "www.google.com" ], stdout = subprocess .PIPE , stderr = subprocess .PIPE )
181
+ subprocess .check_call (["ping" , "-c" , "1" , "www.google.com" ],
182
+ stdout = subprocess .PIPE , stderr = subprocess .PIPE )
153
183
return True
154
184
except subprocess .CalledProcessError :
155
185
return False
@@ -158,6 +188,8 @@ def check_internet_connectivity():
158
188
return False
159
189
160
190
# Function to get current date and time
191
+
192
+
161
193
def get_current_date_time ():
162
194
import datetime
163
195
try :
@@ -167,6 +199,8 @@ def get_current_date_time():
167
199
return 'N/A'
168
200
169
201
# Function to get total and available RAM and disk space
202
+
203
+
170
204
def get_memory_disk_space_info ():
171
205
try :
172
206
svmem = psutil .virtual_memory ()
@@ -192,6 +226,7 @@ def get_memory_disk_space_info():
192
226
'Available Disk Space' : 'N/A'
193
227
}
194
228
229
+
195
230
if __name__ == "__main__" :
196
231
if platform .system () != 'Windows' :
197
232
print ("Sorry, the script is currently available only for Windows Operating System" )
@@ -231,7 +266,11 @@ def get_memory_disk_space_info():
231
266
232
267
print ("\n ---- RAM and Disk Space Information ----" )
233
268
memory_disk_info = get_memory_disk_space_info ()
234
- print (f"Total Memory (RAM): { memory_disk_info ['Total Memory (RAM)' ]:.2f} GB" )
235
- print (f"Available Memory (RAM): { memory_disk_info ['Available Memory (RAM)' ]:.2f} GB" )
236
- print (f"Total Disk Space: { memory_disk_info ['Total Disk Space' ]:.2f} GB" )
237
- print (f"Available Disk Space: { memory_disk_info ['Available Disk Space' ]:.2f} GB" )
269
+ print (
270
+ f"Total Memory (RAM): { memory_disk_info ['Total Memory (RAM)' ]:.2f} GB" )
271
+ print (
272
+ f"Available Memory (RAM): { memory_disk_info ['Available Memory (RAM)' ]:.2f} GB" )
273
+ print (
274
+ f"Total Disk Space: { memory_disk_info ['Total Disk Space' ]:.2f} GB" )
275
+ print (
276
+ f"Available Disk Space: { memory_disk_info ['Available Disk Space' ]:.2f} GB" )
0 commit comments