def _check_ntp_server(self, server): """Check if an NTP server appears to be working. :param str server: NTP server address :returns: True if the server appears to be working, False if not :rtype: bool """ log.debug("checking NTP server %s", server) result = ntp.ntp_server_working(server) if result: log.debug("NTP server %s appears to be working", server) self.set_ntp_server_status(server, constants.NTP_SERVER_OK) else: log.debug("NTP server %s appears not to be working", server) self.set_ntp_server_status(server, constants.NTP_SERVER_NOK)
def _set_server_ok_nok(self, itr, epoch_started): """ If the server is working, set its data to SERVER_OK, otherwise set its data to SERVER_NOK. :param itr: iterator of the $server's row in the self._serversStore """ @gtk_action_nowait def set_store_value(arg_tuple): """ We need a function for this, because this way it can be added to the MainLoop with thread-safe GLib.idle_add (but only with one argument). :param arg_tuple: (store, itr, column, value) """ (store, itr, column, value) = arg_tuple store.set_value(itr, column, value) orig_hostname = self._serversStore[itr][0] server_working = ntp.ntp_server_working(self._serversStore[itr][0]) #do not let dialog change epoch while we are modifying data self._epoch_lock.acquire() #check if we are in the same epoch as the dialog (and the serversStore) #and if the server wasn't changed meanwhile if epoch_started == self._epoch: actual_hostname = self._serversStore[itr][0] if orig_hostname == actual_hostname: if server_working: set_store_value((self._serversStore, itr, 1, SERVER_OK)) else: set_store_value((self._serversStore, itr, 1, SERVER_NOK)) self._epoch_lock.release()
def _set_server_ok_nok(self, itr, epoch_started): """ If the server is working, set its data to SERVER_OK, otherwise set its data to SERVER_NOK. :param itr: iterator of the $server's row in the self._serversStore """ @gtk_action_nowait def set_store_value(arg_tuple): """ We need a function for this, because this way it can be added to the MainLoop with thread-safe GLib.idle_add (but only with one argument). :param arg_tuple: (store, itr, column, value) """ (store, itr, column, value) = arg_tuple store.set_value(itr, column, value) orig_hostname = self._serversStore[itr][SERVER_HOSTNAME] server_working = ntp.ntp_server_working( self._serversStore[itr][SERVER_HOSTNAME]) #do not let dialog change epoch while we are modifying data self._epoch_lock.acquire() #check if we are in the same epoch as the dialog (and the serversStore) #and if the server wasn't changed meanwhile if epoch_started == self._epoch: actual_hostname = self._serversStore[itr][SERVER_HOSTNAME] if orig_hostname == actual_hostname: if server_working: set_store_value( (self._serversStore, itr, SERVER_WORKING, SERVER_OK)) else: set_store_value( (self._serversStore, itr, SERVER_WORKING, SERVER_NOK)) self._epoch_lock.release()