Example #1
0
    def __init__(self, bootstrap, debug_enabled):
        """
        Constructor

        Args:
            bootstrap (dict): bootstrap objects
            debug_enabled (bool): flag to set debug level to logger
        """
        CleepModule.__init__(self, bootstrap, debug_enabled)

        # members
        self.__developer_uuid = None
        self.cleep_path = os.path.dirname(inspect.getfile(CleepModule))
        self.__last_application_build = None
        self.__watcher_task = None
        self.__tests_task = None
        self.__tests_buffer = []
        self.__docs_task = None
        self.__docs_buffer = []

        # events
        self.tests_output_event = self._get_event('developer.tests.output')
        self.docs_output_event = self._get_event('developer.docs.output')
        self.frontend_restart_event = self._get_event(
            'developer.frontend.restart')
Example #2
0
    def __init__(self, bootstrap, debug_enabled):
        """
        Constructor

        Args:
            bootstrap (dict): bootstrap objects
            debug_enabled (bool): flag to set debug level to logger
        """
        CleepModule.__init__(self, bootstrap, debug_enabled)

        # members
        self.bootstrap = bootstrap
        self.events_broker = bootstrap['events_broker']
        self.log_file = bootstrap['log_file']
        self.__monitor_cpu_uuid = None
        self.__monitor_memory_uuid = None
        self.__monitoring_cpu_task = None
        self.__monitoring_memory_task = None
        self.__monitoring_disks_task = None
        self.__process = None
        self.__need_restart = False
        self.__updating_modules = []
        self.__modules = {}
        self.__cleep_update = {
            'package': {
                'url': None
            },
            'checksum': {
                'url': None
            }
        }
        self.cleep_update_pending = False
        self.cleep_backup = CleepBackup(self.cleep_filesystem,
                                        self.crash_report)
        self.cleep_backup_delay = None
        self.cleep_conf = CleepConf(self.cleep_filesystem)
        self.drivers = bootstrap['drivers']

        # events
        self.device_poweroff_event = self._get_event('system.device.poweroff')
        self.device_reboot_event = self._get_event('system.device.reboot')
        self.cleep_restart_event = self._get_event('system.cleep.restart')
        self.cleep_need_restart_event = self._get_event(
            'system.cleep.needrestart')
        self.monitoring_cpu_event = self._get_event('system.monitoring.cpu')
        self.monitoring_memory_event = self._get_event(
            'system.monitoring.memory')
        self.alert_memory_event = self._get_event('system.alert.memory')
        self.driver_install_event = self._get_event('system.driver.install')
        self.driver_uninstall_event = self._get_event(
            'system.driver.uninstall')
Example #3
0
    def __init__(self, bootstrap, debug_enabled):
        """
        Constructor

        Args:
            bootstrap (dict): bootstrap objects
            debug_enabled: debug status
        """
        CleepModule.__init__(self, bootstrap, debug_enabled)

        # members
        self._input_watchers = {}

        # events
        self.gpios_gpio_off = self._get_event("gpios.gpio.off")
        self.gpios_gpio_on = self._get_event("gpios.gpio.on")
Example #4
0
    def __init__(self, bootstrap, debug_enabled):
        """
        Constructor

        Args:
            bootstrap (dict): bootstrap objects
            debug_enabled (bool): flag to set debug level to logger
        """
        # init
        CleepModule.__init__(self, bootstrap, debug_enabled)

        # members
        self.weather_task = None
        self.__owm_uuid = None
        self.__forecast = []

        # events
        self.openweathermap_weather_update = self._get_event(
            "openweathermap.weather.update")
Example #5
0
    def __init__(self, bootstrap, debug_enabled):
        """
        Constructor

        Args:
            bootstrap (dict): bootstrap object
            debug_enabled (bool): debug status
        """
        # init
        CleepModule.__init__(self, bootstrap, debug_enabled)

        # tools
        self.etcnetworkinterfaces = EtcNetworkInterfaces(self.cleep_filesystem)
        self.dhcpcd = DhcpcdConf(self.cleep_filesystem)
        self.wpasupplicantconf = WpaSupplicantConf(self.cleep_filesystem)
        self.iw = Iw()
        self.iwlist = Iwlist()
        self.ifconfig = Ifconfig()
        self.iwconfig = Iwconfig()
        self.ifupdown = Ifupdown()
        self.ip = Ip()
        self.wpacli = Wpacli()
        self.rfkill = Rfkill()
        self.cleepwifi = CleepWifiConf()

        # members
        self.wifi_networks = {}
        self.wifi_network_names = []
        self.wifi_interfaces = {}
        self.wifi_adapters = {}
        self.network_status = {}
        self.last_wifi_networks_scan = 0
        self.__network_watchdog_task = None
        self.__network_is_down = True
        self.__network_scan_duration = Network.NETWORK_SCAN_DURATION
        self.__network_scan_duration_timer = None

        # events
        self.network_up_event = self._get_event('network.status.up')
        self.network_down_event = self._get_event('network.status.down')
        self.network_status_update_event = self._get_event('network.status.update')
Example #6
0
    def __init__(self, bootstrap, debug_enabled):
        """
        Constructor

        Args:
            bootstrap (dict): bootstrap objects
            debug_enabled (bool): flag to set debug level to logger
        """
        # init
        CleepModule.__init__(self, bootstrap, debug_enabled)

        # members
        self.hostname = Hostname(self.cleep_filesystem)
        self.sun = Sun()
        self.sunset = None
        self.sunrise = None
        self.suns = {
            "sunset": 0,
            "sunset_iso": "",
            "sunrise": 0,
            "sunrise_iso": ""
        }
        self.timezonefinder = TimezoneFinder()
        self.timezone_name = None
        self.timezone = None
        self.time_task = None
        self.sync_time_task = None
        self.__clock_uuid = None
        # code from https://stackoverflow.com/a/106223
        self.__hostname_pattern = (
            r"^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*"
            r"([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$")

        # events
        self.time_now_event = self._get_event("parameters.time.now")
        self.time_sunrise_event = self._get_event("parameters.time.sunrise")
        self.time_sunset_event = self._get_event("parameters.time.sunset")
        self.hostname_update_event = self._get_event(
            "parameters.hostname.update")
        self.country_update_event = self._get_event(
            "parameters.country.update")
Example #7
0
    def __init__(self, bootstrap, debug_enabled):
        """
        Constructor

        Params:
            bootstrap (dict): bootstrap objects
            debug_enabled (bool): debug status
        """
        # init
        CleepModule.__init__(self, bootstrap, debug_enabled)

        # members
        self._tasks_by_device_uuid = {}
        self.raspi_gpios = {}
        self.addons_by_name = {}
        self.addons_by_type = {}
        self.sensors_types = {}

        # addons
        self._register_addon(SensorMotionGeneric(self))
        self._register_addon(SensorOnewire(self))
        self._register_addon(SensorDht22(self))
Example #8
0
    def __init__(self, bootstrap, debug_enabled):
        """
        Constructor

        Args:
            bootstrap (dict): bootstrap objects
            debug_enabled (bool): flag to set debug level to logger
        """
        # init
        CleepModule.__init__(self, bootstrap, debug_enabled)

        # members
        self.teleinfo_task = None
        self.instant_power_device_uuid = None
        self.power_consumption_device_uuid = None
        self.last_raw = {}
        self.__teleinfo_parser = None
        self.__last_conso_heures_creuses = 0
        self.__last_conso_heures_pleines = 0

        # events
        self.power_update_event = self._get_event('teleinfo.power.update')
        self.consumption_update_event = self._get_event(
            'teleinfo.consumption.update')