forked from OkyanusA/OAD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OAD.py
95 lines (82 loc) · 4.14 KB
/
OAD.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
from PyQt5 import QtWidgets, QtGui, QtCore
import sys
import os
import subprocess
class OADApp(QtWidgets.QWidget):
def __init__(self):
super().__init__()
self.remaining_time = 180 # 180 saniye (3 dakika)
self.init_ui()
def init_ui(self):
self.setWindowTitle("OAD - Tam Ekran Modu")
self.setGeometry(0, 0, QtWidgets.QDesktopWidget().screenGeometry().width(), QtWidgets.QDesktopWidget().screenGeometry().height())
self.setWindowState(QtCore.Qt.WindowFullScreen)
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.CustomizeWindowHint | QtCore.Qt.FramelessWindowHint)
self.setStyleSheet("background-color: #FFFFFF;")
# Label
self.label = QtWidgets.QLabel("OAD Aktif - Lütfen USB Anahtarını Takın\nNot: Süre dolunca sistem kapanacaktır.", self)
self.label.setFont(QtGui.QFont("Arial", 24, QtGui.QFont.Bold))
self.label.setStyleSheet("color: #000000;")
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setGeometry(self.width() // 4, self.height() // 2 - 50, self.width() // 2, 150)
# Zamanlayıcıyı başlat (USB kontrolü için)
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.check_for_usb_key)
self.timer.start(3000) # Her 3 saniyede bir kontrol et
# Geri sayım göstergesi
self.countdown_label = QtWidgets.QLabel(self)
self.countdown_label.setFont(QtGui.QFont("Arial", 20, QtGui.QFont.Bold))
self.countdown_label.setStyleSheet("color: #FF0000;") # Kırmızı renkli geri sayım
self.countdown_label.setAlignment(QtCore.Qt.AlignCenter)
self.countdown_label.setGeometry(self.width() // 4, self.height() // 2 + 100, self.width() // 2, 50)
self.update_countdown_label()
# Geri sayım zamanlayıcısı
self.countdown_timer = QtCore.QTimer(self)
self.countdown_timer.timeout.connect(self.update_countdown)
self.countdown_timer.start(1000) # Her saniye geri sayımı güncelle
def update_countdown_label(self):
minutes = self.remaining_time // 60
seconds = self.remaining_time % 60
self.countdown_label.setText(f"Kalan Süre: {minutes:02d}:{seconds:02d}")
def update_countdown(self):
if self.remaining_time > 0:
self.remaining_time -= 1
self.update_countdown_label()
else:
self.restart_system() # Süre dolunca sistemi yeniden başlat
def check_for_usb_key(self):
# USB sürücülerini kontrol et
drives = [f"{d}:\\" for d in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" if os.path.exists(f"{d}:\\") and os.path.isdir(f"{d}:\\") and os.path.ismount(f"{d}:\\")]
try:
for drive in drives:
key_file_path = os.path.join(drive, "anahtar.dat")
if os.path.exists(key_file_path):
with open(key_file_path, 'r') as key_file:
content = key_file.read().strip()
if "OAD_ANAHTAR: " in content:
self.deactivate_app()
break
except Exception as e:
print(f"Hata: {e}")
def deactivate_app(self):
# USB anahtarı takılıyken uygulamayı kapat
self.timer.stop()
self.countdown_timer.stop()
QtWidgets.QMessageBox.information(self, "OAD Devre Dışı", "USB Anahtarı algılandı. OAD devre dışı bırakılıyor.")
QtCore.QCoreApplication.instance().quit()
def closeEvent(self, event):
# Uygulamanın kapatılmasını engelle
event.ignore()
def restart_system(self):
# Sistemi yeniden başlat
if sys.platform == "win32":
subprocess.call(["shutdown", "/r", "/t", "0"])
elif sys.platform == "linux":
subprocess.call(["systemctl reboot"])
elif sys.platform == "darwin":
subprocess.call(["sudo shutdown -r now"])
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
window = OADApp()
window.show()
sys.exit(app.exec_())