예제 #1
0
 def notify_server_status_change(self, state):
     if self.last_notified_server_status and self.last_notified_server_status != state:
         info = { "state" : state, "connection" : self.editor.connection }
         # this will notify the rest of the App that the server state has changed, giving them a chance
         # to reconnect or formally disconnect
         nc.send("GRNServerStateChanged", self.editor, info)
     self.last_notified_server_status = state
예제 #2
0
    def force_check_server_state(self, verbose=False):
        # Check the current state of the server and cause the SQL Editor to reconnect/update if the state
        # changed. Returns None if no state change was detected or the new state if it did change.
        old_state = self.last_known_server_running_status[0]
        new_state = self.is_server_running(verbose=verbose,
                                           force_hard_check=True)
        log_debug("Force check server state returned %s\n" % new_state)
        if new_state != old_state:
            info = {
                "state": -1,
                "connection": self.server_profile.db_connection_params
            }
            if new_state == "running":
                info['state'] = 1
            elif new_state == "offline":
                info['state'] = -1
            else:
                info['state'] = 0

            # this will notify the rest of the App that the server state has changed, giving them a chance
            # to reconnect or formally disconnect
            nc.send("GRNServerStateChanged", self.editor, info)

            if new_state == "stopped" or new_state == "offline":
                self.server_variables = {}
                self.status_variables_time = None
                self.status_variables = {}

            return new_state
        return None
 def offline_mode_clicked(self):
     info = { "state" : -1, "connection" : self._ctrl_be.server_profile.db_connection_params }
     if self._ctrl_be.is_server_running() == "offline":
         self._ctrl_be.exec_query("SET GLOBAL offline_mode = off")
         self._ctrl_be.event_from_main("server_started")
         info['state'] = 1
     else:
         self._ctrl_be.exec_query("SET GLOBAL offline_mode = on")
         self._ctrl_be.event_from_main("server_offline")
         info['state'] = -1
         
     #we need to send notification that server state has changed,
     nc.send("GRNServerStateChanged", self._ctrl_be.editor, info)
 def offline_mode_clicked(self):
     info = { "state" : -1, "connection" : self.ctrl_be.server_profile.db_connection_params }
     if self.ctrl_be.is_server_running() == "offline":
         self.ctrl_be.exec_query("SET GLOBAL offline_mode = off")
         self.ctrl_be.event_from_main("server_started")
         info['state'] = 1
     else:
         self.ctrl_be.exec_query("SET GLOBAL offline_mode = on")
         self.ctrl_be.event_from_main("server_offline")
         info['state'] = -1
         
     #we need to send notification that server state has changed,
     nc.send("GRNServerStateChanged", self.ctrl_be.editor, info)