Ejemplo n.º 1
0
    def setup(self, ksdata):
        timezone_proxy = TIMEZONE.get_proxy()
        services_proxy = SERVICES.get_proxy()

        enabled_services = services_proxy.EnabledServices
        disabled_services = services_proxy.DisabledServices

        # do not install and use NTP package
        if not timezone_proxy.NTPEnabled or NTP_PACKAGE in ksdata.packages.excludedList:
            if util.service_running(
                    NTP_SERVICE) and conf.system.can_set_time_synchronization:
                ret = util.stop_service(NTP_SERVICE)
                if ret != 0:
                    timezone_log.error("Failed to stop NTP service")

            if NTP_SERVICE not in disabled_services:
                disabled_services.append(NTP_SERVICE)
                services_proxy.SetDisabledServices(disabled_services)
        # install and use NTP package
        else:
            if not util.service_running(
                    NTP_SERVICE) and conf.system.can_set_time_synchronization:
                ret = util.start_service(NTP_SERVICE)
                if ret != 0:
                    timezone_log.error("Failed to start NTP service")

            self.packages.append(NTP_PACKAGE)

            if not NTP_SERVICE in enabled_services and \
                    not NTP_SERVICE in disabled_services:
                enabled_services.append(NTP_SERVICE)
                services_proxy.SetEnabledServices(enabled_services)
Ejemplo n.º 2
0
    def setup(self, ksdata):
        timezone_proxy = TIMEZONE.get_proxy()
        services_proxy = SERVICES.get_proxy()

        enabled_services = services_proxy.EnabledServices
        disabled_services = services_proxy.DisabledServices

        # do not install and use NTP package
        if not timezone_proxy.NTPEnabled or NTP_PACKAGE in ksdata.packages.excludedList:
            if util.service_running(NTP_SERVICE) and conf.system.can_set_time_synchronization:
                ret = util.stop_service(NTP_SERVICE)
                if ret != 0:
                    timezone_log.error("Failed to stop NTP service")

            if NTP_SERVICE not in disabled_services:
                disabled_services.append(NTP_SERVICE)
                services_proxy.SetDisabledServices(disabled_services)
        # install and use NTP package
        else:
            if not util.service_running(NTP_SERVICE) and conf.system.can_set_time_synchronization:
                ret = util.start_service(NTP_SERVICE)
                if ret != 0:
                    timezone_log.error("Failed to start NTP service")

            self.packages.append(NTP_PACKAGE)

            if not NTP_SERVICE in enabled_services and \
                    not NTP_SERVICE in disabled_services:
                enabled_services.append(NTP_SERVICE)
                services_proxy.SetEnabledServices(enabled_services)
Ejemplo n.º 3
0
    def refresh(self):
        self._shown = True

        # update the displayed time
        self._update_datetime_timer = Timer()
        self._update_datetime_timer.timeout_sec(1, self._update_datetime)
        self._start_updating_timer = None

        kickstart_timezone = self._timezone_module.proxy.Timezone

        if is_valid_timezone(kickstart_timezone):
            self._tzmap.set_timezone(kickstart_timezone)
            time.tzset()

        self._update_datetime()

        has_active_network = self._network_module.proxy.Connected
        if not has_active_network:
            self._show_no_network_warning()
        else:
            self.clear_info()
            gtk_call_once(self._config_dialog.refresh_servers_state)

        if conf.system.can_set_time_synchronization:
            ntp_working = has_active_network and util.service_running(
                NTP_SERVICE)
        else:
            ntp_working = self._timezone_module.proxy.NTPEnabled

        self._ntpSwitch.set_active(ntp_working)
Ejemplo n.º 4
0
    def refresh(self):
        self._shown = True

        # update the displayed time
        self._update_datetime_timer = Timer()
        self._update_datetime_timer.timeout_sec(1, self._update_datetime)
        self._start_updating_timer = None

        kickstart_timezone = self._timezone_module.proxy.Timezone

        if is_valid_timezone(kickstart_timezone):
            self._tzmap.set_timezone(kickstart_timezone)
            time.tzset()

        self._update_datetime()

        has_active_network = self._network_module.proxy.Connected
        if not has_active_network:
            self._show_no_network_warning()
        else:
            self.clear_info()
            gtk_call_once(self._config_dialog.refresh_servers_state)

        if conf.system.can_set_time_synchronization:
            ntp_working = has_active_network and util.service_running(NTP_SERVICE)
        else:
            ntp_working = self._timezone_module.proxy.NTPEnabled

        self._ntpSwitch.set_active(ntp_working)
Ejemplo n.º 5
0
    def refresh(self):
        self._shown = True

        # update the displayed time
        self._update_datetime_timer = Timer()
        self._update_datetime_timer.timeout_sec(1, self._update_datetime)
        self._start_updating_timer = None

        if is_valid_timezone(self.data.timezone.timezone):
            self._tzmap.set_timezone(self.data.timezone.timezone)
            time.tzset()

        self._update_datetime()

        has_active_network = nm.nm_is_connected()
        if not has_active_network:
            self._show_no_network_warning()
        else:
            self.clear_info()
            gtk_call_once(self._config_dialog.refresh_servers_state)

        if flags.can_touch_runtime_system("get NTP service state"):
            ntp_working = has_active_network and util.service_running(
                NTP_SERVICE)
        else:
            ntp_working = not self.data.timezone.nontp

        self._ntpSwitch.set_active(ntp_working)
Ejemplo n.º 6
0
    def on_ntp_switched(self, switch, *args):
        if switch.get_active():
            #turned ON
            if not conf.system.can_set_time_synchronization:
                #cannot touch runtime system, not much to do here
                return

            if not self._network_module.proxy.Connected:
                self._show_no_network_warning()
                switch.set_active(False)
                return
            else:
                self.clear_info()

                working_server = self._config_dialog.working_server
                if working_server is None:
                    self._show_no_ntp_server_warning()
                else:
                    #we need a one-time sync here, because chronyd would not change
                    #the time as drastically as we need
                    ntp.one_time_sync_async(working_server)

            ret = util.start_service(NTP_SERVICE)
            self._set_date_time_setting_sensitive(False)

            #if starting chronyd failed and chronyd is not running,
            #set switch back to OFF
            if (ret != 0) and not util.service_running(NTP_SERVICE):
                switch.set_active(False)

        else:
            #turned OFF
            if not conf.system.can_set_time_synchronization:
                #cannot touch runtime system, nothing to do here
                return

            self._set_date_time_setting_sensitive(True)
            ret = util.stop_service(NTP_SERVICE)

            #if stopping chronyd failed and chronyd is running,
            #set switch back to ON
            if (ret != 0) and util.service_running(NTP_SERVICE):
                switch.set_active(True)

            self.clear_info()
Ejemplo n.º 7
0
    def on_ntp_switched(self, switch, *args):
        if switch.get_active():
            #turned ON
            if not conf.system.can_set_time_synchronization:
                #cannot touch runtime system, not much to do here
                return

            if not self._network_module.proxy.Connected:
                self._show_no_network_warning()
                switch.set_active(False)
                return
            else:
                self.clear_info()

                working_server = self._config_dialog.working_server
                if working_server is None:
                    self._show_no_ntp_server_warning()
                else:
                    #we need a one-time sync here, because chronyd would not change
                    #the time as drastically as we need
                    ntp.one_time_sync_async(working_server)

            ret = util.start_service(NTP_SERVICE)
            self._set_date_time_setting_sensitive(False)

            #if starting chronyd failed and chronyd is not running,
            #set switch back to OFF
            if (ret != 0) and not util.service_running(NTP_SERVICE):
                switch.set_active(False)

        else:
            #turned OFF
            if not conf.system.can_set_time_synchronization:
                #cannot touch runtime system, nothing to do here
                return

            self._set_date_time_setting_sensitive(True)
            ret = util.stop_service(NTP_SERVICE)

            #if stopping chronyd failed and chronyd is running,
            #set switch back to ON
            if (ret != 0) and util.service_running(NTP_SERVICE):
                switch.set_active(True)

            self.clear_info()
Ejemplo n.º 8
0
    def on_ntp_switched(self, switch, *args):
        if switch.get_active():
            #turned ON
            if not conf.system.can_set_time_synchronization:
                #cannot touch runtime system, not much to do here
                return

            if not self._network_module.Connected:
                self._show_no_network_warning()
                switch.set_active(False)
                return
            else:
                self.clear_info()
                working_server = self._get_working_server()

                if working_server is None:
                    self._show_no_ntp_server_warning()

            ret = util.start_service(NTP_SERVICE)
            self._set_date_time_setting_sensitive(False)

            #if starting chronyd failed and chronyd is not running,
            #set switch back to OFF
            if (ret != 0) and not util.service_running(NTP_SERVICE):
                switch.set_active(False)

        else:
            #turned OFF
            if not conf.system.can_set_time_synchronization:
                #cannot touch runtime system, nothing to do here
                return

            self._set_date_time_setting_sensitive(True)
            ret = util.stop_service(NTP_SERVICE)

            #if stopping chronyd failed and chronyd is running,
            #set switch back to ON
            if (ret != 0) and util.service_running(NTP_SERVICE):
                switch.set_active(True)

            self.clear_info()
Ejemplo n.º 9
0
    def refresh(self):
        self._shown = True

        # update the displayed time
        self._update_datetime_timer = Timer()
        self._update_datetime_timer.timeout_sec(1, self._update_datetime)
        self._start_updating_timer = None

        kickstart_timezone = self._timezone_module.Timezone

        if is_valid_timezone(kickstart_timezone):
            self._tzmap.set_timezone(kickstart_timezone)
            time.tzset()

        self._update_datetime()

        # update the ntp configuration
        self._ntp_servers = TimeSourceData.from_structure_list(
            self._timezone_module.TimeSources)

        if not self._ntp_servers:
            try:
                self._ntp_servers = ntp.get_servers_from_config()
            except ntp.NTPconfigError:
                log.warning("Failed to load NTP servers configuration")

        self._ntp_servers_states = NTPServerStatusCache()
        self._ntp_servers_states.changed.connect(
            self._update_ntp_server_warning)

        has_active_network = self._network_module.Connected

        if not has_active_network:
            self._show_no_network_warning()
        else:
            self.clear_info()

            for server in self._ntp_servers:
                self._ntp_servers_states.check_status(server)

        if conf.system.can_set_time_synchronization:
            ntp_working = has_active_network and util.service_running(
                NTP_SERVICE)
        else:
            ntp_working = self._timezone_module.NTPEnabled

        self._ntpSwitch.set_active(ntp_working)