-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem_info.py
145 lines (123 loc) · 5.51 KB
/
system_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import tkinter as tk
from tkinter import messagebox
import subprocess
import platform
import psutil
import socket
from PIL import ImageGrab
import matplotlib.pyplot as plt
import threading
import time
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
import os
# Windows lisans anahtarını almak için komut
def get_windows_key():
try:
command = 'wmic path SoftwareLicensingService get OA3xOriginalProductKey'
product_key = subprocess.check_output(command, shell=True).decode().strip().split('\n')[1]
return product_key
except Exception as e:
return "Lisans anahtarı alınamadı"
# Linux için lisans anahtarını almak
def get_linux_key():
try:
command = "sudo dmidecode -s system-uuid"
product_key = subprocess.check_output(command, shell=True).decode().strip()
return product_key
except Exception as e:
return "Lisans anahtarı alınamadı"
# Sistem bilgilerini almak
def get_system_info():
system_info = {
'İS': platform.system(),
'Sürüm': platform.version(),
'Mimari': platform.architecture()[0],
'Makine': platform.machine(),
'İşlemci': platform.processor(),
'RAM': f"{psutil.virtual_memory().total // (1024 ** 3)} GB",
'Disk': f"{psutil.disk_usage('/').total // (1024 ** 3)} GB",
'IP Adres': socket.gethostbyname(socket.gethostname()),
'CPU Kullanımı': f"{psutil.cpu_percent()}%",
'Pil Durumu': get_battery_status()
}
# İşletim sistemine göre ekstra bilgiler ekleyelim
if platform.system() == "Windows":
system_info['Ürün Anahtarı'] = get_windows_key()
elif platform.system() == "Linux":
system_info['Ürün Anahtarı'] = get_linux_key()
elif platform.system() == "Darwin": # macOS
system_info['Ürün Anahtarı'] = "macOS Anahtarı Bilgisi mevcut değil"
return system_info
# Batarya durumunu almak
def get_battery_status():
battery = psutil.sensors_battery()
if battery:
return f"{battery.percent}% - {'Şarj etme' if battery.power_plugged else 'Şarj Olmuyor'}"
return "Pil bilgisi mevcut değil"
# Sistem performansını sürekli izlemek
def monitor_system_performance(app):
while True:
time.sleep(1)
cpu_usage = psutil.cpu_percent(interval=1)
ram_usage = psutil.virtual_memory().percent
app.update_performance_graph(cpu_usage, ram_usage)
# GUI Uygulaması
class SystemInfoApp:
def __init__(self, window, window_title):
self.window = window
self.window.title(window_title)
self.window.configure(bg="lightgray")
# Sabit boyutlu form
self.window.geometry("780x780") # Form boyutlarını sabitleyin
self.window.resizable(False, False) # Boyutlandırmayı devre dışı bırakın
# Sistem bilgilerini al
system_info = get_system_info()
# Başlık etiketi
label = tk.Label(self.window, text="Sistem Bilgileri", font=("Arial", 16), bg="lightblue")
label.pack(pady=10, fill='x')
# Bilgileri ekrana yazdır
self.info_frame = tk.Frame(self.window, bg="lightgray")
self.info_frame.pack(padx=10, pady=10, fill='both', expand=True)
for key, value in system_info.items():
info_label = tk.Label(self.info_frame, text=f"{key}: {value}", font=("Arial", 12), bg="lightgray")
info_label.pack(pady=5)
# Kaydet butonu
save_button = tk.Button(self.window, text="Bilgileri Kaydet", command=lambda: save_to_file(system_info), font=("Arial", 12), bg="lightgreen")
save_button.pack(pady=10)
# Ekran görüntüsü butonu
capture_button = tk.Button(self.window, text="Ekran Görüntüsü Al", command=capture_screenshot, font=("Arial", 12), bg="lightcoral")
capture_button.pack(pady=10)
# Performans Grafiği
self.figure = plt.Figure(figsize=(5, 2), dpi=100)
self.canvas = FigureCanvasTkAgg(self.figure, self.window)
self.canvas.get_tk_widget().pack(padx=10, pady=10)
# Gerçek zamanlı performans takibi
self.monitor_thread = threading.Thread(target=monitor_system_performance, args=(self,), daemon=True)
self.monitor_thread.start()
self.window.mainloop()
# Performans grafiğini güncellemek
def update_performance_graph(self, cpu_usage, ram_usage):
self.figure.clear()
ax = self.figure.add_subplot(111)
ax.bar(['CPU Kullanımı', 'RAM Kullanımı'], [cpu_usage, ram_usage], color=['blue', 'green'])
ax.set_ylim(0, 100)
ax.set_title('Sistem Performansı')
self.canvas.draw()
# Ekran görüntüsü almak
def capture_screenshot():
screenshot = ImageGrab.grab()
screenshot.save("screenshot.png")
messagebox.showinfo("Ekran Görüntüsü", "Ekran görüntüsü 'screenshot.png' olarak kaydedildi.")
# Sistemi dosyaya kaydetme
def save_to_file(system_info):
try:
with open("sistem_bilgi.txt", "w") as file:
for key, value in system_info.items():
file.write(f"{key}: {value}\n")
messagebox.showinfo("Başarılı", "Bilgiler başarıyla kaydedildi.")
except Exception as e:
messagebox.showerror("Hata", "Bilgiler kaydedilemedi.")
# Uygulamayı başlat
root = tk.Tk()
app = SystemInfoApp(root, "Çapraz Platform Sistem Bilgileri ve Performans Takibi")