Fix some issues

This commit is contained in:
adator
2024-08-28 00:50:50 +02:00
parent c635851d19
commit 9cd089ee6e
4 changed files with 17 additions and 11 deletions

View File

@@ -62,7 +62,7 @@ class Install:
defender_install_folder=defender_install_folder, defender_install_folder=defender_install_folder,
venv_folder=venv_folder, venv_folder=venv_folder,
venv_cmd_installation=['python3', '-m', 'venv', venv_folder], venv_cmd_installation=['python3', '-m', 'venv', venv_folder],
venv_cmd_requirements=['sqlalchemy','psutil','requests'], venv_cmd_requirements=['sqlalchemy','psutil','requests','faker'],
venv_pip_executable=f'{os.path.join(defender_install_folder, venv_folder, "bin")}{os.sep}pip', venv_pip_executable=f'{os.path.join(defender_install_folder, venv_folder, "bin")}{os.sep}pip',
venv_python_executable=f'{os.path.join(defender_install_folder, venv_folder, "bin")}{os.sep}python' venv_python_executable=f'{os.path.join(defender_install_folder, venv_folder, "bin")}{os.sep}python'
) )

View File

@@ -1,4 +1,4 @@
import json import json, sys
from os import sep from os import sep
from typing import Union from typing import Union
from dataclasses import dataclass, field from dataclasses import dataclass, field
@@ -72,15 +72,20 @@ class Config:
return None return None
def __load_json_service_configuration(self): def __load_json_service_configuration(self):
try:
conf_filename = f'core{sep}configuration.json'
with open(conf_filename, 'r') as configuration_data:
configuration:dict[str, Union[str, int, list, dict]] = json.load(configuration_data)
conf_filename = f'core{sep}configuration.json' for key, value in configuration['CONFIG_COLOR'].items():
with open(conf_filename, 'r') as configuration_data: configuration['CONFIG_COLOR'][key] = str(value).encode('utf-8').decode('unicode_escape')
configuration:dict[str, Union[str, int, list, dict]] = json.load(configuration_data)
for key, value in configuration['CONFIG_COLOR'].items(): return configuration
configuration['CONFIG_COLOR'][key] = str(value).encode('utf-8').decode('unicode_escape')
return configuration except FileNotFoundError as fe:
print(f'FileNotFound: {fe}')
print('Configuration file not found please create core/configuration.json')
sys.exit(0)
def __load_service_configuration(self) -> ConfigDataModel: def __load_service_configuration(self) -> ConfigDataModel:
import_config = self.__load_json_service_configuration() import_config = self.__load_json_service_configuration()

View File

@@ -208,10 +208,12 @@ class Clone():
if clone_name.lower() == 'all': if clone_name.lower() == 'all':
for clone in self.ModConfig.clone_nicknames: for clone in self.ModConfig.clone_nicknames:
self.Irc.send2socket(f':{dnickname} PRIVMSG {clone} :KILL') self.Irc.send2socket(f':{dnickname} PRIVMSG {clone} :KILL')
self.ModConfig.clone_nicknames.remove(clone)
else: else:
for clone in self.ModConfig.clone_nicknames: for clone in self.ModConfig.clone_nicknames:
if clone_name == clone: if clone_name == clone:
self.Irc.send2socket(f':{dnickname} PRIVMSG {clone} :KILL') self.Irc.send2socket(f':{dnickname} PRIVMSG {clone} :KILL')
self.ModConfig.clone_nicknames.remove(clone)
except Exception as err: except Exception as err:
self.Logs.error(f'{err}') self.Logs.error(f'{err}')

View File

@@ -4,7 +4,6 @@ from typing import Union
import re, socket, psutil, requests, json, time import re, socket, psutil, requests, json, time
from sys import exit from sys import exit
from core.irc import Irc from core.irc import Irc
from test import Test
# Le module crée devra réspecter quelques conditions # Le module crée devra réspecter quelques conditions
# 1. Le nom de la classe devra toujours s'appeler comme le module. Exemple => nom de class Defender | nom du module mod_defender # 1. Le nom de la classe devra toujours s'appeler comme le module. Exemple => nom de class Defender | nom du module mod_defender