# Path: lib/Settings.py
# class Settings:
#     def __init__(self,
#                  override_settings_path='settings.cfg'):
#         self.settingsFilePath = override_settings_path
#         self.parser = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
#         self.settings = None
#         self.getSettings()
# 
#     def getSettings(self):
#         self.parser.read('./settings.cfg')
#         self.settings = {section: dict(**self.parser[section]) for section in self.parser.sections()}
# 
#         return self.settings
# 
#     def getServiceIp(self, service):
#         return self.settings['general']['my_ip']
# 
# Path: lib/Tools/paths.py

# 
# Path: lib/Wrappers/Logger.py
# class Logger:
#     def __init__(self, name):
#         if 'UNITTESTING' in os.environ:
#             self.logging = NullLogger()
#         else:
#             settings = Settings().getSettings()
#             logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
#                                 level=settings["logs"]["level"])
#             self.logging = logging.getLogger(name)
# 
#     def debug(self, *args, **kwargs):
#         self.logging.debug(*args, **kwargs)
# 
#     def info(self, *args, **kwargs):
#         self.logging.info(*args, **kwargs)
# 
#     def warning(self, *args, **kwargs):
#         self.logging.warning(*args, **kwargs)
# 
#     def error(self, *args, **kwargs):
#         self.logging.error(*args, **kwargs)
# 
#     def critical(self, *args, **kwargs):
#         self.logging.critical(*args, **kwargs)
# 
#     def log(self, *args, **kwargs):
#         self.logging.log(*args, **kwargs)


import os
import shutil
import subprocess
from lib.Settings import Settings
from lib.Tools import paths
from lib.Wrappers.Logger import Logger



class FileSystem:

    def __init__(self, injectedSettings=None, injectedSubprocess=None):
        self.logger = Logger(__name__)
        self.settings = injectedSettings or Settings().getSettings()
        self.subprocess = injectedSubprocess or subprocess

    def clean_filesystem(self):
        self.logger.info("Cleaning filesystem.")
        self._clean_files(paths.raw_fs)
        self.logger.info("Cleaning databases.")
        self._clean_files(paths.data + "/db")
        self.logger.info("Cleaning LDAP.")
        self._clean_files(paths.data + "/ldap")
        self.logger.info("Cleaning elasticsearch.")
        self._clean_files(paths.data + "/elasticsearch")
        self.logger.info("Cleaning MySql.")

# Path: lib/Settings.py
# class Settings:
#     def __init__(self,
#                  override_settings_path='settings.cfg'):
#         self.settingsFilePath = override_settings_path
#         self.parser = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
#         self.settings = None
#         self.getSettings()
# 
#     def getSettings(self):
#         self.parser.read('./settings.cfg')
#         self.settings = {section: dict(**self.parser[section]) for section in self.parser.sections()}
# 
#         return self.settings
# 
#     def getServiceIp(self, service):
#         return self.settings['general']['my_ip']
# 
# Path: lib/Tools/paths.py

# 
# Path: lib/Wrappers/Logger.py
# class Logger:
#     def __init__(self, name):
#         if 'UNITTESTING' in os.environ:
#             self.logging = NullLogger()
#         else:
#             settings = Settings().getSettings()
#             logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
#                                 level=settings["logs"]["level"])
#             self.logging = logging.getLogger(name)
# 
#     def debug(self, *args, **kwargs):
#         self.logging.debug(*args, **kwargs)
# 
#     def info(self, *args, **kwargs):
#         self.logging.info(*args, **kwargs)
# 
#     def warning(self, *args, **kwargs):
#         self.logging.warning(*args, **kwargs)
# 
#     def error(self, *args, **kwargs):
#         self.logging.error(*args, **kwargs)
# 
#     def critical(self, *args, **kwargs):
#         self.logging.critical(*args, **kwargs)
# 
#     def log(self, *args, **kwargs):
#         self.logging.log(*args, **kwargs)


# Path: lib/FS/FileSystem.py
import os
import shutil
import subprocess
from lib.Settings import Settings
from lib.Tools import paths
from lib.Wrappers.Logger import Logger




class FileSystem:

    def __init__(self, injectedSettings=None, injectedSubprocess=None):
        self.logger = Logger(__name__)
        self.settings = injectedSettings or Settings().getSettings()
        self.subprocess = injectedSubprocess or subprocess

    def clean_filesystem(self):
        self.logger.info("Cleaning filesystem.")
        self._clean_files(paths.raw_fs)
        self.logger.info("Cleaning databases.")
        self._clean_files(paths.data + "/db")
        self.logger.info("Cleaning LDAP.")
        self._clean_files(paths.data + "/ldap")
        self.logger.info("Cleaning elasticsearch.")
        self._clean_files(paths.data + "/elasticsearch")
        self.logger.info("Cleaning MySql.")

        self._clean_files(paths.data + "/mysql")