-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_spam.py
More file actions
64 lines (53 loc) · 2.09 KB
/
Copy pathdebug_spam.py
File metadata and controls
64 lines (53 loc) · 2.09 KB
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
import sys
from PyQt6.QtWidgets import QApplication
from PyQt6.QtCore import QEventLoop
import time
print("[DEBUG] Initializing QApplication...")
app = QApplication(sys.argv)
print("[DEBUG] Importing gui_app...")
import gui_app
# Monkeypatch trace prints
old_on_token_generated = gui_app.AIBobApp.on_token_generated
def new_on_token_generated(self, token):
print(f"[TRACE] on_token_generated called with: {repr(token)}")
sys.stdout.flush()
old_on_token_generated(self, token)
print(f"[TRACE] on_token_generated finished.")
sys.stdout.flush()
gui_app.AIBobApp.on_token_generated = new_on_token_generated
old_append_text = gui_app.MessageBubble.append_text
def new_append_text(self, token):
print(f"[TRACE] MessageBubble.append_text called with: {repr(token)}")
sys.stdout.flush()
old_append_text(self, token)
print(f"[TRACE] MessageBubble.append_text finished.")
sys.stdout.flush()
gui_app.MessageBubble.append_text = new_append_text
old_on_inference_finished = gui_app.AIBobApp.on_inference_finished
def new_on_inference_finished(self, response):
print(f"[TRACE] on_inference_finished called with: {repr(response)}")
sys.stdout.flush()
old_on_inference_finished(self, response)
print(f"[TRACE] on_inference_finished finished.")
sys.stdout.flush()
gui_app.AIBobApp.on_inference_finished = new_on_inference_finished
print("[DEBUG] Instantiating AIBobApp...")
window = gui_app.AIBobApp()
print("[DEBUG] Window instantiated successfully.")
print("[DEBUG] Setting agent is_loaded to False...")
window.agent.is_loaded = False
print("[DEBUG] Starting spam loop...")
for i in range(1, 11):
print(f"[DEBUG] Sending query {i}...")
sys.stdout.flush()
window.input_field.setText(f"شيك الرامات {i}")
window.handle_send()
print(f"[DEBUG] Processing events for query {i}...")
sys.stdout.flush()
for _ in range(10):
QApplication.processEvents(QEventLoop.ProcessEventsFlag.AllEvents, 10)
time.sleep(0.01)
print("[DEBUG] Spam loop finished.")
print("[DEBUG] Closing window...")
window.close()
print("[DEBUG] Window closed.")