mirror of
https://github.com/iio612/DEFENDER.git
synced 2026-02-13 11:14:23 +00:00
update installation module
This commit is contained in:
@@ -28,22 +28,17 @@ 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
|
||||
|
||||
if self.skip_install:
|
||||
return None
|
||||
# Sinon tester les dependances python et les installer avec pip
|
||||
if self.do_install():
|
||||
|
||||
# Sinon tester les dependances python et les installer avec pip
|
||||
if self.do_install():
|
||||
self.install_dependencies()
|
||||
|
||||
self.install_dependencies()
|
||||
self.create_service_file()
|
||||
|
||||
self.create_service_file()
|
||||
|
||||
self.print_final_message()
|
||||
self.print_final_message()
|
||||
|
||||
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:
|
||||
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 /!\\')
|
||||
self.skip_install = True
|
||||
return False
|
||||
|
||||
if self.is_root():
|
||||
exit(f'/!\\ I highly not recommend running Defender as root /!\\')
|
||||
self.skip_install = True
|
||||
return False
|
||||
|
||||
def is_root(self) -> bool:
|
||||
|
||||
|
||||
@@ -150,8 +150,33 @@ class Config:
|
||||
with open(conf_filename, 'r') as configuration_data:
|
||||
configuration:dict[str, Union[str, int, list, dict]] = json.load(configuration_data)
|
||||
|
||||
for key, value in configuration['CONFIG_COLOR'].items():
|
||||
configuration['CONFIG_COLOR'][key] = str(value).encode('utf-8').decode('unicode_escape')
|
||||
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')
|
||||
|
||||
return configuration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user