def check_connection(self, url): """ Check connection status to the server currently selected by user and show a status box indicating current operation. :param url: The link of the server chose by user.This string could be a domain name or the IP address of a server. .. seealso:: :attr:`link` in :meth:`~util.common.CommonUtil.check_connection`. :type url: str :return: A flag indicating connection status is good or not. .. seealso:: :meth:`~util.common.CommonUtil.check_connection`. in :class:`~util.common.CommonUtil` class. :rtype: int """ self.messagebox("Checking Server Status...") conn = CommonUtil.check_connection(url) if conn: self.statusinfo[0][1] = "OK" self.statusinfo[0][2] = "GREEN" else: self.statusinfo[0][1] = "Error" self.statusinfo[0][2] = "RED" self.status() return conn
def check_connection(self, url): """ Check connection status to the server currently selected by user and show a status box indicating current operation. :param url: The link of the server chose by user.This string could be a domain name or the IP address of a server. .. seealso:: :attr:`link` in :meth:`~util.common.CommonUtil.check_connection`. :type url: str :return: A flag indicating connection status is good or not. .. seealso:: :meth:`~util.common.CommonUtil.check_connection`. in :class:`~util.common.CommonUtil` class. :rtype: int """ print("Checking Server Status...") conn = CommonUtil.check_connection(url) if conn: self.statusinfo[0][1] = "OK" self.statusinfo[0][2] = "GREEN" else: self.statusinfo[0][1] = "Error" self.statusinfo[0][2] = "RED" return conn
def run(self): """ Start operations to check the network connection with a specified server. """ self.trigger.emit(-1) status = CommonUtil.check_connection(self.link) self.trigger.emit(status)
def check_connection(cls): """ Check connection status to the servers. Modified from tui.curses_d.CursesDaemon.check_connection() """ cls.show_status("Checking Server Status ...") cls.settings[0][2] = CommonUtil.set_network(cls.netfile) srv_id = 0 for srv_id,server in enumerate(cls.settings[0][2]): cls.show_status("Trying to connect to "+server["tag"]+"...") url = server["test_url"] conn = CommonUtil.check_connection(url) if conn : cls.show_status("Connected!") cls.settings[0][1] = srv_id return cls.show_status("Failed.") cls.show_status("Can not connect to any server!") cls.show_status("Script exits now...") sys.exit(1)