This repository was archived by the owner on Jan 2, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebugger.py
More file actions
109 lines (101 loc) · 4.7 KB
/
debugger.py
File metadata and controls
109 lines (101 loc) · 4.7 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
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
# ==================================================================================
# ========================== GESTION MEMOIRE DU BOT DISCORD ========================
# ==================================================================================
# Auteur: @NYTHIQUE
# GitHub: https://github.com/Nythique
# Porfolio: https://nythique.github.io
# Description: Ce fichier contient le code principal du bot Discord PDL-IA.
# Date de création: 01/05/2020
# Licence: GNU AFFERO GENERAL PUBLIC LICENSE
#==================================================================================#
#++++++++++++++++++++++++++ LES IMPORTATIONS ++++++++++++++++++++++++++++++++++++++#
#==================================================================================#
import time
import colorama
import threading
import os
from colorama import Style, Fore
from plugins.integrating.storing.database import database
from plugins.integrating.hosting.node_vm import hardwareInfo
#==================================================================================#
#++++++++++++++++++++++++++ LES INITIALISATION ++++++++++++++++++++++++++++++++++++#
#==================================================================================#
colorama.init()
# DB instance is created only when running this script directly to avoid side-effects on import
db = None
#==================================================================================#
#++++++++++++++++++++++++++ LES FONCTIONS ++++++++++++++++++++++++++++++++++++++#
#==================================================================================#
def testDatabase():
try:
print(Fore.YELLOW + f"[TEST DATABASE START]-> Début du test du module database.py." + Style.RESET_ALL)
db.addAdmin(12323545654)
time.sleep(1)# Pause
db.addUserBlackList(293958347983)
time.sleep(1)# Pause
db.addChannelList(1389375843)
time.sleep(1)# Pause
db.addServerBlackList(25342534534)
time.sleep(1)# Pause
db.addBotStatusList("salut ! Moi c'est le boncoin")
time.sleep(1)# Pause
db.updateBotStats("QueryNumber", 9)
time.sleep(1)# Pause
db.updateBotStats("serverNumber", 10)
time.sleep(1)# Pause
db.updateBotStats("userNumber", 11)
time.sleep(1)# Pause
db.removeAdmin(12323545654)
time.sleep(1)# Pause
db.removeUserBlackList(293958347983)
time.sleep(1)# Pause
db.removeChannelList(1389375843)
time.sleep(1)# Pause
db.removeServerBlackList(25342534534)
time.sleep(1)# Pause
db.removeBotStatusList("salut ! Moi c'est le boncoin")
time.sleep(5)# Pause
db.selectData("adminList")
time.sleep(1)# Pause
db.selectData("userBlackList")
time.sleep(1)# Pause
db.selectData("serverBlackList")
time.sleep(1)# Pause
db.selectData("channelList")
time.sleep(1)# Pause
db.selectData("botStatusList")
time.sleep(1)# Pause
db.selectData("botStats") # Sur forme de tableau (clé, valeur)
time.sleep(1)# Pause
print(Fore.GREEN + f"[TEST DATABASE END]-> Fin du test du module database.py." + Style.RESET_ALL)
except Exception as e:
print(Fore.RED + f"[TEST DATABASE ERROR]-> {e}, ligne 62." + Style.RESET_ALL)
def testNodeVm():
try:
print(Fore.YELLOW + f"[TEST NODE-VM START]-> Début du test du module node_vm.py." + Style.RESET_ALL)
hardwareInfo()
time.sleep(1)# Pause
print(Fore.GREEN + f"[TEST NODE-VM START]-> Fin du test du module node_vm.py."+ Style.RESET_ALL)
except Exception as e:
print(Fore.RED + f"[TEST NODE-VM ERROR]-> {e}, ligne 71." + Style.RESET_ALL)
#==================================================================================#
#++++++++++++++++++++++++++ LES TESTS UNITAIRES +++++++++++++++++++++++++++++++++++#
#==================================================================================#
if __name__ == '__main__':
# Ensure test DB directory exists
test_db_path = os.path.join('unit-tests', 'data', 'data.json')
test_db_dir = os.path.dirname(test_db_path)
if test_db_dir and not os.path.exists(test_db_dir):
try:
os.makedirs(test_db_dir, exist_ok=True)
except Exception as e:
print(Fore.RED + f"[TEST SETUP ERROR]-> Could not create test DB directory: {e}" + Style.RESET_ALL)
raise
# initialize DB for tests
db = database(test_db_path)
th1 = threading.Thread(target=testDatabase)
th2 = threading.Thread(target=testNodeVm)
th1.start()
th2.start()
th1.join()
th2.join()