update installation module

This commit is contained in:
adator
2024-09-18 19:08:08 +02:00
parent 9c78ad0860
commit 3cd2077f63
2 changed files with 49 additions and 23 deletions

View File

@@ -28,11 +28,6 @@ class Install:
self.set_configuration()
if not self.check_python_version():
# Tester si c'est la bonne version de python
exit("Python Version Error")
else:
if self.skip_install:
return None
@@ -74,18 +69,24 @@ class Install:
venv_python_executable=f'{os.path.join(defender_install_folder, venv_folder, "bin")}{os.sep}python'
)
# Exclude Windows OS
if self.check_python_version():
# If the Python version is not good then Exit
exit("/!\\ Python version error /!\\")
if not os.path.exists(os.path.join(self.config.defender_install_folder, 'core', 'configuration.json')):
# If configuration file do not exist
exit("/!\\ Configuration file (configuration.json) doesn't exist /!\\")
# Exclude Windows OS from the installation
if os.name == 'nt':
#print('/!\\ Skip installation /!\\')
self.skip_install = True
else:
return False
if self.is_root():
print(f'/!\\ I fully not recommend running Defender as root /!\\')
self.skip_install = True
# Check if configuration.json exist
if not os.path.exists({os.path.join(self.config.defender_install_folder, 'core', 'configuration.json')}):
print(f'/!\\ configuration.json is not available, please create it first /!\\')
exit(f'/!\\ I highly not recommend running Defender as root /!\\')
self.skip_install = True
return False
def is_root(self) -> bool:

View File

@@ -150,6 +150,31 @@ class Config:
with open(conf_filename, 'r') as configuration_data:
configuration:dict[str, Union[str, int, list, dict]] = json.load(configuration_data)
config_dict = {"CONFIG_COLOR" : {
"blanche": "\\u0003\\u0030",
"noire": "\\u0003\\u0031",
"bleue": "\\u0003\\u0020",
"verte": "\\u0003\\u0033",
"rouge": "\\u0003\\u0034",
"jaune": "\\u0003\\u0036",
"gras": "\\u0002",
"nogc": "\\u0002\\u0003"
}
}
missing_color = False
if not "CONFIG_COLOR" in configuration:
missing_color = True
configuration_color = config_dict
else:
configuration_color = configuration["CONFIG_COLOR"]
if missing_color:
for key, value in configuration_color.items():
configuration_color['CONFIG_COLOR'][key] = str(value).encode('utf-8').decode('unicode_escape')
configuration['CONFIG_COLOR'] = configuration_color['CONFIG_COLOR']
else:
for key, value in configuration['CONFIG_COLOR'].items():
configuration['CONFIG_COLOR'][key] = str(value).encode('utf-8').decode('unicode_escape')